Skip to main content

List of packages in the stdlib

Project description

stdlibs

Simple list of top-level packages in Python's stdlib

Note: If you only need the live module names on 3.10+, just use sys.stdlib_module_names. This is not exactly a backport, but a static list of those for most useful Python versions.

If someone wants to add alternate runtimes, PRs welcome.

Usage

Currently stdlibs.module_names is stdlibs.py3.module_names -- the top-level names that are valid in some version of py3 on some platform. This is a superset of top-level names you may have, and a superset of those in sys.stdlib_module_names.

>>> from stdlibs import module_names
>>> print("os" in module_names)
True
>>> print("peg_parser" in module_names)  # 3.9+
True

If you need a specific version, those are available as other modules:

>>> from stdlibs.py36 import module_names as module_names_py36
>>> print("os" in module_names_py36)
True
>>> print("peg_parser" in module_names_py36)
False

If you intend to process more than one version, you may find the string api easier:

>>> from stdlibs import stdlib_module_names, KNOWN_VERSIONS
>>> [v for v in KNOWN_VERSIONS if "dataclasses" in stdlib_module_names(v)]
['3.7', '3.8', '3.9', '3.10']
>>>
>>> sorted(stdlib_module_names("3.7") - stdlib_module_names("3.6"))
['_abc', '_contextvars', '_py_abc', '_queue', '_uuid', '_xxtestfuzz', 'contextvars', 'dataclasses']
>>>
>>> from moreorless.click import unified_diff
>>> prev = None
>>> buf = []
>>> for v in KNOWN_VERSIONS:
...     cur = ''.join([f"{name}\n" for name in sorted(stdlib_module_names(v))])
...     if prev:
...         buf.append(unified_diff(prev, cur, f"new-in-{v}"))
...     prev = cur
>>> print(''.join(''.join(buf).splitlines(True)[:10]), end='')
--- a/new-in-2.4
+++ b/new-in-2.4
@@ -19,7 +19,6 @@
 DocXMLRPCServer
 ERRNO
 EasyDialogs
-FCNTL
 FILE
 FL
 FileDialog

Install

You can install it from PyPI:

$ pip install stdlibs

Regenerating

If you need to regenerate the list, install libcst, add the url to stdlibs/fetch.py, and run that file. Make sure any new versions are added to KNOWN_VERSIONS.

License

stdlibs is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stdlibs-2021.4.1.tar.gz (15.7 kB view hashes)

Uploaded Source

Built Distribution

stdlibs-2021.4.1-py3-none-any.whl (44.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page