Skip to content
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

Add configure --without-static-libpython to not build libpython3.10.a #87269

Closed
vstinner opened this issue Feb 2, 2021 · 7 comments
Closed
Labels
3.10 only security fixes build The build process and cross-build

Comments

@vstinner
Copy link
Member

vstinner commented Feb 2, 2021

BPO 43103
Nosy @vstinner, @ned-deily, @pablogsal
PRs
  • bpo-43103: Add configure --without-static-libpython #24418
  • bpo-43103: Fix build failure with macOS framework builds. #24676
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-02-17.10:58:14.481>
    created_at = <Date 2021-02-02.15:23:47.769>
    labels = ['build', '3.10']
    title = 'Add configure --without-static-libpython to not build libpython3.10.a'
    updated_at = <Date 2021-03-01.07:04:12.058>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-03-01.07:04:12.058>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-17.10:58:14.481>
    closer = 'vstinner'
    components = ['Build']
    creation = <Date 2021-02-02.15:23:47.769>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43103
    keywords = ['patch']
    message_count = 7.0
    messages = ['386149', '386153', '386205', '386215', '386216', '387137', '387844']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'ned.deily', 'pablogsal']
    pr_nums = ['24418', '24676']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43103'
    versions = ['Python 3.10']

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 2, 2021

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

    @vstinner vstinner added 3.10 only security fixes build The build process and cross-build labels Feb 2, 2021
    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 2, 2021

    "./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.

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 3, 2021

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

    @pablogsal
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 3, 2021

    I rewrote my PR to leave the default behavior unchanged and I renamed the option to --without-static-libpython (python => libpython).

    @vstinner vstinner changed the 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 Feb 3, 2021
    @vstinner vstinner changed the 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 Feb 3, 2021
    @vstinner
    Copy link
    Member Author

    New changeset 801bb0b by Victor Stinner in branch 'master':
    bpo-43103: Add configure --without-static-libpython (GH-24418)
    801bb0b

    @ned-deily
    Copy link
    Member

    New changeset 0608425 by Ned Deily in branch 'master':
    bpo-43103: Fix build failure with macOS framework builds. (GH-24676)
    0608425

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants