How to mark Python package only as Python 2?

I have a Python package that works only in Python 2. In its setup.py there are the following classifiers:

setup( # ... classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2 :: Only', ]) 

However, if I create virtualenv with Python 3, pip successfully installs this package.

How to prevent package installation? Should my setup.py output an error based on sys.version_info ? Can I stop downloading a package even when downloading?

+6
source share
1 answer

In setup.py add the following:

 import sys if sys.version_info[0] != 2: sys.stderr.write("This package only supports Python 2.\n") sys.exit(1) 
+8
source

Source: https://habr.com/ru/post/976489/


All Articles