Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2b7ee7

Browse files
committed
Only depend on ipaddress in python2
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
1 parent 74ade9c commit e2b7ee7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setuptools>=21.0.0 # PSF/ZPL
55
urllib3>=1.19.1,!=1.21 # MIT
66
pyyaml>=3.12 # MIT
77
google-auth>=1.0.1 # Apache-2.0
8-
ipaddress>=1.0.17 # PSF
8+
ipaddress>=1.0.17;python_version=="2.7" # PSF
99
websocket-client>=0.32.0,!=0.40.0,!=0.41.*,!=0.42.* # LGPLv2+
1010
requests # Apache-2.0
1111
requests-oauthlib # ISC

setup.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from setuptools import find_packages, setup
15+
from setuptools import setup
1616

1717
# Do not edit these constants. They will be updated automatically
1818
# by scripts/update-client.sh.
@@ -27,8 +27,18 @@
2727
# prerequisite: setuptools
2828
# http://pypi.python.org/pypi/setuptools
2929

30+
EXTRAS = {}
31+
REQUIRES = []
3032
with open('requirements.txt') as f:
31-
REQUIRES = f.readlines()
33+
for line in f:
34+
line, _, _ = line.partition('#')
35+
line = line.strip()
36+
if ';' in line:
37+
requirement, _, specifier = line.partition(';')
38+
for_specifier = EXTRAS.setdefault(':{}'.format(specifier), [])
39+
for_specifier.append(requirement)
40+
else:
41+
REQUIRES.append(line)
3242

3343
with open('test-requirements.txt') as f:
3444
TESTS_REQUIRES = f.readlines()
@@ -44,6 +54,7 @@
4454
keywords=["Swagger", "OpenAPI", "Kubernetes"],
4555
install_requires=REQUIRES,
4656
tests_require=TESTS_REQUIRES,
57+
extras_require=EXTRAS,
4758
packages=['kubernetes', 'kubernetes.client', 'kubernetes.config',
4859
'kubernetes.watch', 'kubernetes.client.apis',
4960
'kubernetes.stream', 'kubernetes.client.models'],

0 commit comments

Comments
 (0)