Python packaging: How to prevent user from installing my package with wrong python version

Viewed 92

Environment:

  • pip version: 21.2.4
  • twine version: 3.4.1
  • Python version: 3.9.7

I have made a python package developed in the above environment and distributing with pypi (pip install). The problem is that while the package requires python 3.8 or newer due to typing.Literal for type hinting, the package somehow can be installed with python 3.7. As a result, user gets an error when importing but not on installation. I want to fix this behavior but setting python_requires=">=3.8.0" in setup.py does not change anything.

How can I let user know that they don't have compatible python version when installing?

I have observed that happened by installing my package on Google COLAB which has python3.7 and pip version 21.1.3.

0 Answers
Related