]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43103: Add configure --without-static-libpython (GH-24418)
authorVictor Stinner <vstinner@python.org>
Wed, 17 Feb 2021 10:14:42 +0000 (11:14 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Feb 2021 10:14:42 +0000 (11:14 +0100)
Add a new configure --without-static-libpython option to not build
the libpythonMAJOR.MINOR.a static library and not install the
python.o object file.

Fix smelly.py and stable_abi.py tools when libpython3.10.a is
missing.

Doc/whatsnew/3.10.rst
Makefile.pre.in
Misc/NEWS.d/next/Build/2021-02-02-16-26-44.bpo-43103.VWeyP_.rst [new file with mode: 0644]
Tools/scripts/smelly.py
Tools/scripts/stable_abi.py
configure
configure.ac

index c282edcc9d8f0ece95069c6ec12118bddcd78fca..0fba27c7d5845c269a7000f1b98cf698311a1479 100644 (file)
@@ -820,6 +820,12 @@ Build Changes
 
   (Contributed by Victor Stinner in :issue:`42856`.)
 
+* Add a new configure ``--without-static-libpython`` option to not build the
+  ``libpythonMAJOR.MINOR.a`` static library and not install the ``python.o``
+  object file.
+
+  (Contributed by Victor Stinner in :issue:`43103`.)
+
 
 C API Changes
 =============
index 0d9fdc713406c0de4447a5530d4db923e7f711a0..d3ac2dab893f0baf3514d542ec124fc12b3e86dc 100644 (file)
@@ -236,6 +236,9 @@ PY3LIBRARY=     @PY3LIBRARY@
 DLLLIBRARY=    @DLLLIBRARY@
 LDLIBRARYDIR=   @LDLIBRARYDIR@
 INSTSONAME=    @INSTSONAME@
+LIBRARY_DEPS=  @LIBRARY_DEPS@
+PY_ENABLE_SHARED=      @PY_ENABLE_SHARED@
+STATIC_LIBPYTHON=      @STATIC_LIBPYTHON@
 
 
 LIBS=          @LIBS@
@@ -578,7 +581,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
        $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
 
 # Build the interpreter
-$(BUILDPYTHON):        Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
+$(BUILDPYTHON):        Programs/python.o $(LIBRARY_DEPS)
        $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
 
 platform: $(BUILDPYTHON) pybuilddir.txt
@@ -713,7 +716,7 @@ Makefile Modules/config.c: Makefile.pre \
        @echo "The Makefile was updated, you may need to re-run make."
 
 
-Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
+Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS)
        $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
 
 ############################################################################
@@ -1305,19 +1308,21 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
                fi; \
                (cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
        fi
-       if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
-               if test -n "$(DLLLIBRARY)" ; then \
-                       $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
-               else \
-                       $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
-                       if test $(LDLIBRARY) != $(INSTSONAME); then \
-                               (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
-                       fi \
-               fi; \
-               if test -n "$(PY3LIBRARY)"; then \
-                       $(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
+       @if test "$(PY_ENABLE_SHARED)" = 1 -o "$(STATIC_LIBPYTHON)" = 1; then \
+               if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
+                       if test -n "$(DLLLIBRARY)" ; then \
+                               $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
+                       else \
+                               $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
+                               if test $(LDLIBRARY) != $(INSTSONAME); then \
+                                       (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
+                               fi \
+                       fi; \
+                       if test -n "$(PY3LIBRARY)"; then \
+                               $(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
+                       fi; \
+               else    true; \
                fi; \
-       else    true; \
        fi
        if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
                rm -f $(DESTDIR)$(BINDIR)python$(VERSION)-32$(EXE); \
@@ -1661,19 +1666,21 @@ libainstall:    @DEF_MAKE_RULE@ python-config
                else    true; \
                fi; \
        done
-       @if test -d $(LIBRARY); then :; else \
-               if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
-                       if test "$(SHLIB_SUFFIX)" = .dll; then \
-                               $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
+       @if test "$(STATIC_LIBPYTHON)" = 1; then \
+               if test -d $(LIBRARY); then :; else \
+                       if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
+                               if test "$(SHLIB_SUFFIX)" = .dll; then \
+                                       $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
+                               else \
+                                       $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
+                               fi; \
                        else \
-                               $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
+                               echo Skip install of $(LIBRARY) - use make frameworkinstall; \
                        fi; \
-               else \
-                       echo Skip install of $(LIBRARY) - use make frameworkinstall; \
                fi; \
+               $(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o; \
        fi
        $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
-       $(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) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup
diff --git a/Misc/NEWS.d/next/Build/2021-02-02-16-26-44.bpo-43103.VWeyP_.rst b/Misc/NEWS.d/next/Build/2021-02-02-16-26-44.bpo-43103.VWeyP_.rst
new file mode 100644 (file)
index 0000000..edf04c1
--- /dev/null
@@ -0,0 +1,3 @@
+Add a new configure ``--without-static-libpython`` option to not build the
+``libpythonMAJOR.MINOR.a`` static library and not install the ``python.o``
+object file.
index e8a375c808cdaa1a2ece7b845f522186bf5b496e..fb01660dea33ae9fc1008e5cdc1c365687925bc0 100755 (executable)
@@ -136,11 +136,14 @@ def check_extensions():
 
 
 def main():
+    nsymbol = 0
+
     # static library
     LIBRARY = sysconfig.get_config_var('LIBRARY')
     if not LIBRARY:
         raise Exception("failed to get LIBRARY variable from sysconfig")
-    nsymbol = check_library(LIBRARY)
+    if os.path.exists(LIBRARY):
+        nsymbol += check_library(LIBRARY)
 
     # dynamic library
     LDLIBRARY = sysconfig.get_config_var('LDLIBRARY')
index 47547a97bfd318209ae59fb4c75c507013ebce31..117dfeb3cb57aa413e1e72214cb85f86dbd7e314 100755 (executable)
@@ -2,8 +2,9 @@
 
 import argparse
 import glob
-import re
+import os.path
 import pathlib
+import re
 import subprocess
 import sys
 import sysconfig
@@ -213,7 +214,8 @@ def check_symbols(parser_args):
         LIBRARY = sysconfig.get_config_var("LIBRARY")
         if not LIBRARY:
             raise Exception("failed to get LIBRARY variable from sysconfig")
-        check_library(parser_args.stable_abi_file, LIBRARY, abi_funcs)
+        if os.path.exists(LIBRARY):
+            check_library(parser_args.stable_abi_file, LIBRARY, abi_funcs)
 
         # dynamic library
         LDLIBRARY = sysconfig.get_config_var("LDLIBRARY")
index 8e0cc71a50480dfccc39771c641c04af6c70afc2..8c948250e41e47ea8684d2752b79aa592ab8daf3 100755 (executable)
--- a/configure
+++ b/configure
@@ -624,6 +624,8 @@ ac_includes_default="\
 
 ac_subst_vars='LTLIBOBJS
 TEST_MODULES
+LIBRARY_DEPS
+STATIC_LIBPYTHON
 OPENSSL_LDFLAGS
 OPENSSL_LIBS
 OPENSSL_INCLUDES
@@ -856,6 +858,7 @@ with_openssl
 with_ssl_default_suites
 with_builtin_hashlib_hashes
 with_experimental_isolated_subinterpreters
+with_static_libpython
 enable_test_modules
 '
       ac_precious_vars='build_alias
@@ -1602,6 +1605,9 @@ Optional Packages:
   --with-experimental-isolated-subinterpreters
                           better isolate subinterpreters, experimental build
                           mode (default is no)
+  --without-static-libpython
+                          do not build libpythonMAJOR.MINOR.a and do not
+                          install python.o (default is yes)
 
 Some influential environment variables:
   MACHDEP     name for machine-dependent library files
@@ -17776,6 +17782,40 @@ $as_echo "no" >&6; }
 fi
 
 
+# --with-static-libpython
+STATIC_LIBPYTHON=1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-static-libpython" >&5
+$as_echo_n "checking for --with-static-libpython... " >&6; }
+
+# Check whether --with-static-libpython was given.
+if test "${with_static_libpython+set}" = set; then :
+  withval=$with_static_libpython;
+if test "$withval" = no
+then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; };
+  STATIC_LIBPYTHON=0
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; };
+fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
+if test "$PY_ENABLE_SHARED" = 1; then
+    LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
+    if test "$STATIC_LIBPYTHON" = 1; then
+        LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
+    fi
+else
+    LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
+fi
+
+
+
 # Check whether to disable test modules. Once set, setup.py will not build
 # test extension modules and "make install" will not install test suites.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --disable-test-modules" >&5
index 60c5d8e0b5b034eb642b8d9c4d4e315b10787faa..29957935e9b2aa79a94589734b81e81f0b620a04 100644 (file)
@@ -5882,6 +5882,33 @@ else
 fi],
 [AC_MSG_RESULT(no)])
 
+# --with-static-libpython
+STATIC_LIBPYTHON=1
+AC_MSG_CHECKING(for --with-static-libpython)
+AC_ARG_WITH(static-libpython,
+  AS_HELP_STRING([--without-static-libpython],
+                 [do not build libpythonMAJOR.MINOR.a and do not install python.o (default is yes)]),
+[
+if test "$withval" = no
+then
+  AC_MSG_RESULT(no);
+  STATIC_LIBPYTHON=0
+else
+  AC_MSG_RESULT(yes);
+fi],
+[AC_MSG_RESULT(yes)])
+LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
+if test "$PY_ENABLE_SHARED" = 1; then
+    LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
+    if test "$STATIC_LIBPYTHON" = 1; then
+        LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
+    fi
+else
+    LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS"
+fi
+AC_SUBST(STATIC_LIBPYTHON)
+AC_SUBST(LIBRARY_DEPS)
+
 # Check whether to disable test modules. Once set, setup.py will not build
 # test extension modules and "make install" will not install test suites.
 AC_MSG_CHECKING(for --disable-test-modules)