Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting “python_requires” with ">=3.7" is a better way to declare Python compatibility #599

Closed
PyVCEchecker opened this issue Oct 26, 2022 · 0 comments · Fixed by #765
Assignees

Comments

@PyVCEchecker
Copy link

Hello!
I noticed such a declaration in setup.py

classes = """
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3.7
    Programming Language :: Python :: 3.8
    Programming Language :: Python :: 3.9
    Programming Language :: Python :: 3.10
   ...
   """

And using the following code checking Python compatibility locally

PY37_OR_LESS = sys.version_info < (3, 7)
PYPY_VERSION = getattr(sys, 'pypy_version_info', None)
PYPY24_ATLEAST = PYPY_VERSION and PYPY_VERSION >= (2, 4)

if PY37_OR_LESS and not PYPY24_ATLEAST:
    raise Exception(E_UNSUPPORTED_PYTHON % (PYIMP, '3.7'))

I guess you want to set python>3.7. But I think it is a better way to declare Python compatibility by using the keyword argument python_requires than argument classifiers or checking compatibility locally for some reasons:

  • Descriptions in python_requires will be reflected in the metadata
  • “pip install” can check such metadata on the fly during distribution selection , and prevent from downloading and installing the incompatible package versions.
  • If the user does not specify any version constraint, pip can automatically choose the latest compatible package version for users.

Way to improve:
modify setup() in setup.py, add python_requires keyword argument:

setup(…
     python_requires=">=3.7",
     …)

Thanks for your attention.
Best regrads,
PyVCEchecker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants