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
Use environment marker for conditional requirements #1029
Conversation
081639e
to
17844cc
Compare
@lmr, Thanks for pointing out this. Now fixed. |
Hello @Hao-Liu we got to the same problem at roughly the same time. We have this in our TODO for the current sprint. Anyway there is yet one thing to do, we need to reorder the I haven't looked at it yet, could you please test it and adjust the makefile so it works as expected? (I think reorder should do, but I'm not sure if |
Hi @ldoktor, You're right about this. But I don't think simply reorder the installation is very proper even if it could solve this issue. What if python2.7 need to upper-limit a dependence but python2.6 not? (I know it's just a theoretical situation) I googled and found that there seems exists a way to merge python-version-related dependencies into one single requirements.txt via Environment Markers. Thus we can merge requirements.txt and requirements-python26.txt into:
|
Nice, I didn't know about this. Does it work in python 2.6? |
Hmm in examples they have python 2.4, so it probably does. Would you, @Hao-Liu, please take care of all requirements files? |
Managing different requirements files for different python version requires much more efforts when the requirements became too complex. This issue emerged when a required package `stevedore` decide not supporting Python 2.6 since version `1.11.0`. ``` >>> import stevedore Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/stevedore/__init__.py", line 23, in <module> LOG.addHandler(logging.NullHandler()) AttributeError: 'module' object has no attribute 'NullHandler ``` Pip provides a feature named [Environment Markers](https://www.python.org/dev/peps/pep-0496/) for requirements file to include specific packages conditionally which could properly solve this issue. This fix: 1. Use environment markers and merge python version specific requirements files; 2. Remove python version specific requirements files references in `Makefile` and Travis configuration; 3. Use `pip install -r requirements.txt` to replace per-line package installation; 4. Restrain package `stevedore` on Python 2.6 to `1.10.0`. Signed-off-by: Hao Liu <hliu@redhat.com>
17844cc
to
03c04b9
Compare
Hi @ldoktor, I've merged python26 requirements files into the other one and changed .travis.yaml and Makefile accordingly. Could you plz help check this PR. Thanks. |
@Hao-Liu this is really cool! Thanks a lot for coming up with this very useful, yet unknown to many, feature of requirements.txt. |
Well, I guess it was too soon... I tried it on F21 and not even |
When I look into |
@ldoktor , I'm extremely sorry that this patch break fedora tests. But I tested this on RHEL6 & 7 actually. Since my |
I see, well |
Since PR avocado-framework/avocado#1029 is trying to merge python version specific requirements files. We don't need to specify another requirements when running on python 2.6. Change-Id: I9cf885df10b036a59f3d2587f212826e4219fd94 Signed-off-by: Hao Liu <hliu@redhat.com>
Managing different requirements files for different python version
requires much more efforts when the requirements became too complex.
This issue emerged when a required package
stevedore
decide notsupporting Python 2.6 since version
1.11.0
.Pip provides a feature named Environment Markers
for requirements file to include specific packages conditionally which could
properly solve this issue.
This fix:
requirements files;
Makefile
and Travis configuration;pip install -r requirements.txt
to replace per-line packageinstallation;
stevedore
on Python 2.6 to1.10.0
.Signed-off-by: Hao Liu hliu@redhat.com