-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix issue #1433: parse requirements in markers #1472
Conversation
Example of requirements for my Trollius project:
Output with Python 2.7:
Trollius: https://bitbucket.org/haypo/trollius/ |
The original markers specification explicitly did not support < and > against strings. Does it now? |
in PEP426 it says:
I'm inclined to think we need "Requirement Files 2.0" for this. json format. |
The new commit should fix tests on Travis. I'm not sure that "; " is the best separator for markers. Do you have a better proposition? The semicolon is not a random choice, it comes from setup.cfg. |
@qwcode: Sorry, but I don't understand what do you mean by:
|
@Haypo see the thread I started last night on pypa-dev about this |
I just rebased the patch on lastest develop branch. |
+1. Unlike Requirements 2.0 this is simple and it exists. |
With my latest change, the syntax is now: mock >= 0.9 # comment {'name': 'mock >= 0.9'} # comment works here too {'name': 'mock3', 'markers': 'python_version >= "3"'} # markers! # {...} syntax opens the door for more options like "install-options" and "global-options" as well |
👍 This would be very handy to be able to make requirements conditional. I've often wished for this when porting packages to Python 3. |
I would prefer to leave out anything to do with |
This feature should be merged. I agree with just allowing the ; for now, until we have time to overengineer a requirements 2.0. |
Ok, here is a new proposal of syntax for markers in requirements. Use the semicolon as separator for the common code, BUT requires semicolon+space separator if the line starts with an URL. Valid syntax:
Invalid syntax,
These examples with URL are ugly but it was just to show you the worst case, when the URL also contains semicolons. A more common case looks like this:
|
👍 |
I've done something like this, except the rule was "the last semicolon On Thu, May 22, 2014, at 11:59 AM, Marc Abramowitz wrote: 👍 — Reply to this email directly or [1]view it on GitHub. References |
Oh, it makes me realize that it would be nice to add a test checking that a marker can contain a semicolon. Travis was unhappy. There was a obvious bug in the method checking if markers match or not. It's now fixed but I also added unit tests on this method. The whole change now has a nice coverage in term of unit tests, and I'm happy with the new syntax. So it's ready for a final review ;-) |
" Error — The Travis CI build could not complete due to an error · Details " It looks like Python 3 tests are too slow for Travis. I played the tests manually on my PC and py33 tests pass: "435 passed, 8 skipped in 803.33 seconds". |
Hey, did I forgot something to get my patch merged? What should I do? |
+1 for this feature. |
I agree also for this feature. |
+1, that would be awesome and would help limiting the code in, let's say... setup.py by example |
@Haypo looks like the patch needs rebasing. Also, it could do with documentation. @mihamel how would it affect |
@pfmoore it doesn't, i was just pointing the fact that people are using setup.py for doing that kind of things, since it's python code. but sometime, you end up having a huge file which is super difficult to maintain. Being able to do it in a simpler way in a requirement.txt would be fantastic. Take this one by example: https://github.com/odoo/odoo/blob/6.0/setup.py (it's way more better in their latest version although) |
setup.py and requirements.txt are for different things. |
@dstufft yeah but people are using both. for different reason, that would be another reason to use requirement.txt for me... :) |
* InstallRequirement supports PEP 426 markers * RequirementSet.add_requirement() ignores an InstallRequirement if markers don't match.
It is possible to use markers in setup.py by using a colon separator in the extra name. Wheel's own setup.py demonstrates. The empty extra name ':python_version=="2.6"' is how you do markers on dependencies that would otherwise go into install_requires = [].
|
I'd rather we get a properly documented and supported solution. @dholth I've no idea if this is supported (I've no doubt it works). Is it documented anywhere? In retrospect, and given the confusion the |
Done.
I added something to the documentation, is it enough? I ran "tox -e pep8,docs,py27,py33" with success. Let's see if Travis agrees with me ;-) |
@@ -29,6 +29,12 @@ and like arguments to :ref:`pip install`, the following forms are supported:: | |||
[-e] <local project path> | |||
[-e] <vcs project url> | |||
|
|||
Since the version 6.0, pip also supports markers using the "; " separator. |
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 guess "version 6.0" means "setuptools 6.0", right? :)
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 guess "version 6.0" means "setuptools 6.0", right? :)
I searched for the version of pip and I found version = "6.0.dev1" in pip/init.py. It is not the version of pip?
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.
Correct - we removed the initial "1." so version 6.X is what was previously being referred to as 1.6.X. By the way, a minor nit, "Since version 6.0" would be better grammatically.
Please, merge it. Thank you |
Example, OrderedDict is in Python 2.7 and Python 3.x but not in Python 2.6 |
It's now possible to specify requirements markers in requirements. Examples:: futures; python_version < '2.7' mock; python_version < '3.3' nose ordereddict; python_version < '2.7' unittest2; python_version < '2.7' The separator is "; ". For convinience, ";" alone is also supported, but no in URLs. The ";" character is a legit and common character in an URL. Example of valid URL without markers:: http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz Example of URL with markers:: http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz; python_version < '3.3'
Travis agrees with me. So what's the next step? |
Thanks |
markers don't match.
fixes #1433