I was wondering if there is a generic way to find out if your version of python
is supported by a specific module?
For example, let us say that I have python 3.11
installed on my computer and I want to install the modules biopython
and lru-dict
. Going to their respective pypi
entries biopython
shows this in their Project description
:
Python Requirements
We currently recommend using Python 3.10 from http://www.python.org
Biopython is currently supported and tested on the following Python implementations:
Python 3.7, 3.8, 3.9, 3.10 and 3.11 – see http://www.python.org
PyPy3.7 v7.3.5 – or later, see http://www.pypy.org
However, if we check the lru-dict
entry, their Project description
does not mention Python requirements. I did eventually find out that python 3.11
is not supported by finding a issue
on their github
page.
Is there a simpler way of finding this information out?
If you go to the https://pypi.org/pypi/PACKAGE_NAME/json
address, you will receive complete information about Python PACKAGE_NAME in JSON format. For example, to view information about lru-dict
open https://pypi.org/pypi/lru-dict/json link, Then you can extract the necessary information from it.
To see the Python version that PACKAGE_NAME is supported, I wrote this code, I hope it suits you.
import json
import pprint
from urllib import request
package_name = 'lru-dict'
with request.urlopen(f'https://pypi.org/pypi/{package_name}/json') as response:
data = json.loads(response.read())
pprint.pprint(data['info']['classifiers'])
Output:
['Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Operating System :: POSIX',
'Programming Language :: C',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development :: Libraries :: Python Modules']
In addition to viewing the supported Python version, you can also get other information such as the Python version required for each release, package description, author's name, etc.
No, there is no generic way.
If the library has tests you can run them and check, but it might give you false positives as well as false negatives :shrug:
The lru-dict has this fragment in their setup.py, which is one of the places you can check for supported versions:
'Programming Language :: C',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
So as you can see, I don't think they knew about the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With