Feat/py3.10
Hi Ankur.
This patch is not working with Python-3.10.0-rc1 yet:
+ PYTHONPATH='/builddir/build/BUILDROOT/python-stdlib-list-0.8.0-4.fc36.noarch}/usr/lib/python3.10/site-packages'
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=zEC12 -mtune=z13 -fasynchronous-unwind-tables -fstack-clash-protection'
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 '
+ PATH=/builddir/build/BUILDROOT/python-stdlib-list-0.8.0-4.fc36.noarch/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
+ PYTHONPATH='/builddir/build/BUILDROOT/python-stdlib-list-0.8.0-4.fc36.noarch}/usr/lib/python3.10/site-packages'
+ PYTHONDONTWRITEBYTECODE=1
+ /usr/bin/pytest
============================= test session starts ==============================
platform linux -- Python 3.10.0rc1, pytest-6.2.4, py-1.10.0, pluggy-1.0.0
rootdir: /builddir/build/BUILD/python-stdlib-list-0.8.0
collected 8 items
tests/test_basic.py FFFFF [ 62%]
tests/test_platform.py FFF [100%]
=================================== FAILURES ===================================
___________________ TestCurrentVersion.test_builtin_modules ____________________
self = <tests.test_basic.TestCurrentVersion testMethod=test_builtin_modules>
def setUp(self):
> self.list = stdlib_list.stdlib_list(sys.version[:3])
tests/test_basic.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
____________________ TestCurrentVersion.test_list_is_sorted ____________________
self = <tests.test_basic.TestCurrentVersion testMethod=test_list_is_sorted>
def setUp(self):
> self.list = stdlib_list.stdlib_list(sys.version[:3])
tests/test_basic.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
________________________ TestCurrentVersion.test_string ________________________
self = <tests.test_basic.TestCurrentVersion testMethod=test_string>
def setUp(self):
> self.list = stdlib_list.stdlib_list(sys.version[:3])
tests/test_basic.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
____________________ TestSysModules.test_preloaded_modules _____________________
self = <tests.test_basic.TestSysModules testMethod=test_preloaded_modules>
def setUp(self):
> super(TestSysModules, self).setUp()
tests/test_basic.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_basic.py:11: in setUp
self.list = stdlib_list.stdlib_list(sys.version[:3])
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
____________________ TestSysModules.test_preloaded_packages ____________________
self = <tests.test_basic.TestSysModules testMethod=test_preloaded_packages>
def setUp(self):
> super(TestSysModules, self).setUp()
tests/test_basic.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_basic.py:11: in setUp
self.list = stdlib_list.stdlib_list(sys.version[:3])
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
___________________________ TestPureLibDir.test_dir ____________________________
self = <tests.test_platform.TestPureLibDir testMethod=test_dir>
def setUp(self):
self.dir = get_python_lib(standard_lib=True, plat_specific=False)
> super(TestPureLibDir, self).setUp()
tests/test_platform.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_platform.py:41: in setUp
self.list = stdlib_list.stdlib_list(sys.version[:3])
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
___________________________ TestPlatLibDir.test_dir ____________________________
self = <tests.test_platform.TestPlatLibDir testMethod=test_dir>
def setUp(self):
self.dir = get_python_lib(standard_lib=True, plat_specific=True)
> super(TestPlatLibDir, self).setUp()
tests/test_platform.py:129:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_platform.py:41: in setUp
self.list = stdlib_list.stdlib_list(sys.version[:3])
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
____________________________ TestSharedDir.test_dir ____________________________
self = <tests.test_platform.TestSharedDir testMethod=test_dir>
def setUp(self):
self.dir = get_config_var("DESTSHARED")
> super(TestSharedDir, self).setUp()
tests/test_platform.py:135:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_platform.py:41: in setUp
self.list = stdlib_list.stdlib_list(sys.version[:3])
stdlib_list/base.py:44: in stdlib_list
version = get_canonical_version(version) if version is not None else '.'.join(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = '3.1'
def get_canonical_version(version):
if version in long_versions:
version = ".".join(version.split(".")[:2])
elif version not in short_versions:
> raise ValueError("No such version: {}".format(version))
E ValueError: No such version: 3.1
stdlib_list/base.py:25: ValueError
=============================== warnings summary ===============================
tests/test_platform.py:6
/builddir/build/BUILD/python-stdlib-list-0.8.0/tests/test_platform.py:6: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.sysconfig import get_python_lib
tests/test_platform.py:6
/builddir/build/BUILD/python-stdlib-list-0.8.0/tests/test_platform.py:6: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
from distutils.sysconfig import get_python_lib
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_basic.py::TestCurrentVersion::test_builtin_modules - ValueE...
FAILED tests/test_basic.py::TestCurrentVersion::test_list_is_sorted - ValueEr...
FAILED tests/test_basic.py::TestCurrentVersion::test_string - ValueError: No ...
FAILED tests/test_basic.py::TestSysModules::test_preloaded_modules - ValueErr...
FAILED tests/test_basic.py::TestSysModules::test_preloaded_packages - ValueEr...
FAILED tests/test_platform.py::TestPureLibDir::test_dir - ValueError: No such...
FAILED tests/test_platform.py::TestPlatLibDir::test_dir - ValueError: No such...
FAILED tests/test_platform.py::TestSharedDir::test_dir - ValueError: No such ...
======================== 8 failed, 2 warnings in 0.10s =========================
Hrm, I'll have to take a look to see what this is caused by. It's finding 3.1 instead of 3.10 here, for example. Could be because of this maybe:
sys.version[:3]
which will stop at 3.1 instead of going to 3.10. The docs say one shoudn't use sys.version at all and instead use sys.version_info or platform methods to get the correct value.
https://docs.python.org/3/library/sys.html#sys.version
So maybe something like:
version = ".".join(platform.python_version_tuple()[:2])
is a better way to get major.minor information everywhere.
@sagitter try now?
(The travis test failures are because of other reasons that look unrelated to this particular change)
@sagitter try now?
(The travis test failures are because of other reasons that look unrelated to this particular change)
============================= test session starts ==============================
platform linux -- Python 3.10.0rc2, pytest-6.2.4, py-1.10.0, pluggy-1.0.0
rootdir: /builddir/build/BUILD/python-stdlib-list-0.8.0
collected 8 items
tests/test_basic.py F..FF [ 62%]
tests/test_platform.py FFF [100%]
=================================== FAILURES ===================================
___________________ TestCurrentVersion.test_builtin_modules ____________________
self = <tests.test_basic.TestCurrentVersion testMethod=test_builtin_modules>
def test_builtin_modules(self):
"""Check all top level stdlib packages are recognised."""
unknown_builtins = set()
for module_name in sys.builtin_module_names:
if module_name not in self.list:
unknown_builtins.add(module_name)
> self.assertFalse(sorted(unknown_builtins))
E AssertionError: ['_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_tracemalloc', '_warnings', '_weakref', 'xxsubtype'] is not false
tests/test_basic.py:28: AssertionError
____________________ TestSysModules.test_preloaded_modules _____________________
self = <tests.test_basic.TestSysModules testMethod=test_preloaded_modules>
def test_preloaded_modules(self):
"""Check all stdlib modules are recognised."""
not_stdlib = set()
for module_name in sys.modules:
pkg, _, module = module_name.partition(".")
# https://github.com/jackmaney/python-stdlib-list/issues/29
if pkg.startswith("_sysconfigdata_"):
continue
if pkg in self.ignore_list:
continue
# Avoid duplicating errors covered by other tests
if module_name in sys.builtin_module_names:
continue
if PY2:
# Python 2.7 creates sub-modules for imports
if pkg in self.list and module in self.list:
continue
# Python 2.7 deprecation solution for old names
if pkg == "email":
mod = sys.modules[module_name]
if mod.__class__.__name__ == "LazyImporter":
continue
if module_name not in self.list:
not_stdlib.add(module_name)
> self.assertFalse(sorted(not_stdlib))
E AssertionError: ['_bisect', '_bz2', '_collections_abc', '_compression', '_csv', '_datetime', '_decimal', '_elementtree', '_frozen_importlib', '_frozen_importlib_external', '_heapq', '_json', '_lzma', '_opcode', '_posixsubprocess', '_pytest', '_pytest._argcomplete', '_pytest._code', '_pytest._code.code', '_pytest._code.source', '_pytest._io', '_pytest._io.saferepr', '_pytest._io.terminalwriter', '_pytest._io.wcwidth', '_pytest._version', '_pytest.assertion', '_pytest.assertion.rewrite', '_pytest.assertion.truncate', '_pytest.assertion.util', '_pytest.cacheprovider', '_pytest.capture', '_pytest.compat', '_pytest.config', '_pytest.config.argparsing', '_pytest.config.exceptions', '_pytest.config.findpaths', '_pytest.debugging', '_pytest.deprecated', '_pytest.doctest', '_pytest.faulthandler', '_pytest.fixtures', '_pytest.freeze_support', '_pytest.helpconfig', '_pytest.hookspec', '_pytest.junitxml', '_pytest.logging', '_pytest.main', '_pytest.mark', '_pytest.mark.expression', '_pytest.mark.structures', '_pytest.monkeypatch', '_pytest.nodes', '_pytest.nose', '_pytest.outcomes', '_pytest.pastebin', '_pytest.pathlib', '_pytest.pytester', '_pytest.python', '_pytest.python_api', '_pytest.recwarn', '_pytest.reports', '_pytest.runner', '_pytest.setuponly', '_pytest.setupplan', '_pytest.skipping', '_pytest.stepwise', '_pytest.store', '_pytest.terminal', '_pytest.threadexception', '_pytest.timing', '_pytest.tmpdir', '_pytest.unittest', '_pytest.unraisableexception', '_pytest.warning_types', '_pytest.warnings', '_random', '_sha512', '_sitebuiltins', '_socket', '_struct', '_uuid', '_weakrefset', 'attr', 'attr._cmp', 'attr._compat', 'attr._config', 'attr._funcs', 'attr._make', 'attr._next_gen', 'attr._version_info', 'attr.converters', 'attr.exceptions', 'attr.filters', 'attr.setters', 'attr.validators', 'email._encoded_words', 'email._parseaddr', 'email._policybase', 'email.base64mime', 'email.quoprimime', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'genericpath', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.metadata._adapters', 'importlib.metadata._collections', 'importlib.metadata._functools', 'importlib.metadata._itertools', 'importlib.metadata._meta', 'importlib.metadata._text', 'iniconfig', 'json.decoder', 'json.encoder', 'json.scanner', 'ntpath', 'opcode', 'pluggy', 'pluggy._callers', 'pluggy._hooks', 'pluggy._manager', 'pluggy._result', 'pluggy._tracing', 'pluggy._version', 'posixpath', 'py', 'py._builtin', 'py._code', 'py._code.code', 'py._error', 'py._path', 'py._path.common', 'py._path.local', 'py._vendored_packages', 'py._vendored_packages.apipkg', 'py._vendored_packages.apipkg.version', 'py._version', 'py.apipkg', 'py.builtin', 'py.code', 'py.error', 'py.iniconfig', 'py.io', 'py.log', 'py.path', 'py.process', 'py.test', 'py.xml', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'pytest', 'pytest.collect', 'sphinxcontrib', 'sre_compile', 'sre_constants', 'sre_parse', 'typing.io', 'typing.re', 'unittest.case', 'unittest.loader', 'unittest.main', 'unittest.result', 'unittest.runner', 'unittest.signals', 'unittest.suite', 'unittest.util', 'xml.etree', 'xml.etree.ElementPath'] is not false
tests/test_basic.py:95: AssertionError
That seems to be related to the list which has already changed since I generated and added it here. I guess that changes as more modules list py3.10 as a supported version and needs to be regularly updated.
Any progress on supporting 3.10 ? It's currently breaking one of our our packages that depends on this package, and seems to be the last roadblock for us upgrading to 3.10.
I would love to help, but honestly I have no idea where to start, and seems like most of the work is done? If there is anything I can do to contribute, please tell!
I've updated the lists for 3.7, 3.8, 3.9 again but the tests still fail, so at this point I'm not quite sure of what the error is :(
#67.