This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add frozen modules to sys.stdlib_module_names
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nascheme, vstinner
Priority: normal Keywords: patch

Created on 2021-03-09 10:35 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24798 merged vstinner, 2021-03-09 10:39
Messages (6)
msg388345 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-09 10:35
The sys.stdlib_module_names documentation says: "All module kinds are listed: pure Python, built-in, frozen and extension modules. Test modules are excluded."
https://docs.python.org/dev/library/sys.html#sys.stdlib_module_names

But I just noticed that frozen modules are not listed!

Attached PR fix this issue.
msg388374 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2021-03-09 19:13
Not sure the proper place to discuss this but I wonder if putting this stdlib module names list in the executable is the best idea.  The list of available stdlib modules could change after compiling Python.  I understand you don't want to dynamically crawl the library path the build the list.  That's too slow.  However, is there a really strong reason to embed it in the Python executable?

Did you consider generating a .py module, containing the list.  E.g. "_stdlib_modules.py" inside the lib folder.  Then, you can have site.py or some similar startup logic import that module and assign it to sys.stdlib_module_names.
msg388378 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-09 19:54
Neil Schemenauer: "Not sure the proper place to discuss this but I wonder if putting this stdlib module names list in the executable is the best idea."

For the rationale behind sys.stdlib_module_names, please see the bpo-42955 where alternative were discussed.
msg388379 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-09 19:58
> The list of available stdlib modules could change after compiling Python.

It's documented:
"[ sys.stdlib_module_names] is the same on all platforms. Modules which are not available on some platforms and modules disabled at Python build are also listed."
https://docs.python.org/dev/library/sys.html#sys.stdlib_module_names
msg388418 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-10 10:14
New changeset 307745aa42196ad3fd97fee4a1ae6496bb895596 by Victor Stinner in branch 'master':
bpo-43445: Add frozen modules to sys.stdlib_module_names (GH-24798)
https://github.com/python/cpython/commit/307745aa42196ad3fd97fee4a1ae6496bb895596
msg388420 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-10 10:17
Neal: you may also read the thread on python-dev:
https://mail.python.org/archives/list/python-dev@python.org/thread/BTX7SH2CR66QCLER2EXAK2GOUAH2U4CL/
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87611
2021-03-10 10:17:25vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg388420

stage: patch review -> resolved
2021-03-10 10:14:36vstinnersetmessages: + msg388418
2021-03-09 19:58:26vstinnersetmessages: + msg388379
2021-03-09 19:54:31vstinnersetmessages: + msg388378
2021-03-09 19:13:03naschemesetnosy: + nascheme
messages: + msg388374
2021-03-09 10:39:27vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request23566
2021-03-09 10:35:11vstinnercreate