mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-42955: Remove sub-packages from sys.stdlib_module_names (GH-24353)
This commit is contained in:
parent
c9b8e9c421
commit
64fc105b2d
3 changed files with 11 additions and 34 deletions
|
@ -57,29 +57,17 @@ def list_python_modules(names):
|
|||
names.add(name)
|
||||
|
||||
|
||||
def _list_sub_packages(path, names, parent=None):
|
||||
for name in os.listdir(path):
|
||||
# Packages in Lib/
|
||||
def list_packages(names):
|
||||
for name in os.listdir(STDLIB_PATH):
|
||||
if name in IGNORE:
|
||||
continue
|
||||
package_path = os.path.join(path, name)
|
||||
package_path = os.path.join(STDLIB_PATH, name)
|
||||
if not os.path.isdir(package_path):
|
||||
continue
|
||||
if not any(package_file.endswith(".py")
|
||||
for package_file in os.listdir(package_path)):
|
||||
continue
|
||||
if parent:
|
||||
qualname = f"{parent}.{name}"
|
||||
else:
|
||||
qualname = name
|
||||
if qualname in IGNORE:
|
||||
continue
|
||||
names.add(qualname)
|
||||
_list_sub_packages(package_path, names, qualname)
|
||||
|
||||
|
||||
# Packages and sub-packages
|
||||
def list_packages(names):
|
||||
_list_sub_packages(STDLIB_PATH, names)
|
||||
if any(package_file.endswith(".py")
|
||||
for package_file in os.listdir(package_path)):
|
||||
names.add(name)
|
||||
|
||||
|
||||
# Extension modules built by setup.py
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue