#133 [EXPERIMENTAL] Build python3 statically, but have a libpython3 package
Closed a year ago by churchyard. Opened a year ago by churchyard.
rpms/ churchyard/python3 static  into  master

@@ -1,78 +0,0 @@ 

- From f6df02cde47874f10e183ead483c90941bb8076f Mon Sep 17 00:00:00 2001

- From: David Malcolm <dmalcolm@redhat.com>

- Date: Mon, 18 Jan 2010 17:59:07 +0000

- Subject: [PATCH] 00111: Don't try to build a libpythonMAJOR.MINOR.a

- MIME-Version: 1.0

- Content-Type: text/plain; charset=UTF-8

- Content-Transfer-Encoding: 8bit

- 

- Downstream only: not appropriate for upstream.

- 

- See https://bugzilla.redhat.com/show_bug.cgi?id=556092

- 

- Co-authored-by: David Malcolm <dmalcolm@redhat.com>

- Co-authored-by: Bohuslav Kabrda <bkabrda@redhat.com>

- Co-authored-by: Matej Stuchlik <mstuchli@redhat.com>

- Co-authored-by: Robert Kuska <rkuska@redhat.com>

- Co-authored-by: Charalampos Stratakis <cstratak@redhat.com>

- Co-authored-by: Miro Hrončok <miro@hroncok.cz>

- ---

-  Makefile.pre.in | 21 ++-------------------

-  1 file changed, 2 insertions(+), 19 deletions(-)

- 

- diff --git a/Makefile.pre.in b/Makefile.pre.in

- index 4ad3df1122..72d202d71b 100644

- --- a/Makefile.pre.in

- +++ b/Makefile.pre.in

- @@ -562,7 +562,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)

- +$(BUILDPYTHON):	Programs/python.o $(LDLIBRARY) $(PY3LIBRARY)

-  	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)

-  

-  platform: $(BUILDPYTHON) pybuilddir.txt

- @@ -610,12 +610,6 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o

-  		_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \

-  		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build

-  

- -

- -# Build static library

- -$(LIBRARY): $(LIBRARY_OBJS)

- -	-rm -f $@

- -	$(AR) $(ARFLAGS) $@ $(LIBRARY_OBJS)

- -

-  libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)

-  	if test $(INSTSONAME) != $(LDLIBRARY); then \

-  		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \

- @@ -693,7 +687,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)

- +Programs/_testembed: Programs/_testembed.o $(LDLIBRARY) $(PY3LIBRARY)

-  	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)

-  

-  ############################################################################

- @@ -1557,17 +1551,6 @@ 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) ; \

- -			else \

- -				$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \

- -			fi; \

- -		else \

- -			echo Skip install of $(LIBRARY) - use make frameworkinstall; \

- -		fi; \

- -	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

- -- 

- 2.21.0

- 

file added
+14
@@ -0,0 +1,14 @@ 

+ diff --git a/configure.ac b/configure.ac

+ index 807e379..6eedf9e 100644

+ --- a/configure.ac

+ +++ b/configure.ac

+ @@ -1121,8 +1121,7 @@ if test $enable_shared = "yes"; then

+            ;;

+      Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)

+  	  LDLIBRARY='libpython$(LDVERSION).so'

+ -	  BLDLIBRARY='-L. -lpython$(LDVERSION)'

+ -	  RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

+ +	  BLDLIBRARY='$(LIBRARY_OBJS)'

+  	  INSTSONAME="$LDLIBRARY".$SOVERSION

+  	  if test "$with_pydebug" != yes

+            then

file modified
+31 -14
@@ -17,7 +17,7 @@ 

  #global prerel ...

  %global upstream_version %{general_version}%{?prerel}

  Version: %{general_version}%{?prerel:~%{prerel}}

- Release: 1%{?dist}

+ Release: 666%{?dist}

  License: Python

  

  
@@ -233,13 +233,6 @@ 

  # Not yet sent upstream.

  Patch102: 00102-lib64.patch

  

- # 00111 #

- # Patch the Makefile.pre.in so that the generated Makefile doesn't try to build

- # a libpythonMAJOR.MINOR.a

- # See https://bugzilla.redhat.com/show_bug.cgi?id=556092

- # Downstream only: not appropriate for upstream

- Patch111: 00111-no-static-lib.patch

- 

  # 00189 #

  # Instead of bundled wheels, use our RPM packaged wheels from

  # /usr/share/python-wheels
@@ -261,6 +254,9 @@ 

  # See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426

  Patch328: 00328-pyc-timestamp-invalidation-mode.patch

  

+ # XXXXX

+ Patch666: 00666.patch

+ 

  # (New patches go here ^^^)

  #

  # When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@@ -367,7 +363,7 @@ 

  

  

  %package libs

- Summary:        Python runtime libraries

+ Summary:        Python standard library

  

  %if %{with rpmwheels}

  Requires: python-setuptools-wheel
@@ -398,16 +394,25 @@ 

  

  

  %description libs

- This package contains runtime libraries for use by Python:

- - the majority of the Python standard library

- - a dynamically linked library for use by applications that embed Python as

-   a scripting language, and by the main "python3" executable

+ This package contains the majority of the Python standard library.

+ 

+ 

+ %package -n lib%{name}

+ Summary: Python shared library

+ Requires: %{name}-libs%{?_isa} = %{version}-%{release}

+ Provides: libpython = %{version}-%{release}

+ Provides: libpython%{?_isa} = %{version}-%{release}

+ 

+ %description -n lib%{name}

+ This package contains a dynamically linked library for use by applications

+ that embed Python as a scripting language.

  

  

  %package devel

  Summary: Libraries and header files needed for Python development

  Requires: %{name} = %{version}-%{release}

  Requires: %{name}-libs%{?_isa} = %{version}-%{release}

