Skip to content

Commit

Permalink
#72 🐛 remove custom monorepo group to allow transitive dependencies t…
Browse files Browse the repository at this point in the history
…o work more seamlessly
  • Loading branch information
d-ryan-ashcraft committed Mar 12, 2024
1 parent 24b6e7c commit b197cd4
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 400 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ Habushu will replace invocations of Poetry's `build` and `publish` commands with
`poetry-monorepo-dependency-plugin`, which are `build-rewrite-path-deps` and `publish-rewrite-path-deps`, respectively.

To further ease working with monorepo dependencies, Habushu will specially handle how these dependencies are written to
intermediate `requirements.txt` exports if they are included in the `[tool.poetry.group.monorepo.dependencies]` group
within your `pyproject.toml` file. In this case, the dependencies will be excluded from the export unless `rewriteLocalPathDepsInArchives`
is set to true. This feature can be useful if installing the exported `requirements.txt` on another machine and/or
Docker container. If a monorepo dependency is not included in this specific group, it will be exported with a local path.
intermediate `requirements.txt` exports. In this case, the dependencies will be excluded from the export unless
`rewriteLocalPathDepsInArchives` is set to true. This feature can be useful if installing the exported
`requirements.txt` on another machine and/or Docker container. If a monorepo dependency is not included in this
specific group, it will be exported with a local path.

Typically, this flag will only be `true` when deploying/releasing Habushu modules within a CI environment that are part of a monorepo project
structure which multiple Poetry projects depend on one another.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
@Mojo(name = "build-deployment-artifacts", defaultPhase = LifecyclePhase.PACKAGE)
public class BuildDeploymentArtifactsMojo extends AbstractHabushuMojo {

public static final String TOOL_POETRY_GROUP_MONOREPO_DEPENDENCIES = "tool.poetry.group.monorepo.dependencies";
/**
* By default, export requirements.txt file.
*/
Expand Down Expand Up @@ -96,7 +95,6 @@ public void doExecute() throws MojoExecutionException, MojoFailureException {
if (exportRequirementsFile) {
getLog().info("Exporting requirements.txt file...");

String outputFile = exportRequirementsFolder + "/requirements.txt";
File directory = new File(exportRequirementsFolder);
if (!directory.exists()) {
directory.mkdir();
Expand All @@ -105,15 +103,9 @@ public void doExecute() throws MojoExecutionException, MojoFailureException {
List<String> command = new ArrayList<>();
command.add("export");
command.add("--output");
String outputFile = exportRequirementsFolder + "/requirements.txt";
command.add(outputFile);

List<String> customPoetryToolGroups = findCustomToolPoetryGroups();
if (!rewriteLocalPathDepsInArchives && customPoetryToolGroups.contains(TOOL_POETRY_GROUP_MONOREPO_DEPENDENCIES)) {
command.add("--without");
command.add("monorepo");
logLocalMonorepoCaveats();
}


if (!exportRequirementsWithHashes) {
command.add("--without-hashes");
Expand All @@ -129,23 +121,6 @@ public void doExecute() throws MojoExecutionException, MojoFailureException {
}
}

private void logLocalMonorepoCaveats() {
getLog().info(String.format("Excluding [%s] to prevent path references in requirements.txt",
TOOL_POETRY_GROUP_MONOREPO_DEPENDENCIES));
getLog().info("The following dependencies must be install manually if using requirements.txt (e.g., pip install needed-dependency.whl):");

try (FileConfig pyProjectConfig = FileConfig.of(getPoetryPyProjectTomlFile())) {
pyProjectConfig.load();
Optional<Config> packageSources = pyProjectConfig.getOptional(TOOL_POETRY_GROUP_MONOREPO_DEPENDENCIES);
if (packageSources.isPresent()) {
Config monoRepoDependencies = packageSources.get();
for (String dependencyKey : monoRepoDependencies.valueMap().keySet()) {
getLog().info(String.format("\t- %s", dependencyKey));
}
}
}
}

protected void setUpPlaceholderFileAsMavenArtifact() {
mavenArtifactFile.getParentFile().mkdirs();
try (PrintWriter writer = new PrintWriter(mavenArtifactFile)) {
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions habushu-maven-plugin/src/main/resources/migrations.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
[
{
"name": "custom-monorepo-group-migration",
"implementation": "org.technologybrewery.habushu.migration.CustomMonorepoGroupMigration",
"fileSets": [
{
"includes": ["pyproject.toml"]
}
]
},
{
"name": "custom-poetry-core-version-migration",
"implementation": "org.technologybrewery.habushu.migration.CustomPoetrycoreVersionMigration",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit b197cd4

Please sign in to comment.