Skip to content

Commit

Permalink
bpo-42955: Add Python/module_names.h (pythonGH-24258)
Browse files Browse the repository at this point in the history
Add a private list of all stdlib modules: _Py_module_names.

* Add Tools/scripts/generate_module_names.py script.
* Makefile: Add "make regen-module-names" command.
* setup.py: Add --list-module-names option.
* GitHub Action and Travis CI also runs "make regen-module-names",
  not ony "make regen-all", to ensure that the module names remains
  up to date.
  • Loading branch information
vstinner authored Jan 19, 2021
1 parent e8e66ea commit cad8020
Show file tree
Hide file tree
Showing 8 changed files with 592 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
# Build Python with the libpython dynamic library
./configure --with-pydebug --enable-shared
make -j4 regen-all
make regen-module-names
- name: Check for changes
run: |
changes=$(git status --porcelain)
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ before_script:
- eval "$(pyenv init -)"
- pyenv global 3.8
- PYTHON_FOR_REGEN=python3.8 make -j4 regen-all
- make regen-module-names
- changes=`git status --porcelain`
- |
# Check for changes in regenerated files
Expand Down
17 changes: 15 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)

PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
UPDATE_FILE=@PYTHON_FOR_REGEN@ $(srcdir)/Tools/scripts/update_file.py
UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
BUILD_GNU_TYPE= @build@
Expand Down Expand Up @@ -757,6 +757,8 @@ regen-limited-abi: all
regen-all: regen-opcode regen-opcode-targets regen-typeslots \
regen-token regen-ast regen-keyword regen-importlib clinic \
regen-pegen-metaparser regen-pegen
@echo
@echo "Note: make regen-module-names and autoconf should be run manually"

############################################################################
# Special rules for object files
Expand Down Expand Up @@ -896,6 +898,15 @@ regen-keyword:
$(srcdir)/Lib/keyword.py.new
$(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new

.PHONY: regen-module-names
regen-module-names: build_all
# Regenerate Python/module_names.h
# using Tools/scripts/generate_module_names.py
$(RUNSHARED) ./$(BUILDPYTHON) \
$(srcdir)/Tools/scripts/generate_module_names.py \
> $(srcdir)/Python/module_names.h.new
$(UPDATE_FILE) $(srcdir)/Python/module_names.h $(srcdir)/Python/module_names.h.new

Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o: $(srcdir)/Include/Python-ast.h

Python/getplatform.o: $(srcdir)/Python/getplatform.c
Expand Down Expand Up @@ -1145,7 +1156,9 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_ucnhash.h \
$(srcdir)/Include/internal/pycore_unionobject.h \
$(srcdir)/Include/internal/pycore_warnings.h \
$(DTRACE_HEADERS)
$(DTRACE_HEADERS) \
\
$(srcdir)/Python/module_names.h

$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)

Expand Down
1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
<ClInclude Include="..\Python\ceval_gil.h" />
<ClInclude Include="..\Python\condvar.h" />
<ClInclude Include="..\Python\importdl.h" />
<ClInclude Include="..\Python\module_names.h" />
<ClInclude Include="..\Python\thread_nt.h" />
<ClInclude Include="..\Python\wordcode_helpers.h" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@
<ClInclude Include="..\Python\importdl.h">
<Filter>Python</Filter>
</ClInclude>
<ClInclude Include="..\Python\module_names.h">
<Filter>Python</Filter>
</ClInclude>
<ClInclude Include="..\Python\thread_nt.h">
<Filter>Python</Filter>
</ClInclude>
Expand Down
Loading

0 comments on commit cad8020

Please sign in to comment.