This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add configure --without-static-libpython to not build libpython3.10.a
Type: Stage: resolved
Components: Build Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, pablogsal, vstinner
Priority: normal Keywords: patch

Created on 2021-02-02 15:23 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24418 merged vstinner, 2021-02-02 18:12
PR 24676 merged ned.deily, 2021-03-01 06:39
Messages (7)
msg386149 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-02 15:23
Currently, "make install" copies Programs/python.o to $prefix/lib/python3.10/config-3.10-x86_64-linux-gnu/: see bpo-42307. This file is only useful to build a static Python executable with libpython3.10.a.

libpython3.10.a is also copied to $prefix/lib/python3.10/config-3.10-x86_64-linux-gnu/.

Most users don't build a static Python executable, so I propose to no longer build "static Python" by default and add --with-static-python option to the configure script.


---


Fedora has a downstream patch to not build libpythonX.Y.a for 11 years:
https://src.fedoraproject.org/rpms/python3.10/blob/master/f/00111-no-static-lib.patch

It is needed to respect the Fedora packaging guideline. The patch was introduced in Fedora to fix "python : does not adhere to Static Library Packaging Guideline" issue:
https://bugzilla.redhat.com/show_bug.cgi?id=556092

"""


The package is in need of an update because it does not adhere to
the guidelines for packaging static libraries:

  http://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries

The -devel package contains both the shared and the static build of
a library. That makes it possible to link statically with the -devel
package as a build requirement instead of having to build-require a
special-purpose -static subpackage.

Correct would be to either disable/delete the static libraries at
build-time, or to %exclude them in the %files section, or to split off
a -static subpackage (if there is a compelling reason as why the static
libs should be made available).

Please consult the guidelines for the details.

[...]

python-devel
    /usr/lib/python2.6/config/libpython2.6.so  <=>  /usr/lib/python2.6/config/libpython2.6.a
"""
msg386153 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-02 16:32
"./configure --enable-shared --prefix /opt/py310 && make && make install" installs multiple files which are only useful to create a static Python binary:

$ ls /opt/py310/lib/python3.10/config-3.10-x86_64-linux-gnu/ -1
config.c
config.c.in
install-sh*
libpython3.10.a
Makefile
makesetup*
__pycache__/
python-config.py*
python.o
Setup
Setup.local

$ ls /opt/py310/lib/ -1
libpython3.10.so@
libpython3.10.so.1.0*
libpython3.so*
pkgconfig/
python3.10/

libpython3.10.a is a big file: 15 MB.

Without --enable-shared, /opt/py310/lib/ contains a second copy of libpython3.10.a!


Example with the Ubuntu libpython3.6-dev package:

$ dpkg -L libpython3.6-dev|grep config-
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/Makefile
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/Setup
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/Setup.config
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/Setup.local
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/config.c
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/config.c.in
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/install-sh
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m-pic.a
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.a
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/makesetup
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/python-config.py
/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/python.o

---

By the way, it seems like many files of /opt/py310/lib/python3.10/config-3.10-x86_64-linux-gnu/ are useless.

The most useful one is python-config.py script.

Makefile is no longer used by sysconfig which creates _sysconfigdata__linux_x86_64-linux-gnu.py (in /opt/py310/lib/python3.10/) instead.
msg386205 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-03 13:49
About the option name, I consider to rename it to: --with-static-libpython, since technically it doesn't build a static "python" executable, but a static "libpython" (.a).
msg386215 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-03 15:38
There are some build systems and downstream distributors that expect the .a to be there, so I propose to at least not changing the default.
msg386216 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-03 15:41
I rewrote my PR to leave the default behavior unchanged and I renamed the option to --without-static-libpython (python => libpython).
msg387137 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-02-17 10:15
New changeset 801bb0b5035f8eeafe389dc082c02dfafaa07f6a by Victor Stinner in branch 'master':
bpo-43103: Add configure --without-static-libpython (GH-24418)
https://github.com/python/cpython/commit/801bb0b5035f8eeafe389dc082c02dfafaa07f6a
msg387844 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-03-01 07:04
New changeset 0608425944932f46b544afea04ae6d301a76f5f2 by Ned Deily in branch 'master':
bpo-43103: Fix build failure with macOS framework builds. (GH-24676)
https://github.com/python/cpython/commit/0608425944932f46b544afea04ae6d301a76f5f2
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87269
2021-03-01 07:04:12ned.deilysetmessages: + msg387844
2021-03-01 06:39:49ned.deilysetnosy: + ned.deily

pull_requests: + pull_request23461
2021-02-17 10:59:40vstinnerlinkissue42307 superseder
2021-02-17 10:58:14vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-02-17 10:15:14vstinnersetmessages: + msg387137
2021-02-03 15:41:30vstinnersetmessages: + msg386216
title: Add configure option to disable build libpython.a and don't install python.o -> Add configure --without-static-libpython to not build libpython3.10.a
2021-02-03 15:38:14pablogsalsetnosy: + pablogsal
messages: + msg386215
2021-02-03 13:49:44vstinnersetmessages: + msg386205
2021-02-02 18:12:54vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request23233
2021-02-02 16:32:05vstinnersetmessages: + msg386153
2021-02-02 15:23:47vstinnercreate