-
-
Notifications
You must be signed in to change notification settings - Fork 611
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 requirement support (extras_require) #1363
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1363 +/- ##
==========================================
+ Coverage 99.65% 99.67% +0.01%
==========================================
Files 33 33
Lines 2939 3037 +98
Branches 308 327 +19
==========================================
+ Hits 2929 3027 +98
Misses 5 5
Partials 5 5
Continue to review full report at Codecov.
|
Is there anything that remains to do? |
Could you add a test for |
What's the expected behavior? AFAIK, |
@orsinium IMO there should be an error. |
Done 👍🏿 |
small-fake-c = "0.3" | ||
small-fake-d = "0.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that these are duplicated in here and in the extras?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is how poetry works. Here is the specification, in extras
only names.
assert "small-fake-e" not in out.stderr | ||
assert "small-fake-f" not in out.stderr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand. Is "extra" supposed to only select the dists that are listed in extras but not the main runtime deps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small-fake-e and small-fake-f are from another extra, the test
one, we pass only dev
.
piptools/scripts/compile.py
Outdated
"--extra", | ||
"extras", | ||
multiple=True, | ||
help="names of extras_require to install", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/n/N
- If this is supposed to install only extras but not the default runtime deps, can this be renamed into
--extra-only
? - If it's supposed to merge those extras with the main runtime deps list, can we add an additional flag
--extras-only
/--exclude-default-deps
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last one, default dependencies are always selected. I don't think --exclude-default-deps
makes sense, I'd make a separate discussion for it. AFAIK, setuptools/poetry/flit/pip doesn't have a way to opt-out installing the default dependencies, so I see no reason why pip-tools should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a long-standing feature request in pip and I think there's been no opposition, just nobody had time to come up with an implementation. The main motivation was that people often supply test/dev/docs extras for different processes they have and some of them don't really require the dist itself to be installed. Of course, there's another camp saying that this sort of deps should be put elsewhere because they aren't necessary for the runtime and there should be env pins anyway.
But if pip-tools were to implement this flag, it'd facilitate a hybrid of these two approaches with the direct open-ended deps in the dist metadata configs and the pins existing in separate constraints files.
But yes, this could probably be brought up in a separate discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm from that camp too. I have a separate environment for every tool. However, most of the tools still need dependencies: pytest
for sure, mypy
for type-checking of third-party libs usage, pylint
for inference-based tasks. In my projects, only flake8
works nicely without knowing the project dependencies. And I keep a separate requirements.txt
for it. Yep, makes the root of the project a bit messier but works. This is why I made dephell a long time ago, to handle all this zoo :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's merge-ready, any other comments can be addressed separately.
Also:
|
@webknjaz thanks for the info! Perhaps, "extra" should be filtered/stripped out in format_requirement somehow. Ideas? |
Possible solutions I see for removing
I think, the second option should be fine 🤔 |
Approach №2 is fine by me 👍🏻 |
I've implemented and integrated |
Huh. I've put a breakpoint there and it IS covered, for sure. I have a deja vu. Coverage.py seems to be quite flaky about branch coverage for if conditions. I definitely faced something like this in deal but I don't remember the exact solution. Probably, I've just rewritten the condition back then. |
I decided to hack it around here too 🙃 |
@atugushev @orsinium @webknjaz Is there anything blocking progress on this PR? I do find it very useful and a blocker for the new release. |
Nothing from my side. There is a new logic (3b63aa9) that needs a review from maintainers. |
Hello @ssbarnea! Thanks for pinging. I'm going to look into this shortly. |
I should be the owe thanking you. That is indeed a very important feature, one that prevented further adoption from more people. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orsinium thanks for fixing the bug with extras
🙏🏻 The PR's all good!
|
Changelog-friendly one-liner: Add
--extra
to specifyextras_require
dependencies.Supports setup.py and anything PEP-517 compatible. Tested for setup.py, setup.cfg, poetry, and flit.
Close #625.
Contributor checklist