-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
Pip-compile ignores extras_require when parsing setup.py #625
Comments
Does it make a difference if you specify the conditional dependency in the Here's an example: setup(
name='mypackage',
install_requires=[
'python-cjson ; platform_python_implementation=="CPython"',
...
]) |
@suutari Turns out it doesn't make any difference. Setuptools Distribution class separates out any installation requirements with environment markers, and then merges them into The Distribution object provides an |
Hi @davidjlloyd, thanks for the details. I did a small test and can point out this: you will get the proper result if you use a requirements.in file like this:
Having pip parse the requirements.in file, and then process the setup.py, works fine. I would generally advise to use requirements files, its the battle-tested flow. Hindsight being 20/20, I might have voted against parsing the setup.py directly in retrospective. Contributions are welcomed of course 😄 |
We just ran head first into this one. We are not a package but rather have a requirements.in that needs to be resolved into frozen packages. In this case one of our dependencies have a extras_require section. This issue means that one dependency is going to be missing completely in the resulting requirements.txt and fail the entire install as all packages needs to be frozen in --require-hashes mode. We cant see any workaround other then depending on the package specified in extras_require ourselvs. This is very inconvenient and makes upgrades a lot less flexible. We would very much like to see a fix for this as the whole purpose of pip-compile seams to be to solve this kind problem. I might try to get a PR in for it if I get some time on my hands but in the meantime please be advised that this issue has a real and serious impact without workaround. |
@vphilippon thank you very much for your comments and suggested approach (and for maintaining such a good package)! I have a little doubt left though: since, as you said, the support to Is there an alternative workaround for this? |
Have the same problem. In my case it's https://github.com/stefanfoulis/django-phonenumber-field it used install_requires and extras_require in setup:
install_requires is considered but extras_require not:
|
Hello @jedie! What about this: $ echo "django-phonenumber-field[phonenumbers]" | pip-compile - -qo-
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=- -
#
babel==2.7.0 # via django-phonenumber-field
django-phonenumber-field[phonenumbers]==3.0.1
django==2.2.2 # via django-phonenumber-field
phonenumbers==8.10.13 # via django-phonenumber-field
pytz==2019.1 # via babel, django
sqlparse==0.3.0 # via django |
Yes. But in my case: django-phonenumber-field is a dependency of a other package. So i didn't have this in my |
What about something like:
|
That's author's decision to force developers to install extra requirements manually. See changelog and PR stefanfoulis/django-phonenumber-field#236. So in your case you have to put |
Can someone clarify the expected behavior? I see above that |
Related question: I have a library project where the library's own |
Hi @barrywhart. I don't see how your question relates at all to "extras_require", which is key to this topic. It sounds like you have another issue. |
I've filed an issue #908 which describes how to resolve a bunch of problems with "extras_require" in setup.py. Please comment if someone is interested in. |
I'm confused how This results in the package being added to the requirements file itself, which is not what happens if you run |
I think this is a workflow used by developers of apps that require the app (site, etc) to be itself an installed Python project, for entry points or other integrations (e.g. Pyramid sites need this): developers want to document one command to install project dependencies and the project itself (I guess), so having I am not sure about having |
Sounds reasonable. But just to note, the “two install commands” can be used in one line e.g.
which works fine and does not require to be I also think, the above line in the documentation, instead putting |
Yep. I have a package that should be able to be 'frozen' with hashes, for both its regular dependencies, and |
we should update this document once jazzband/pip-tools#625 is fixed and/or jazzband/pip-tools#908 is merged Signed-off-by: Kefu Chai <[email protected]>
we should update this document once jazzband/pip-tools#625 is fixed and/or jazzband/pip-tools#908 is merged Signed-off-by: Kefu Chai <[email protected]>
we should update this document once jazzband/pip-tools#625 is fixed and/or jazzband/pip-tools#908 is merged Signed-off-by: Kefu Chai <[email protected]>
we should update this document once jazzband/pip-tools#625 is fixed and/or jazzband/pip-tools#908 is merged Signed-off-by: Kefu Chai <[email protected]>
we should update this document once jazzband/pip-tools#625 is fixed and/or jazzband/pip-tools#908 is merged Signed-off-by: Kefu Chai <[email protected]>
I think something like:
|
|
The documentation for python-wheel describes ways to define conditional dependencies: http://wheel.readthedocs.io/en/stable/index.html?highlight=extras_require#defining-conditional-dependencies
The most well-supported of these is to use the parameter
extras_require
to specify dependencies for specific environment markers. For example:This allows us to install optimisations for CPython which are not available on other implementations of Python. This works correctly for pip/setuptools (e.g.
pip install .
orpython setup.py install
) but is ignored by pip-compile.Environment Versions
Steps to replicate
extras_require
insetup.py
.Expected result
The generated requirements.txt should contain the conditional packages for the environment which meets the conditions, and not otherwise.
Actual result
The conditional dependencies are not present in any requirements files.
The text was updated successfully, but these errors were encountered: