Skip to content

Conversation

@TheSuperiorStanislav
Copy link
Contributor

@TheSuperiorStanislav TheSuperiorStanislav commented Jul 18, 2025

Summary

Use sync(install --sync in v1) for installing dependencies

Closes #96

Use Cases

When changing BP_POETRY_INSTALL_ONLY between main and dev and running pack build, I noticed that install doesn't remove deps that are not matching the selected group, and only checks that all deps from specified group are installed.

pack build --builder=paketobuildpacks/builder-jammy-base:latest --run-image=paketobuildpacks/run-jammy-base:latest test-image --env=BP_POETRY_INSTALL_ONLY=main

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).

@TheSuperiorStanislav
Copy link
Contributor Author

TheSuperiorStanislav commented Jul 18, 2025

I don't know how to address this one since locally and in my fork(Github Actions) are passing
image
TheSuperiorStanislav#2

@TheSuperiorStanislav TheSuperiorStanislav marked this pull request as ready for review July 18, 2025 09:42
@TheSuperiorStanislav TheSuperiorStanislav requested a review from a team as a code owner July 18, 2025 09:42
poetryVersion = "2.*"
}
installCmd := []string{"sync"}
// Can be remove once support for poetry v1 is removed
Copy link

Choose a reason for hiding this comment

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

Just a thought as we do this for other buildpacks.

Maybe the arguments could be configurable? Like BP_POETRY_INSTALL_ARGS. You could default that to the appropriate args for each version. Users could then override that if they want other args.

Seems like it would solve this problem but continue to be a useful feature beyond this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, but I don't think the default install buildpack works as intended.

I have included the following example as a test project I created for myself.

pyproject.toml

[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = "^3.13"
django = "^5.2.4"
fastapi = "^0.116.1"

project.toml

[build]
exclude = [
    ".venv",
]

Procfile

web: python3 main.py

main.py

try:
    import django
    print(django)
except ImportError:
    print("Fail to import django")
try:
    import fastapi
    print(fastapi)
except ImportError:
    print("Fail to import fastapi")

So I built an image with

pack build --builder=paketobuildpacks/builder-jammy-base:latest --run-image=paketobuildpacks/run-jammy-base:latest test-image

Then run it

docker run test-image

Output

<module 'django' from '/layers/paketo-buildpacks_poetry-install/poetry-venv/non-package-mode-xS3fZVNL-py3.13/lib/python3.13/site-packages/django/__init__.py'>
<module 'fastapi' from '/layers/paketo-buildpacks_poetry-install/poetry-venv/non-package-mode-xS3fZVNL-py3.13/lib/python3.13/site-packages/fastapi/__init__.py'>

As expected, okay, let's remove fastapi from pyproject.toml and update lock file. And repeat the build and run command.

Output

<module 'django' from '/layers/paketo-buildpacks_poetry-install/poetry-venv/non-package-mode-xS3fZVNL-py3.13/lib/python3.13/site-packages/django/__init__.py'>
<module 'fastapi' from '/layers/paketo-buildpacks_poetry-install/poetry-venv/non-package-mode-xS3fZVNL-py3.13/lib/python3.13/site-packages/fastapi/__init__.py'>

Hmm, weird, where does FastAPI come from? If I rebuild with no cache

<module 'django' from '/layers/paketo-buildpacks_poetry-install/poetry-venv/non-package-mode-xS3fZVNL-py3.13/lib/python3.13/site-packages/django/__init__.py'>
Fail to import fastapi

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explore poetry install --sync

2 participants