Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying the minimum python version required for a module in pip

Tags:

python

pip

pypi

Is there a way to specify the minimum python version required for installing a module in pip?

I am trying to publish a package to pypi.

python setup.py sdist upload -r pypi

Is the command I am using. However in setup.py there is no way to specify that the minimum python version (in my case python 3.5) is needed to run this module.

like image 333
nesdis Avatar asked Aug 20 '17 05:08

nesdis


People also ask

How do I install a specific version of a Python package using pip?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1.

How does pip decide which version to install?

Once pip has a list of compatible distributions, it sorts them by version, chooses the most recent version, and then chooses the "best" distribution for that version. It prefers binary wheels if there are any, and if they are multiple it chooses the one most specific to the install environment.

Does Python 3.10 have pip?

The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.


1 Answers

You can specify the version of the python required for your project by using:

python_requires='>=3.5'

The above code must be specified in setup.py ,also only versions 9.0.0 and higher of pip recognize the python_requires metadata.

Additionally in setup.py to specify the dependences:

setup(
install_requires=['dependent functions,classes,etc'],
)
like image 130
Aniruddha Alek Avatar answered Sep 24 '22 00:09

Aniruddha Alek