# HG changeset patch # Parent 64e1986859511bd296b63c3ce429839b10624dc5 Issue #12141: Install copies of template C module file so that packaging test_command_build_ext and distutils test_build_ext can be run outside of a build directory or with regrtest -j. diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -22,6 +22,11 @@ ALREADY_TESTED = False def _get_source_filename(): + # use installed copy if available + tests_f = os.path.join(os.path.dirname(__file__), 'xxmodule.c') + if os.path.exists(tests_f): + return tests_f + # otherwise try using copy from build directory srcdir = sysconfig.get_config_var('srcdir') return os.path.join(srcdir, 'Modules', 'xxmodule.c') diff --git a/Lib/packaging/tests/test_command_build_ext.py b/Lib/packaging/tests/test_command_build_ext.py --- a/Lib/packaging/tests/test_command_build_ext.py +++ b/Lib/packaging/tests/test_command_build_ext.py @@ -17,6 +17,11 @@ def _get_source_filename(): + # use installed copy if available + tests_f = os.path.join(os.path.dirname(__file__), 'xxmodule.c') + if os.path.exists(tests_f): + return tests_f + # otherwise try using copy from build directory srcdir = sysconfig.get_config_var('srcdir') return os.path.join(srcdir, 'Modules', 'xxmodule.c') diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -931,7 +931,7 @@ multiprocessing multiprocessing/dummy \ unittest unittest/test \ curses pydoc_data $(MACHDEPS) -libinstall: build_all $(srcdir)/Lib/$(PLATDIR) +libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c @for i in $(SCRIPTDIR) $(LIBDEST); \ do \ if test ! -d $(DESTDIR)$$i; then \ @@ -987,6 +987,14 @@ done; \ done $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt + if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \ + $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ + $(DESTDIR)$(LIBDEST)/distutils/tests ; \ + fi + if test -d $(DESTDIR)$(LIBDEST)/packaging/tests; then \ + $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ + $(DESTDIR)$(LIBDEST)/packaging/tests ; \ + fi -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ ./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ -d $(LIBDEST) -f \