Search code examples
pythonpippypi

Specifying the minimum python version required for a module in pip


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.


Solution

  • 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'],
    )