-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question ❓] How to install only "root/run" dependencies and ignore other groups dependencies #180
Comments
Makes total sense. You're on the leading edge! Not many folks are using paketo buildpacks + poetry in production yet. I can reproduce this, and I agree we should provide a mechanism to only install production dependencies. I was hoping that we could leverage environment variables to configure which dependencies to install (similar to So it seems we'll have to invent an API for this. I think it would look something like providing the environment variable Is this something you're interested in contributing? We can lay out the changes necessary if so. |
Hello @robdimsdale, thanks for the quick answer ! I don't know paketo, buildpacks nor Go very well but I can take a look at it and try to make a pull request :) I will most certainly ask you some questions in this issue after taking a look at the code ! |
Awesome! So I think you're going to want to start with this line in
I think we're going to want to expand that to read from the environment variable
We should add unit tests for this in Finally we should probably add an integration test. You could probably copy |
Hello @robdimsdale , I took a look at Poetry documentation for the install command, and surprisingly, it is not possible to install only "root/run" dependencies with $>poetry install --with root;
Group(s) not found: root (via --with) It seems, the only way to achieve this is to run Before starting to implement tests and code, I wanted to check with you the expected behavior for this pull request :
What do you think ? Also, maybe the env variable should be named |
Oh, sorry, I thought you wanted to install
https://python-poetry.org/docs/managing-dependencies/#dependency-groups |
Oh, I learned something ! As the "main/root" group name is not documented well in Poetry docs, I thought it was not possible to install only the main group with I'll go with the following tests suite :
What do you think ? |
Yup that sounds good, thanks! Technically it's a breaking change to default to Also Cloud Native Buildpacks doesn't have any mechanism for running tests, or toolchain commands (like code coverage, etc) so I think defaulting to |
Hi @robdimsdale , I have started an implementation, with unit tests passing, in this fork : Mehdi-H@84c30e1 I have trouble with the integration tests : I managed to run them, but they are failing as the default behavior is breaking During the integration tests, the build ends up with this error :
I am a bit lost as to what assertion in the integration tests is failing exactly, a global repo search on "does not exist" gets 0 result. Any idea where to look ? |
Thanks for getting started with this. The issue is that the args need to be separate strings in an array, not space-separated. What's happening in your code currently is the following (quotes added to make it clear that's a single argument):
When really what you need is:
If you change:
to:
That should resolve your issue. |
Otherwise this PR looks like it's heading in the right direction! |
Hello @robdimsdale , Unit and integration tests are green, can you take a look at this pull request ? - #182 I'll take any feedback ! EDIT: I see that the PR pipeline is red, but I don't think I can fix it on my own |
I would welcome this as well, thanks for the fix @Mehdi-H ! Any update on integration ? |
Hello @binomaiheu and @robdimsdale, sorry for the inactivity, I did not have access to the internet for the past month I see that I have to
I will try to take a look at all this in the next few days |
We got hit by this as well. I'd like to add a potential work around: In Ref: https://python-poetry.org/docs/managing-dependencies/#optional-groups |
Any updates on this? Got hit also. |
General summary of the issue
I am suprised that running "pack build" with
paketo-buildpacks/poetry-install
installs all the dependencies described in my pyproject.toml file.For production, I only want to install run dependencies (in
[tool.poetry.dependencies]
section), dependencies in other groups (such as[tool.poetry.group.dev.dependencies]
) are not necessary and make the built image heavier than necessaryExpected Behavior
When running
pack build [my_image] --builder paketobuildpacks/builder:base
(usingpaketo-buildpacks/poetry-install
in Detection phase) I expectpaketo-buildpacks/poetry-install
to run the following command :POETRY_CACHE_DIR=/layers/paketo-buildpacks_poetry-install/cache POETRY_VIRTUALENVS_PATH=/layers/paketo-buildpacks_poetry-install/poetry-venv poetry install --only main
Having the following dependencies in pyproject.toml, I expect only fastapi and uvicorn to be installed, without pytest ✅ :
Current Behavior
When running
pack build [my_image] --builder paketobuildpacks/builder:base
(usingpaketo-buildpacks/poetry-install
in Detection phase), I see in the log that the following command is run :POETRY_CACHE_DIR=/layers/paketo-buildpacks_poetry-install/cache POETRY_VIRTUALENVS_PATH=/layers/paketo-buildpacks_poetry-install/poetry-venv poetry install
Having the following dependencies in pyproject.toml, pytest is installed 😢 :
I see the following logs in the console :
Question
I don't see any configuration or environment variable to add arguments to "poetry install" command in the README.md file, is there something that I missed ?
Steps to Reproduce
Tell me if this is necessary and I can setup a repository with reproducible steps, as it can take me some time to do it. I'll do it happily :)
Motivations
In the current situation, having poetry installing all dependencies, even the ones I do not need is a no-go for any of my projects in production.
The text was updated successfully, but these errors were encountered: