Skip to content

bpo-34106: Add --with-modules-setup option to 'configure' script #8269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
# python_build: (Boolean) if true, we're either building Python or
# building an extension with an un-installed Python, so we use
# different (hard-wired) directories.
# Setup.local is available for Makefile builds including VPATH builds,
# Setup.dist is available on Windows
def _is_python_source_dir(d):
for fn in ("Setup.dist", "Setup.local"):
for fn in ("Setup", "Setup.local"):
if os.path.isfile(os.path.join(d, "Modules", fn)):
return True
return False
Expand Down
2 changes: 1 addition & 1 deletion Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _safe_realpath(path):
_PROJECT_BASE = _safe_realpath(os.environ["_PYTHON_PROJECT_BASE"])

def _is_python_source_dir(d):
for fn in ("Setup.dist", "Setup.local"):
for fn in ("Setup", "Setup.local"):
if os.path.isfile(os.path.join(d, "Modules", fn)):
return True
return False
Expand Down
20 changes: 5 additions & 15 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ INSTALL_SHARED= ${INSTALL} -m 555
MKDIR_P= @MKDIR_P@

MAKESETUP= $(srcdir)/Modules/makesetup
MODULES_SETUP= @MODULES_SETUP@

# Compiler options
OPT= @OPT@
Expand Down Expand Up @@ -687,26 +688,16 @@ oldsharedmods: $(SHAREDMODS)
Makefile Modules/config.c: Makefile.pre \
$(srcdir)/Modules/config.c.in \
$(MAKESETUP) \
Modules/Setup \
$(MODULES_SETUP) \
Modules/Setup.local
$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
-s Modules \
Modules/Setup.local \
Modules/Setup
$(MODULES_SETUP)
@mv config.c Modules
@echo "The Makefile was updated, you may need to re-run make."


Modules/Setup: $(srcdir)/Modules/Setup.dist
@if test -f Modules/Setup; then \
echo "-----------------------------------------------"; \
echo "Modules/Setup.dist is newer than Modules/Setup;"; \
echo "check to make sure you have all the updates you"; \
echo "need in your Modules/Setup file."; \
echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
echo "-----------------------------------------------"; \
fi

Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)

Expand Down Expand Up @@ -1478,7 +1469,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
$(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o
$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
$(INSTALL_DATA) $(MODULES_SETUP) $(DESTDIR)$(LIBPL)/Setup
$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
Expand Down Expand Up @@ -1701,8 +1692,7 @@ distclean: clobber
for file in $(srcdir)/Lib/test/data/* ; do \
if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \
done
-rm -f core Makefile Makefile.pre config.status \
Modules/Setup Modules/Setup.local \
-rm -f core Makefile Makefile.pre config.status Modules/Setup.local \
Modules/ld_so_aix Modules/python.exp Misc/python.pc \
Misc/python-config.sh
-rm -f python*-gdb.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rename Modules/Setup.dist to Modules/Setup, and remove the necessity to copy
the former manually to the latter when updating the local source tree.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The 'configure' script now accepts a --with-module-config=<file> option. By
default, the Modules/Setup file is used. By providing this option, a
customized Setup file can be provided. The file will be used by
Modules/makesetup to generate the makefile and Modules/config.c.
9 changes: 3 additions & 6 deletions Modules/Setup.dist → Modules/Setup
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# -*- makefile -*-
# The file Setup is used by the makesetup script to construct the files
# Makefile and config.c, from Makefile.pre and config.c.in,
# respectively. The file Setup itself is initially copied from
# Setup.dist; once it exists it will not be overwritten, so you can edit
# Setup to your heart's content. Note that Makefile.pre is created
# from Makefile.pre.in by the toplevel configure script.
# respectively. Note that Makefile.pre is created from Makefile.pre.in
# by the toplevel configure script.

# (VPATH notes: Setup and Makefile.pre are in the build directory, as
# are Makefile and config.c; the *.in and *.dist files are in the source
# directory.)
# are Makefile and config.c; the *.in files are in the source directory.)

# Each line in this file describes one or more optional modules.
# Modules configured here will not be compiled by the setup.py script,
Expand Down
2 changes: 1 addition & 1 deletion Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ search_for_prefix(const _PyCoreConfig *core_config,
/* Check to see if argv[0] is in the build directory */
wcsncpy(prefix, calculate->argv0_path, MAXPATHLEN);
prefix[MAXPATHLEN] = L'\0';
joinpath(prefix, L"Modules/Setup");
joinpath(prefix, L"Modules/Setup.local");
if (isfile(prefix)) {
/* Check VPATH to see if argv0_path is in the build directory. */
vpath = Py_DecodeLocale(VPATH, NULL);
Expand Down
2 changes: 1 addition & 1 deletion Modules/makesetup
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Setup files after a -n option are used for their variables, modules
# and libraries but not for their .o files.
#
# See Setup.dist for a description of the format of the Setup file.
# See Setup for a description of the format of the Setup file.
#
# The following edits are made:
#
Expand Down
20 changes: 10 additions & 10 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15 -*- Autoconf -*-

# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -12,9 +12,9 @@
# PARTICULAR PURPOSE.

m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)

dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
dnl serial 11 (pkg-config-0.29.1)
dnl
dnl Copyright © 2004 Scott James Remnant <[email protected]>.
dnl Copyright © 2012-2015 Dan Nicholson <[email protected]>
dnl
Expand Down Expand Up @@ -55,7 +55,7 @@ dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
[m4_define([PKG_MACROS_VERSION], [0.29.1])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
Expand Down Expand Up @@ -156,7 +156,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl

pkg_failed=no
AC_MSG_CHECKING([for $2])
AC_MSG_CHECKING([for $1])

_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
Expand All @@ -166,11 +166,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])

if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
Expand All @@ -187,7 +187,7 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
Expand Down
45 changes: 37 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ ac_includes_default="\
#endif"

ac_subst_vars='LTLIBOBJS
MODULES_SETUP
OPENSSL_LDFLAGS
OPENSSL_LIBS
OPENSSL_INCLUDES
Expand Down Expand Up @@ -781,6 +782,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -839,6 +841,7 @@ with_computed_gotos
with_ensurepip
with_openssl
with_ssl_default_suites
with_modules_setup
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -891,6 +894,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -1143,6 +1147,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1280,7 +1293,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1433,6 +1446,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -1541,6 +1555,8 @@ Optional Packages:
Python's preferred selection (default), openssl:
leave OpenSSL's defaults untouched, STRING: use a
custom string, PROTOCOL_SSLv2 ignores the setting
--with-modules-setup=FILE
Modules Setup file, default is Modules/Setup

Some influential environment variables:
MACHDEP name for machine-dependent library files
Expand Down Expand Up @@ -17050,6 +17066,25 @@ $as_echo "#define PY_SSL_DEFAULT_CIPHERS 1" >>confdefs.h
fi


# Allow custom Modules/Setup file

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-modules-setup=FILE" >&5
$as_echo_n "checking for --with-modules-setup=FILE... " >&6; }

# Check whether --with-modules-setup was given.
if test "${with_modules_setup+set}" = set; then :
withval=$with_modules_setup;
MODULES_SETUP="$withval"

else

MODULES_SETUP="$srcdir/Modules/Setup"

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MODULES_SETUP" >&5
$as_echo "$MODULES_SETUP" >&6; }


# generate output files
ac_config_files="$ac_config_files Makefile.pre Misc/python.pc Misc/python-config.sh"
Expand Down Expand Up @@ -18355,12 +18390,6 @@ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi


echo "creating Modules/Setup" >&6
if test ! -f Modules/Setup
then
cp $srcdir/Modules/Setup.dist Modules/Setup
fi

echo "creating Modules/Setup.local" >&6
if test ! -f Modules/Setup.local
then
Expand All @@ -18370,7 +18399,7 @@ fi
echo "creating Makefile" >&6
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-s Modules \
Modules/Setup.local Modules/Setup
Modules/Setup.local "$MODULES_SETUP"
mv config.c Modules

if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
Expand Down
21 changes: 14 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5559,18 +5559,25 @@ AC_MSG_RESULT(python)
AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1)
])

# Allow custom Modules/Setup file
AC_SUBST(MODULES_SETUP)
AC_MSG_CHECKING(for --with-modules-setup=FILE)
AC_ARG_WITH(modules-setup,
AS_HELP_STRING([--with-modules-setup=FILE],
[Modules Setup file, default is Modules/Setup]),
[
MODULES_SETUP="$withval"
], [
MODULES_SETUP="$srcdir/Modules/Setup"
])
AC_MSG_RESULT($MODULES_SETUP)


# generate output files
AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-config.sh)
AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
AC_OUTPUT

echo "creating Modules/Setup" >&AS_MESSAGE_FD
if test ! -f Modules/Setup
then
cp $srcdir/Modules/Setup.dist Modules/Setup
fi

echo "creating Modules/Setup.local" >&AS_MESSAGE_FD
if test ! -f Modules/Setup.local
then
Expand All @@ -5580,7 +5587,7 @@ fi
echo "creating Makefile" >&AS_MESSAGE_FD
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-s Modules \
Modules/Setup.local Modules/Setup
Modules/Setup.local "$MODULES_SETUP"
mv config.c Modules

if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
Expand Down