export - ability to chose subset of dependencies to export
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] I have searched the documentation and believe that my question is not covered.
Feature Request
The use case I'm thinking of here is CI pipelines and dev dependencies.
Most of the time I don't need all dev dependencies for a build. For example, I might use black and flake8 locally but only want to run unit tests in my CI build, in which case installing black and flake8 on a CI box just adds time.
In terms of CLI, thinking something like
poetry export -f requirements.txt --ignore black flake8 > requirements.txt
n.b. I'm not looking to export only dev deps (like https://github.com/python-poetry/poetry/issues/1441) but rather a way to selectively exclude deps (dev or prod).
I just have opened a similar issue: https://github.com/python-poetry/poetry/issues/2009. The export part of poetry needs to be increased. Maybe you can try with dephell you may have more chance than me on your use case...
I just have opened a similar issue: python-poetry/poetry-export-plugin#39.
These two issues seem related only insofar as they concern the export command. Maybe I'm not grokking yours though.
I can try to see what I can do, I have started a PR (https://github.com/python-poetry/poetry/pull/2013) :)
Hi, I would also like the ability to chose subset of dependencies to export but for a different use case from @zachvalenta
I have a project with multiple services, each requiring their own requirements.
project/
|-- pyproject.toml
|-- docker-compose.yml
|-- project/
|-- server/
|-- Dockerfile
|-- requirements.txt (to be exported by poetry when building the image)
|-- worker/
|-- Dockerfile
|-- requirements.txt (to be exported by poetry when building the image)
In the example above, suppose the server service requires flask, celery, sqlalchemy and worker service requires celery, tensorflow, I would like a way to export only the dependencies that are needed for the service.
Possible solution: I was thinking that a tagging solution would be possible in the toml file. For example:
[tool.poetry.dependencies]
flask = { version="^1.1.1", tags=["server"] }
celery = { version="^4.4.0", tags=["server", "worker"] }
tensorflow = { version="^2.1.0", tags=["worker"] }
sqlalchemy = { version="^1.3.13", tags=["server"] }
then, when exporting, we can just specify that tag to export:
poetry export -f requirements.txt --tag=server > requirements.txt
If no tag is provided, then the current behaviour is the default behaviour.
It's a possible to use with extras in pyproject.toml as temporary solution https://github.com/RCheese/deplodocker
Could be made more likely to happen by https://github.com/python-poetry/poetry/issues/1644 (scheduled for v1.2).
I need this!