Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

setuptools - install_requires based on python version

I have a module that works both on python 2 and python 3. In Python<3.2 I would like to install a specific package as a dependency. For Python>=3.2.

Something like:

 install_requires=[
    "threadpool >= 1.2.7 if python_version < 3.2.0",
 ],

How can one make that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use environment markers:

install_requires=[
    'threadpool >= 1.2.7; python_version < "3.2.0"',
]

Setuptools specific usage is detailed in their documentation. The syntax shown above requires setuptools v36.2+ (change log).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...