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

Extra requirements are lost in pip-compile comments #1577

Open
sawatsky opened this issue Feb 8, 2022 · 5 comments
Open

Extra requirements are lost in pip-compile comments #1577

sawatsky opened this issue Feb 8, 2022 · 5 comments
Labels
annotations Related to packages annotations extras Handling optional dependencies

Comments

@sawatsky
Copy link

sawatsky commented Feb 8, 2022

I have a requirements.txt file with the following:

my-package[extra]~=1.0
my-sub-package~=1.1

When I run python -m piptools compile, the extra requirement [extra] gets lost in the list of via requirements under my-sub-package:

my-package[extra]==1.0.0
    # via -r requirements.txt
my-sub-package==1.1.1
    # via
    #   -r requirements.txt
    #   my-package

I need the extra requirements to remain in the comments. We're parsing the output file of pip-compile that's breaking because the [extra] requirement is gone from the comments.

@AndydeCleyre
Copy link
Contributor

Let's say there are two subpackages, package A is always required by the top level package, and package B is only required when [EXTRA] is specified.

Should the annotations for both of these subpackages include the [EXTRA], or only for package B?

@atugushev
Copy link
Member

I'm inclined to think that pip-compile should strip all extras in compiled requirements.txt. See explanation by @FlorentJeannot in #1453 (comment). Of course this requires some discussion.

@FlorentJeannot
Copy link
Contributor

@atugushev I think we could have something like that in the requirements.txt:

my-package==1.0.0
    # via -r requirements.txt
my-sub-package==1.1.1
    # via
    #   -r requirements.txt
    #   my-package[extra]

Meaning: we strip all extras, but we keep them in the comments for clarity if someone wants to review where the package comes from.
What do you think?
@sawatsky would my example above meet your needs?

@atugushev
Copy link
Member

atugushev commented Feb 20, 2022

what if my-sub-package is required by my-package, my-package[extra1], and my-package[extra2] in sub-dependencies? Then it would be:

my-sub-package==1.1.1
    # via
    #   -r requirements.txt
    #   my-package
    #   my-package[extra1]
    #   my-package[extra2]

or like this (but here we need to merge extras somehow):

my-sub-package==1.1.1
    # via
    #   -r requirements.txt
    #   my-package
    #   my-package[extra1,extra2]

I'd still prefer to strip all extras:

my-sub-package==1.1.1
    # via
    #   -r requirements.txt
    #   my-package

@FlorentJeannot
Copy link
Contributor

Good point, I agree with you then.

@atugushev atugushev added the annotations Related to packages annotations label Apr 6, 2022
@atugushev atugushev added the extras Handling optional dependencies label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotations Related to packages annotations extras Handling optional dependencies
Projects
None yet
Development

No branches or pull requests

4 participants