Closed delirious-lettuce closed 7 years ago
I didn't add it to requirements.txt because I couldn't find a way to tell pip to install ordereddict
only for Python 2.6. I don't want users to install ordereddict
if they are using Python 2.7-3.6. Do you happen to know how to do it?
@eliangcs ,
My original thought was that it was kind of "installed" for Python 2.7-3.6 users anyways (in the form ordereddict.py
), so why not just pip install it. But you make a good point, having it installed only when needed (Python 2.6 users) seems like the better option.
I came across a few links while looking for solutions (I was googling "conditional dependencies python"):
EDIT:
I haven't tested this yet but maybe something like this in setup.py
?
def read_requirements(filename):
try:
with open(filename) as f:
result = f.read().splitlines()
except IOError:
raise IOError(os.getcwd())
else:
if sys.version_info < (2, 7):
result.append('ordereddict>=1.1')
return result
@delirious-lettuce I think that works 👍. Feel free to create a pull request if you want to. Thanks a lot!
Ok, sure. I'll be at my computer in maybe 45-60 minutes. I'll do a couple tests and then submit that PR.
I was looking at Raymond Hettinger's script on ActiveState (in this repo as
ordereddict.py
) and noticed in the comments that it was available on PyPI. It seems to be an updated version of the original script.I guess I'm just wondering if it wouldn't be easier to just
pip install ordereddict
(by adding it torequirements.txt
)?