Almost everyone uses
setuptools.setup in their
python_requires allows fine-grained control of which versions of Python are supported.
Let’s explain the use of this by example.
We assume that
setup.py is structured like
from setuptools import setup, find_packages setup(name='JoesProg', packages=find_packages(), python_requires='>=3.5', ... )
NOTE: You must install packages (including those local on your hard drive e.g. a Git repo) with
python -m pip install -e .
python setup.py develop
as the latter ignores
Both methods use
site-packages/ so that you’re always using what’s in your
~/code directory, not a frozen
Python ≥ a version
This is by far the most common use case, to avoid confusion from the few users still on Python 2. Many Python users have at least Python 3.5, and Python 3.6 has been widely available and supported for some time. Many of my programs have
Python ≤ a version
Let’s say you have one of those rare programs that doesn’t run on Python 3. You can forbid Python 3 from installing it by setting
or since we know Python 2.7 is the last Python 2 version
Inclusive Range of Python versions
Let’s say your program only works for Python 2.6 and 2.7.
Even more options found in the reference below.