Search code examples
pythonpython-3.xpackaging

How to label a Python package as version 3 only?


What do I have to do to make PyPI identify my package as working on Python 3 only?


Solution

  • You give it a trove classifier:

    Programming Language :: Python :: 3
    

    and leave out the Python 2 classifiers.

    If you want to prevent your package from being installed on Python 2 systems anyway, you can simply exit the setup.py script after detecting the version:

    import sys
    
    if sys.version_info[0] < 3:
        sys.stderr.write('Requires Python 3 or up\n')
        sys.exit(1)