Skip to content

Conversation

@Mehdi-H
Copy link

@Mehdi-H Mehdi-H commented Jul 30, 2023

Summary

This PR is linked to #180

  • Breaking change : default behavior is now to install only main dependency group from pyproject.toml
    • Previous behavior: poetry installs every dependencies, even the ones not necessary for production, regardless of the dependency groups
  • Possibility to specify additional dependency groups with env variable BP_POETRY_INSTALL_WITH, mirroring the --with option from poetry install command
  • README.md is updated to describe this new behaviors
  • Unit and integration tests where added

Use Cases

Check #180 discussion for more details

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@Mehdi-H Mehdi-H requested a review from a team as a code owner July 30, 2023 19:14
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 30, 2023

CLA Missing ID CLA Not Signed

* Choose additionnal dependency groups to install via BP_POETRY_INSTALL_WITH env variable
@Mehdi-H Mehdi-H force-pushed the install-dependencies-with-group branch from ca25f4c to be22893 Compare July 30, 2023 19:26
@robdimsdale robdimsdale added the semver:minor A change requiring a minor version bump label Jul 30, 2023
@robdimsdale
Copy link
Member

Thanks @Mehdi-H - could you sign the CLA? The bot above has a link. You can either sign as an individual or as part of a corporate CLA.

Copy link
Member

@robdimsdale robdimsdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting this! This generally looks good. I have a few comments/suggestions/questions inline, and once we address those I think we'll be good to merge this.

SetDefaultEventuallyTimeout(30 * time.Second)

suite := spec.New("Integration", spec.Report(report.Terminal{}))
suite("Default", testDefault, spec.Parallel())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we removed the spec.Parallel() - was that intentional? Did you observe the tests failing with that present?

MatchRegexp(fmt.Sprintf(
" Running 'POETRY_CACHE_DIR=/layers/%s/cache POETRY_VIRTUALENVS_PATH=/layers/%s/poetry-venv poetry install --with dev'",
strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"),
strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this strings.ReplaceAll twice - the second invocation should be redundant.

MatchRegexp(fmt.Sprintf(` PATH -> "/layers/%s/poetry-venv/default-app-.*-py\d+\.\d+/bin:\$PATH"`, strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"))),
MatchRegexp(fmt.Sprintf(` POETRY_VIRTUALENVS_PATH -> "/layers/%s/poetry-venv"`, strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"))),
MatchRegexp(fmt.Sprintf(` PYTHONPATH -> "/layers/%s/poetry-venv/default-app-.*-py\d+\.\d+/lib/python\d+\.\d+/site-packages:\$PYTHONPATH"`, strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"))),
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the "" and replace it with another invocation of Expect(logs).To(ContainLines(...))?

We've found that asserting on empty log lines is brittle, because sometimes extra lines get inserted due to environment issues (deprecation warnings, etc).

A second invocation of ContainLines() will continue to preserve the assertions on the line ordering.

// check an SBOM file to make sure it has an entry for a poetry dependency
contents, err := os.ReadFile(filepath.Join(sbomDir, "sbom", "launch", strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_"), "poetry-venv", "sbom.cdx.json"))
Expect(err).NotTo(HaveOccurred())
Expect(string(contents)).To(ContainSubstring(`"name": "flask"`))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this test, could you also add the environment variable: WithEnv(map[string]string{"BP_POETRY_INSTALL_WITH": "dev"}). and could you also add an assertion that the SBOM contains a dev dependency?

Similarly, could you add an assertion to the default_test to assert that the SBOM does not contain a dev dependency?

@robdimsdale
Copy link
Member

robdimsdale commented Jul 30, 2023

Also, as discussed in #180 - although this is technically a breaking change, I don't think it will break any users in practice, as I don't believe users are expecting their apps to contain dependencies other than the main group. The fact that they were, and now will be removing them by default, should be invisible to users.

As such, I'm labeling this as: semver:minor

@robdimsdale
Copy link
Member

@Mehdi-H as far as the CLA, I think part of the issue is that your commit was made from an email that isn't associated with your github account. The links in the CLA bot's comment above should help.

@radoshi
Copy link

radoshi commented Apr 19, 2024

Hi @Mehdi-H @robdimsdale ,

We would like to see this issue fixed as well. I think Mehdi has done all of the heavy lifting here but this PR seems to have fallen off.

Would y'all have any objections if I picked it up and finished it? Here is a draft PR with all the review comments addressed. It passes unit and integration tests.
#347

Thank you,
-Rushabh

@TheSuperiorStanislav
Copy link
Contributor

Hi @Mehdi-H @robdimsdale any progress on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:minor A change requiring a minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants