Only depend on ipaddress in python2#509
Only depend on ipaddress in python2#509yliaog merged 2 commits intokubernetes-client:masterfrom asottile:only_ipaddress_python_2
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.
what is the purpose of "for_specifier.append(requirement)" but for_specifier is not kept anywhere?
There was a problem hiding this comment.
for_specifier is the list inside EXTRAS[f":{spec}"] -- I'd use collections.defaultdict(list) here but setuptools requires specific types here.
|
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
ipaddressmodulein python2.7. In setuptools, the most compatible way to accomplish this is
through the
extras_requirefield (as suggested in the wheel docs).