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

Port module setup to PY_STDLIB_MOD() macro and addext() #90005

Open
tiran opened this issue Nov 19, 2021 · 63 comments
Open

Port module setup to PY_STDLIB_MOD() macro and addext() #90005

tiran opened this issue Nov 19, 2021 · 63 comments
Labels
3.11 3.12 build type-feature

Comments

@tiran
Copy link
Member

@tiran tiran commented Nov 19, 2021

BPO 45847
Nosy @tiran, @ned-deily, @pablogsal, @miss-islington, @erlend-aasland, @arhadthedev
PRs
  • #29642
  • #29644
  • #29660
  • #29668
  • #29685
  • #29688
  • #29689
  • #29690
  • #29696
  • #29697
  • #29699
  • #29702
  • #29703
  • #29705
  • #29706
  • #29707
  • #29713
  • #29715
  • #29720
  • #29725
  • #29727
  • #29738
  • #29741
  • #29743
  • #29747
  • #29768
  • #29769
  • #29833
  • #29844
  • #29914
  • #29946
  • #29967
  • #29969
  • #31698
  • #32229
  • #32299
  • #32328
  • 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 = None
    created_at = <Date 2021-11-19.16:56:30.299>
    labels = ['type-feature', 'build', '3.11']
    title = 'Port module setup to PY_STDLIB_MOD() macro and addext()'
    updated_at = <Date 2022-04-05.04:48:03.902>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2022-04-05.04:48:03.902>
    actor = 'Anthony Sottile'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Build']
    creation = <Date 2021-11-19.16:56:30.299>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45847
    keywords = ['patch']
    message_count = 61.0
    messages = ['406597', '406618', '406646', '406662', '406703', '406714', '406746', '406751', '406754', '406755', '406763', '406771', '406777', '406779', '406781', '406782', '406783', '406784', '406785', '406788', '406801', '406822', '406823', '406842', '406890', '406891', '406892', '406905', '406913', '406914', '407077', '407199', '407249', '407255', '407274', '407287', '407654', '407668', '407861', '407949', '407958', '407959', '407962', '407981', '408008', '414642', '414645', '414648', '414649', '414656', '416425', '416565', '416566', '416567', '416568', '416569', '416570', '416575', '416600', '416712', '416750']
    nosy_count = 6.0
    nosy_names = ['christian.heimes', 'ned.deily', 'pablogsal', 'miss-islington', 'erlendaasland', 'arhadthedev']
    pr_nums = ['29642', '29644', '29660', '29668', '29685', '29688', '29689', '29690', '29696', '29697', '29699', '29702', '29703', '29705', '29706', '29707', '29713', '29715', '29720', '29725', '29727', '29738', '29741', '29743', '29747', '29768', '29769', '29833', '29844', '29914', '29946', '29967', '29969', '31698', '32229', '32299', '32328']
    priority = None
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue45847'
    versions = ['Python 3.11']

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 19, 2021

    bpo-45573 added the PY_STDLIB_MOD() autoconf macro, Modules/Setup.stdlib.in template, and setup.py helper method addext().

    The macro sets up

    • MODULE_{NAME}_TRUE/FALSE conditional
    • MODULE_{NAME} variable with values yes, disabled, missing, or n/a
    • MODULE_{NAME}_CFLAGS
    • MODULE_{NAME}_LDFLAGS

    Additionally there is a MODULE_{NAME}_DEPS variable with dependency information.

    The Modules/Setup.stdlib.in template and addext() method consume the variables and set up extension compilation and linking. There is no need to look for headers or libraries in setup.py any more.

    Let's port all modules to the new approach.

    @tiran tiran added 3.11 build type-feature labels Nov 19, 2021
    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 19, 2021

    New changeset c8c21bd by Christian Heimes in branch 'main':
    bpo-45847: Port builtin hashlib extensions to PY_STDLIB_MOD (GH-29642)
    c8c21bd

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 20, 2021

    New changeset 5596909 by Christian Heimes in branch 'main':
    bpo-45847: Port _scproxy to PY_STDLIB_MOD (GH-29644)
    5596909

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 20, 2021

    New changeset f36c69a by Christian Heimes in branch 'main':
    bpo-45847: Port test modules to PY_STDLIB_MOD (GH-29660)
    f36c69a

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 21, 2021

    New changeset f201d26 by Christian Heimes in branch 'main':
    bpo-45847: Port grp, spwd, termios, resource, syslog to PY_STDLIB_MOD (GH-29668)
    f201d26

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 21, 2021

    New changeset 2afa1a1 by Christian Heimes in branch 'main':
    bpo-45847: Port codecs and unicodedata to PY_STDLIB_MOD (GH-29685)
    2afa1a1

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset 133c65a by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port array, _contextvars, math, and cmath to PY_STDLIB_MOD_SIMPLE (GH-29688)
    133c65a

    @miss-islington
    Copy link
    Contributor

    @miss-islington miss-islington commented Nov 22, 2021

    New changeset 718cee0 by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port _bisect, _heapq, _json, _pickle, _random, and _zoneinfo to PY_STDLIB_MOD_SIMPLE (GH-29689)
    718cee0

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Nov 22, 2021

    45 down, 35 to go.

    @miss-islington
    Copy link
    Contributor

    @miss-islington miss-islington commented Nov 22, 2021

    New changeset 39f7d2f by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port _lfprof, _opcode, _asyncio, _queue, _statistics, and _typing to PY_STDLIB_MOD_SIMPLE (GH-29690)
    39f7d2f

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset 29699a2 by Christian Heimes in branch 'main':
    bpo-45847: Various PY_STDLIB_MOD cleanups (GH-29697)
    29699a2

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset 5b946ca by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port fcntl to Py_STDLIB_MOD (GH-29696)
    5b946ca

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset b451673 by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port mmap, select, and _xxsubinterpreters to Py_STDLIB_MOD (GH-29703)
    b451673

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset d9cedab by Christian Heimes in branch 'main':
    bpo-45847: Port compression libs to PY_STDLIB_MOD (GH-29702)
    d9cedab

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset c6dec7e by Christian Heimes in branch 'main':
    bpo-45847: Port nis module to PY_STDLIB_MOD (GH-29699)
    c6dec7e

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    Not converted yet:

    readline
    _curses
    _curses_panel
    _crypt
    _socket
    _ssl
    _hashlib
    _dbm
    _gdbm
    _ctypes
    _multiprocessing
    _posixshmem
    _tkinter
    _uuid
    xxlimited
    xxlimited_35

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Nov 22, 2021

    _socket coming up...

    @miss-islington
    Copy link
    Contributor

    @miss-islington miss-islington commented Nov 22, 2021

    New changeset eee683c by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port audioop, _csv, and _posixsubprocess to PY_STDLIB_MOD_SIMPLE (GH-29705)
    eee683c

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    _crypt is powered by pkgconf libcrypt or libxcrypt on Linux. On my system and on Debian, libcrypt.pc is a symlink to libxcrypt.pc. Linux has crypt() and/or crypt_r() in <crypt.h>. On FreeBSD crypt_r() is in <unistd.h> and libc.

    _uuid needs similar special handling. It's <uuid/uuid.h>, -luuid, and uuid.pc on Linux. On BSD it's <uuid.h> and symbols are in libc.

    _readline uses either libreadline (readline.pc) or libeditline (libeditline.pc). It also needs special handling of tinfo and termcap on some platforms.

    ndbm, gdbm, and libdb have no pkgconf providers. My PR #73720 has some code to detect them in configure.

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset 0e1c2f3 by Christian Heimes in branch 'main':
    bpo-45847: port _struct to PY_STDLIB_MOD (GH-29706)
    0e1c2f3

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 22, 2021

    New changeset 2dc7d3d by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port xxlimited and xxlimited_35 to PY_STDLIB_MOD (GH-29707)
    2dc7d3d

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 23, 2021

    New changeset 758a23d by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Fix xxlimited and xxlimited_35 build conditions (GH-29715)
    758a23d

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 23, 2021

    New changeset d82f2ca by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port _socket to PY_STDLIB_MOD (GH-29713)
    d82f2ca

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Nov 23, 2021

    We are down to 9 missing modules:

    readline
    _curses
    _curses_panel
    _dbm
    _ctypes
    _multiprocessing
    _posixshmem
    _tkinter
    _uuid

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Mar 7, 2022

    Solved: Ubuntu is fine, we just need to treat LIBS and LDFLAGS with care in configure.ac. #75879 is updated with a fix.

    @miss-islington
    Copy link
    Contributor

    @miss-islington miss-islington commented Mar 31, 2022

    New changeset b36d222 by Erlend Egeberg Aasland in branch 'main':
    bpo-45847: Port _tkinter to PY_STDLIB_MOD (GH-31698)
    b36d222

    @asottile
    Copy link
    Mannequin

    @asottile asottile mannequin commented Apr 2, 2022

    this appears to break the tkinter extension for ubuntu bionic (18.04) -- I'm not entirely sure on the correct fix here but I get the following from trying to build there:

    2022-04-02T15:52:08.0910452Z Python build finished successfully!
    2022-04-02T15:52:08.0911924Z The necessary bits to build these optional modules were not found:
    2022-04-02T15:52:08.0913469Z _tkinter

    this is the tk I have available:

    root@f0dd06a3e87c:/# dpkg -l | grep libtk
    ii libtk8.6:amd64 8.6.8-4 amd64 Tk toolkit for Tcl and X11 v8.6 - run-time files

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Apr 2, 2022

    Please attach your config.log file. Did configure tell you that you are missing pkg-config?

    @asottile
    Copy link
    Mannequin

    @asottile asottile mannequin commented Apr 2, 2022

    the tk-dev package on ubuntu bionic does not ship with a pkg-config file for tk so it does not build properly there:

    root@f0dd06a3e87c:/cpython# dpkg -L tk8.6-dev | grep pc
    root@f0dd06a3e87c:/cpython# 
    

    (a note: bionic reaches end of life in april 2023 so it is likely to still see significant use until then)

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Apr 2, 2022

    Could you please open a distro bug with Ubuntu and report the issue? We require a pkg-config file for TCL/TK.

    @asottile
    Copy link
    Mannequin

    @asottile asottile mannequin commented Apr 2, 2022

    I could, but it's very unlikely to get fixed given I believe 18.04 is in security-only fixes and backporting a pkg-config file seems unlikely

    this worked two days ago before this patch

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Apr 2, 2022

    As I said already, we require a pkg-config file for TCL/TK detection. It turned out to be too painful and too complicated to implement manual TCL/TK detection in configure.ac. Erlend and I tried and eventually gave up.

    If your platform does not provide the pkg-config files, then you need to work around the problem or contribute a patch.

    @tiran
    Copy link
    Member Author

    @tiran tiran commented Apr 2, 2022

    PS: Check out ./configure --help

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Apr 2, 2022

    Anthony: you should be able to build the _tkinter by manually specifying the compiler and linker flags using the TCLTK_CFLAGS and TCLTK_LIBS environment variables. AFAICS, the flags provided by pkgconfig in Ubuntu 20.04 should work well in 18.04 (possibly with minor adjustments; I didn't check).

    @ned-deily
    Copy link
    Member

    @ned-deily ned-deily commented Apr 5, 2022

    New changeset 5a7506d by Oleg Iarygin in branch 'main':
    Fix "Contributed ... in bpo-bpo-45847" (GH-32299)
    5a7506d

    @ned-deily
    Copy link
    Member

    @ned-deily ned-deily commented Apr 5, 2022

    New changeset a0c7004 by Ned Deily in branch 'main':
    bpo-45847: Adapt macOS installer build to use new tkinter configure vars (GH-32328)
    a0c7004

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Apr 14, 2022

    Regarding _ctypes: are we actually using the bundled libffi anymore?

    $ ls  Modules/_ctypes/libffi_osx 
    LICENSE		README		README.pyobjc	ffi.c		include		powerpc		types.c		x86
    $ grep -r libffi_osx *
    Tools/c-analyzer/cpython/_parser.py:#Modules/_ctypes/libffi_osx/*.c
    Tools/scripts/patchcheck.py:EXCLUDE_DIRS = [os.path.join('Modules', '_ctypes', 'libffi_osx'),

    @erlend-aasland
    Copy link
    Contributor

    @erlend-aasland erlend-aasland commented Apr 14, 2022

    FTR, remaining modules:

    • _ctypes (WIP)
    • _curses
    • _curses_panel
    • _dbm
    • readline

    erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Apr 17, 2022
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 9, 2022
    (cherry picked from commit 269e726)
    
    Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
    miss-islington added a commit that referenced this issue May 9, 2022
    (cherry picked from commit 269e726)
    
    Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
    @AA-Turner AA-Turner added the 3.12 label Jun 7, 2022
    miss-islington pushed a commit that referenced this issue Jun 26, 2022
    Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
    
    Automerge-Triggered-By: GH:tiran
    tiran added a commit to tiran/cpython that referenced this issue Jun 26, 2022
    It makes it easier to look for module states in sysconfig without
    special casing suffixes "_CFLAGS|, "_DEPS", "_LDFLAGS", "_OBJS",
    and "CTYPES_MALLOC_CLOSURE".
    tiran added a commit to tiran/cpython that referenced this issue Jun 26, 2022
    It makes it easier to look for module states in sysconfig without
    special casing suffixes "_CFLAGS", "_DEPS", "_LDFLAGS", "_OBJS",
    and "CTYPES_MALLOC_CLOSURE".
    miss-islington pushed a commit that referenced this issue Jun 27, 2022
    It makes it easier to look for module states in sysconfig without
    special casing suffixes "_CFLAGS", "_DEPS", "_LDFLAGS", "_OBJS",
    and "CTYPES_MALLOC_CLOSURE".
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 3.12 build type-feature
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants