-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Only depend on ipaddress in python2 #509
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
Only depend on ipaddress in python2 #509
Conversation
The ipaddress module became a standard module in python3.3. This uses [environment markers][pep508] to only select the `ipaddress` module in python2.7. In setuptools, the most compatible way to accomplish this is through the `extras_require` field (as suggested in the [wheel][wheel] docs). [pep508]: https://www.python.org/dev/peps/pep-0508/#id23 [wheel]: https://wheel.readthedocs.io/en/latest/#defining-conditional-dependencies
could you please write a test case for it? |
I'm not sure how I would test this, it's really only a quality of the installation itself -- generally I've noted in |
if ';' in line: | ||
requirement, _, specifier = line.partition(';') | ||
for_specifier = EXTRAS.setdefault(':{}'.format(specifier), []) | ||
for_specifier.append(requirement) |
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.
what is the purpose of "for_specifier.append(requirement)" but for_specifier is not kept anywhere?
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.
for_specifier
is the list inside EXTRAS[f":{spec}"]
-- I'd use collections.defaultdict(list)
here but setuptools requires specific types here.
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 trick here is setdefault
would you be able to add a line in test-requirements.txt to test it? |
the |
i think it's possible to write a test case to check which python version is run, and if python version is 2.7, then check if ipaddress module is installed, and also where it is installed, etc. But i agree manually checking that it works is probably good enough. |
Presumably the tests would crash on an |
The ipaddress module became a standard module in python3.3.
This uses environment markers to only select the
ipaddress
modulein python2.7. In setuptools, the most compatible way to accomplish this is
through the
extras_require
field (as suggested in the wheel docs).