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
366 views
in Technique[技术] by (71.8m points)

python - Operating-system specific requirements with pip

Is it possible to have OS specific requirements in pip's requirements.txt file?

For example: I have a dependency on readline, therefore, if installing on windows (or OSX), then pyreadline is a requirement. If it's linux, then I don't want to force an install.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

You can do this with "Environment Markers" as specified in PEP-508:

Here's an example of using such a marker inside a requirements.txt:

pyreadline==2.1; platform_system == "Windows"

Similarly, in a setup.py:

setup(
    ...
    install_requires=['pyreadline; platform_system == "Windows"'],
)

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

...