+ Requires: lib%{name}%{?_isa} = %{version}-%{release}

  BuildRequires: python-rpm-macros

  # The RPM related dependencies bring nothing to a non-RPM Python developer

  # But we want them when packages BuildRequire python3-devel
@@ -511,6 +516,7 @@ 

  # shares the same .py/.pyc files and directories as the regular build. Hence

  # we depend on all of the subpackages of the regular build:

  Requires: %{name}%{?_isa} = %{version}-%{release}

+ Requires: lib%{name}%{?_isa} = %{version}-%{release}

  Requires: %{name}-libs%{?_isa} = %{version}-%{release}

  Requires: %{name}-devel%{?_isa} = %{version}-%{release}

  Requires: %{name}-test%{?_isa} = %{version}-%{release}
@@ -587,7 +593,6 @@ 

  %if "%{_lib}" == "lib64"

  %patch102 -p1

  %endif

- %patch111 -p1

  

  %if %{with rpmwheels}

  %patch189 -p1
@@ -597,6 +602,7 @@ 

  %patch251 -p1

  %patch274 -p1

  %patch328 -p1

+ %patch666 -p1

  

  

  # Remove files that should be generated by the build
@@ -927,6 +933,12 @@ 

  # See https://bugzilla.redhat.com/show_bug.cgi?id=1111275

  mv %{buildroot}%{_bindir}/2to3-%{pybasever} %{buildroot}%{_bindir}/2to3

  

+ # Remove the static library

+ rm %{buildroot}%{pylibdir}/config-%{LDVERSION_optimized}-%{_arch}-linux%{_gnu}/*.a

+ %if %{with debug_build}

+ rm %{buildroot}%{pylibdir}/config-%{LDVERSION_debug}-%{_arch}-linux%{_gnu}/*.a

+ %endif

+ 

  %if %{with flatpackage}

  # Remove stuff that would conflict with python3 package

  rm %{buildroot}%{_bindir}/python3
@@ -1276,6 +1288,11 @@ 

  %dir %{_includedir}/python%{LDVERSION_optimized}/

  %{_includedir}/python%{LDVERSION_optimized}/%{_pyconfig_h}

  

+ 

+ %if %{without flatpackage}

+ %files -n lib%{name}

+ %endif

+ 

  %{_libdir}/%{py_INSTSONAME_optimized}

  %if %{without flatpackage}

  %{_libdir}/libpython3.so

Context: https://bugzilla.redhat.com/show_bug.cgi?id=1749479

TODO:

  • make sure it works
  • properly number/document/register/git the patch
  • changelog
  • explain the reasoning in the commit message
  • prepare a proper patch that adds a new option to configure, propose upstream

Open questions:

  1. Why was /usr/lib64/libpython3.so in python3-libs and not python3-devel? What is this file actually for? (stable ABI)

  2. Which package should provide python(abi)? Now it is the interpreter package (python3). All Python modules require it. But Python modules are useful from libpython3 as well. Should both packages provide it? Or should python3-libs provide it? See also this question from the past - it touches the topic yet without the context of this new problem.

  3. Do extension modules that link to libpython 3still work? Try something from repoquery --repo=rawhide --whatrequires 'libpython3.8.so.1.0()(64bit)':

  • python3-COPASI
  • python3-arcus
  • python3-arcus-lulzbot
  • python3-caja
  • python3-cantor
  • python3-clingo
  • python3-createrepo_c
  • python3-csound
  • python3-devel
  • python3-dmlite
  • python3-gdcm
  • python3-gdl
  • python3-gpaw-mpich
  • python3-gpaw-openmpi
  • python3-gstreamer1
  • python3-hamlib
  • python3-hawkey
  • python3-hokuyoaist
  • python3-jep
  • python3-kolabformat
  • python3-ldb
  • python3-ldns
  • python3-libCombine
  • python3-libcomps
  • python3-libdnf
  • python3-libftdi
  • python3-libkml
  • python3-libnuml
  • python3-libpamtest
  • python3-libplist
  • python3-librepo
  • python3-libsbml
  • python3-libsedml
  • python3-libyang
  • python3-mathgl
  • python3-med
  • python3-mod_wsgi
  • python3-nest
  • python3-nest-mpich
  • python3-nest-openmpi
  • python3-netgen-mesher
  • python3-netgen-mesher-mpich
  • python3-netgen-mesher-openmpi
  • python3-nordugrid-arc
  • python3-openbabel
  • python3-openimageio
  • python3-openmeeg
  • python3-opentrep
  • python3-pythia8
  • python3-qgis
  • python3-qpid-proton
  • python3-qt5-base
  • python3-rdkit
  • python3-rmol
  • python3-root
  • python3-samba
  • python3-samba-dc
  • python3-savitar
  • python3-talloc
  • python3-trademgen
  • python3-unbound
  • python3-vigra
  • python3-vrpn
  • python3-vtk-mpich
  • python3-vtk-openmpi
  • python3-yui

Metadata Update from @churchyard:
- Pull-request tagged with: WIP, feature

a year ago
  1. libpython3.so is similar to libpython3.8.so, but for the stable ABI. Extensions that link against should will work with libpython3.so from python3.8+.

  2. For now, I think it should be the interpreter. Changing that might be material for a Change proposal.

For 3 I'm out of time this week :(

Ad 2: we agreed with @cstratak that this needs a change proposal anyway.

3 is a more long term thing. I assume that least python3-hawkey must have worked on the CI.

rebased onto e50681262797eaf72250fc98b7c3e38bd7f747e4

a year ago

rebased onto d1f36e1ceaf907eb6e377778fdb24e430efbf184

a year ago

rebased onto ca72dc1

a year ago

Pull-Request has been closed by churchyard

a year ago