Skip to content
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

export - ability to chose subset of dependencies to export #40

Open
2 tasks done
zachvalenta opened this issue Feb 10, 2020 · 7 comments
Open
2 tasks done

export - ability to chose subset of dependencies to export #40

zachvalenta opened this issue Feb 10, 2020 · 7 comments

Comments

@zachvalenta
Copy link

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • 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 python-poetry/poetry#1441) but rather a way to selectively exclude deps (dev or prod).

@gsemet
Copy link

gsemet commented Feb 10, 2020

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

@zachvalenta
Copy link
Author

I just have opened a similar issue: #39.

These two issues seem related only insofar as they concern the export command. Maybe I'm not grokking yours though.

@gsemet
Copy link

gsemet commented Feb 10, 2020

I can try to see what I can do, I have started a PR (python-poetry/poetry#2013) :)

@cadmusthefounder
Copy link

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.

@RCheese
Copy link

RCheese commented Nov 9, 2020

It's a possible to use with extras in pyproject.toml as temporary solution
https://github.com/RCheese/deplodocker

@sinoroc
Copy link

sinoroc commented Nov 10, 2020

Could be made more likely to happen by python-poetry/poetry#1644 (scheduled for v1.2).

@clistion
Copy link

I need this!

@finswimmer finswimmer transferred this issue from python-poetry/poetry Dec 28, 2021
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

No branches or pull requests

6 participants