#5 Add the python3.13-freethreading and python3.13-freethreading-debug packages
Merged 2 years ago by churchyard. Opened 2 years ago by churchyard.
rpms/ churchyard/python3.13 nogil  into  rawhide

file modified
+182 -10
@@ -17,7 +17,7 @@ 

  %global prerel a2

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

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

- Release: 1%{?dist}

+ Release: 2%{?dist}

  License: Python-2.0.1

  

  
@@ -136,6 +136,16 @@ 

  # (the -debug subpackages)

  %bcond_without debug_build

  

+ # Extra build without GIL, the freethreading PEP 703 provisional way

+ # (the -freethreading subpackage)

+ # support for the excluded arches is being added upstream and is expected to land in 3.13.0a3

+ # https://github.com/python/cpython/issues/112535

+ %ifnarch ppc64le s390x

+ %bcond_without freethreading_build

Could we use the new bcond syntax here or do you expect we could be in need of the legacy definition?

+ %else

+ %bcond_with freethreading_build

+ %endif

+ 

  # Support for the GDB debugger

  %bcond_without gdb_hooks

  
@@ -168,11 +178,15 @@ 

  

  # ABIFLAGS, LDVERSION and SOABI are in the upstream configure.ac

  # See PEP 3149 for some background: http://www.python.org/dev/peps/pep-3149/

- %global ABIFLAGS_optimized %{nil}

- %global ABIFLAGS_debug     d

+ %global ABIFLAGS_optimized           %{nil}

+ %global ABIFLAGS_debug               d

+ %global ABIFLAGS_freethreading       t

+ %global ABIFLAGS_freethreading_debug td

  

- %global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized}

- %global LDVERSION_debug     %{pybasever}%{ABIFLAGS_debug}

+ %global LDVERSION_optimized           %{pybasever}%{ABIFLAGS_optimized}

+ %global LDVERSION_debug               %{pybasever}%{ABIFLAGS_debug}

+ %global LDVERSION_freethreading       %{pybasever}%{ABIFLAGS_freethreading}

+ %global LDVERSION_freethreading_debug %{pybasever}%{ABIFLAGS_freethreading_debug}

  

  # We use the upstream arch triplets, we convert them from %%{_arch}-linux%%{_gnu}

  %global platform_triplet %{expand:%(echo %{_arch}-linux%{_gnu} | sed -E \\
@@ -180,8 +194,10 @@ 

      -e 's/^mips64(el)?-linux-gnu$/mips64\\1-linux-gnuabi64/' \\

      -e 's/^ppc(64)?(le)?-linux-gnu$/powerpc\\1\\2-linux-gnu/')}

  

- %global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}-%{platform_triplet}

- %global SOABI_debug     cpython-%{pyshortver}%{ABIFLAGS_debug}-%{platform_triplet}

+ %global SOABI_optimized           cpython-%{pyshortver}%{ABIFLAGS_optimized}-%{platform_triplet}

+ %global SOABI_debug               cpython-%{pyshortver}%{ABIFLAGS_debug}-%{platform_triplet}

+ %global SOABI_freethreading       cpython-%{pyshortver}%{ABIFLAGS_freethreading}-%{platform_triplet}

+ %global SOABI_freethreading_debug cpython-%{pyshortver}%{ABIFLAGS_freethreading_debug}-%{platform_triplet}

  

  # All bytecode files are in a __pycache__ subdirectory, with a name

  # reflecting the version of the bytecode.
@@ -202,8 +218,10 @@ 

  # (if these get out of sync, the payload of the libs subpackage will fail

  # and halt the build)

  %global py_SOVERSION 1.0

- %global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION}

- %global py_INSTSONAME_debug     libpython%{LDVERSION_debug}.so.%{py_SOVERSION}

+ %global py_INSTSONAME_optimized           libpython%{LDVERSION_optimized}.so.%{py_SOVERSION}

+ %global py_INSTSONAME_debug               libpython%{LDVERSION_debug}.so.%{py_SOVERSION}

+ %global py_INSTSONAME_freethreading       libpython%{LDVERSION_freethreading}.so.%{py_SOVERSION}

+ %global py_INSTSONAME_freethreading_debug libpython%{LDVERSION_freethreading_debug}.so.%{py_SOVERSION}

  

  # Disable automatic bytecompilation. The python3 binary is not yet be

  # available in /usr/bin when Python is built. Also, the bytecompilation fails
@@ -659,6 +677,67 @@ 

  %endif # with debug_build

  

  

+ %if %{with freethreading_build}

+ # This deliberately does not use the %%{pkgname}- prefix,

+ # we want to call this python3.X-threading even when built as a main Python.

+ # At least until the PEP 703 build remains provisional.

+ %package -n python%{pybasever}-freethreading

+ Summary: Free Threading (PEP 703) version of the Python runtime

+ 

+ # The freethreading build is an all-in-one package version of the regular build, and

+ # 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: %{pkgname}%{?_isa} = %{version}-%{release}

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

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

+ Requires: %{pkgname}-test%{?_isa} = %{version}-%{release}

+ Requires: %{pkgname}-tkinter%{?_isa} = %{version}-%{release}

+ Requires: %{pkgname}-idle%{?_isa} = %{version}-%{release}

+ 

+ %description -n python%{pybasever}-freethreading

+ The provisional Free Threading (PEP 703) build of Python.

+ 

+ CPython’s global interpreter lock (“GIL”) prevents multiple threads from

+ executing Python code at the same time. The GIL is an obstacle to using

+ multi-core CPUs from Python efficiently.

+ 

+ This build of Python is built with the --disable-gil option.

+ It lets the interpreter run Python code without the global interpreter lock

+ and with the necessary changes needed to make the interpreter thread-safe.

+ %endif # with freethreading_build

+ 

+ 

+ %if %{with freethreading_build} && %{with debug_build}

+ %package -n python%{pybasever}-freethreading-debug

+ Summary: Free Threading (PEP 703) version of the Python runtime (debug build)

+ 

+ # The debug build is an all-in-one package version of the regular build, and

+ # 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: %{pkgname}%{?_isa} = %{version}-%{release}

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

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

+ Requires: %{pkgname}-test%{?_isa} = %{version}-%{release}

+ Requires: %{pkgname}-tkinter%{?_isa} = %{version}-%{release}

+ Requires: %{pkgname}-idle%{?_isa} = %{version}-%{release}

+ 

+ %description -n python%{pybasever}-freethreading-debug

+ The provisional Free Threading (PEP 703) build of Python. Debug build.

+ 

+ CPython’s global interpreter lock (“GIL”) prevents multiple threads from

+ executing Python code at the same time. The GIL is an obstacle to using

+ multi-core CPUs from Python efficiently.

+ 

+ This build of Python is built with the --disable-gil option.

+ It lets the interpreter run Python code without the global interpreter lock

+ and with the necessary changes needed to make the interpreter thread-safe.

+ 

+ This package provides a version of the Python runtime with numerous debugging

+ features enabled, aimed at advanced Python users such as developers of Python

+ extension modules.

+ %endif # with freethreading_build && debug_build

+ 

+ 

  # ======================================================

  # The prep phase of the build:

  # ======================================================
@@ -820,6 +899,18 @@ 

    "--without-ensurepip %{optimizations_flag}" \

    ""

  

+ %if %{with freethreading_build} && %{with debug_build}

+ BuildPython freethreading-debug \

+   "--without-ensurepip --with-pydebug --disable-gil" \

+   "-O0 -Wno-cpp"

+ %endif # with freethreading_build && debug_build

+ 

+ %if %{with freethreading_build}

+ BuildPython freethreading \

+   "--without-ensurepip %{optimizations_flag} --disable-gil" \

+   ""

+ %endif # with freethreading_build

+ 

  # ======================================================

  # Installing the built code:

  # ======================================================
@@ -918,8 +1009,16 @@ 

    echo FINISHED: INSTALL OF PYTHON FOR CONFIGURATION: $ConfName

  }

  

- # Install the "debug" build first; any common files will be overridden with

+ # Install the "freethreading" and "debug" builds first; any common files will be overridden with

  # later builds

+ %if %{with freethreading_build} && %{with debug_build}

+ # Now the freethreading debug build:

+ InstallPython freethreading-debug \

+   %{py_INSTSONAME_freethreading_debug} \

+   "" \

+   %{LDVERSION_freethreading_debug}

+ %endif # with freethreading_build && debug_build

+ 

  %if %{with debug_build}

  InstallPython debug \

    %{py_INSTSONAME_debug} \
@@ -927,6 +1026,14 @@ 

    %{LDVERSION_debug}

  %endif # with debug_build

  

+ %if %{with freethreading_build}

+ # Now the freethreading optimized build:

+ InstallPython freethreading \

+   %{py_INSTSONAME_freethreading} \

+   "" \

+   %{LDVERSION_freethreading}

+ %endif # with freethreading_build

+ 

  # Now the optimized build:

  InstallPython optimized \

    %{py_INSTSONAME_optimized} \
@@ -1160,6 +1267,12 @@ 

  CheckPython debug

  %endif # with debug_build

  CheckPython optimized

+ %if %{with freethreading_build} && %{with debug_build}

+ CheckPython freethreading-debug

+ %endif # with freethreading_build && debug_build

+ %if %{with freethreading_build}

+ CheckPython freethreading

+ %endif # with freethreading_build

  

  %endif # with tests

  
@@ -1471,6 +1584,60 @@ 

  

  %endif # with debug_build

  

+ %if %{with freethreading_build}

+ %files -n python%{pybasever}-freethreading

+ # Analog of the core subpackage's files:

+ %{_bindir}/python%{LDVERSION_freethreading}

+ 

+ # Analog to the -libs subpackage's files:

+ %{_libdir}/%{py_INSTSONAME_freethreading}

+ 

+ # Analog of the libs, test, and tkinter extension modules:

+ %extension_modules %{SOABI_freethreading}

+ %extension_modules_test %{SOABI_freethreading}

+ %{dynload_dir}/_tkinter.%{SOABI_freethreading}.so

+ 

+ # Analog of the -devel subpackage's files:

+ %{pylibdir}/config-%{LDVERSION_freethreading}-%{platform_triplet}/

+ %{_includedir}/python%{LDVERSION_freethreading}/

+ %{_bindir}/python%{LDVERSION_freethreading}-config

+ %{_bindir}/python%{LDVERSION_freethreading}-*-config

+ %{_libdir}/libpython%{LDVERSION_freethreading}.so

+ %{_libdir}/pkgconfig/python-%{LDVERSION_freethreading}.pc

+ %{_libdir}/pkgconfig/python-%{LDVERSION_freethreading}-embed.pc

+ 

+ %{pylibdir}/_sysconfigdata_%{ABIFLAGS_freethreading}_linux_%{platform_triplet}.py

+ %{pylibdir}/__pycache__/_sysconfigdata_%{ABIFLAGS_freethreading}_linux_%{platform_triplet}%{bytecode_suffixes}

+ 

+ %endif # with freethreading_build

+ 

+ %if %{with freethreading_build} && %{with debug_build}

+ %files -n python%{pybasever}-freethreading-debug

+ # Analog of the core subpackage's files:

+ %{_bindir}/python%{LDVERSION_freethreading_debug}

+ 

+ # Analog to the -libs subpackage's files:

+ %{_libdir}/%{py_INSTSONAME_freethreading_debug}

+ 

+ # Analog of the libs, test, and tkinter extension modules:

+ %extension_modules %{SOABI_freethreading_debug}

+ %extension_modules_test %{SOABI_freethreading_debug}

+ %{dynload_dir}/_tkinter.%{SOABI_freethreading_debug}.so

+ 

+ # Analog of the -devel subpackage's files:

+ %{pylibdir}/config-%{LDVERSION_freethreading_debug}-%{platform_triplet}/

+ %{_includedir}/python%{LDVERSION_freethreading_debug}/

+ %{_bindir}/python%{LDVERSION_freethreading_debug}-config

+ %{_bindir}/python%{LDVERSION_freethreading_debug}-*-config

+ %{_libdir}/libpython%{LDVERSION_freethreading_debug}.so

+ %{_libdir}/pkgconfig/python-%{LDVERSION_freethreading_debug}.pc

+ %{_libdir}/pkgconfig/python-%{LDVERSION_freethreading_debug}-embed.pc

+ 

+ %{pylibdir}/_sysconfigdata_%{ABIFLAGS_freethreading_debug}_linux_%{platform_triplet}.py

+ %{pylibdir}/__pycache__/_sysconfigdata_%{ABIFLAGS_freethreading_debug}_linux_%{platform_triplet}%{bytecode_suffixes}

+ 

+ %endif # with freethreading_build && debug_build

+ 

  # We put the debug-gdb.py file inside /usr/lib/debug to avoid noise from ldconfig

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

  #
@@ -1492,6 +1659,11 @@ 

  # ======================================================

  

  %changelog

+ * Tue Dec 05 2023 Miro Hrončok <[email protected]> - 3.13.0~a2-2

+ - Add the python3.13-freethreading and python3.13-freethreading-debug packages

+ - See https://peps.python.org/pep-0703/

+ - ppc64le and s390x are excluded for now, support is expected in 3.13.0a3

+ 

  * Fri Nov 24 2023 Karolina Surma <[email protected]> - 3.13.0~a2-1

  - Update to Python 3.13.0a2

  

file modified
+5 -5
@@ -52,10 +52,10 @@ 

      # manual pages

      'no-manual-page-for-binary (idle|pydoc|pyvenv|2to3|python3?-debug|pathfix|msgfmt|pygettext)',

      'no-manual-page-for-binary python3?.*-config$',

-     'no-manual-page-for-binary python3\.\d+dm?$',

+     'no-manual-page-for-binary python3\.\d+t?dm?$',

  

      # missing documentation from subpackages

-     '^python3(\.\d+)?-(debug|tkinter|test|idle)\.[^:]+: (E|W): no-documentation',

+     '^python3(\.\d+)?-(freethreading(-debug)?|debug|tkinter|test|idle)\.[^:]+: (E|W): no-documentation',

  

      # platform python is obsoleted, but not provided

      'obsolete-not-provided platform-python',
@@ -77,13 +77,13 @@ 

      # this is OK for F28+

      'library-without-ldconfig-post',

  

-     # debug package contains devel and non-devel files

-     'python3(\.\d+)?-debug\.[^:]+: (E|W): (non-)?devel-file-in-(non-)?devel-package',

+     # freethreading/debug package contains devel and non-devel files

+     'python3(\.\d+)?-(freethreading(-debug)?|debug)\.[^:]+: (E|W): (non-)?devel-file-in-(non-)?devel-package',

  

      # this goes to other subpackage, hence not actually dangling

      'dangling-relative-symlink /usr/bin/python python3',

      'dangling-relative-symlink /usr/share/man/man1/python\.1\.gz python3\.1\.gz',

-     'dangling-relative-symlink /usr/lib(64)?/pkgconfig/python-3\.\d+dm?(-embed)?\.pc python-3\.\d+(-embed)?\.pc',

+     'dangling-relative-symlink /usr/lib(64)?/pkgconfig/python-3\.\d+t?d?m?(-embed)?\.pc python-3\.\d+t?(-embed)?\.pc',

  

      # the python-unversioned-command package contains dangling symlinks by design

      '^python-unversioned-command\.[^:]+: (E|W): dangling-relative-symlink (/usr/bin/python \./python3|/usr/share/man/man1/python\.1\S* ./python3\.1\S*)$',

no initial comment

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/7497f25efa5a4898bf55361a28066257

1 new commit added

  • fixup! WIP add a NOGIL build
2 years ago

1 new commit added

  • fixup! fixup! WIP add a NOGIL build
2 years ago

1 new commit added

  • fixup! fixup! fixup! WIP add a NOGIL build
2 years ago

note to self: the comments in the %files sections need updating

Blast form the past, a tools subpackage :scream:

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/718f17ee5d64491191b06a3be3e787cd

Cool to see this. I think we should give up on the "free threading" name. I understand where it comes from, but it's awkward to say or write… I'm pretty sure everybody will end up saying "no gil", just like the config option is named. Thus I think the subpackage should have the nogil suffix instead.

I'd like to follow the upstream consensus here. Unfortunately, the discussion wasn't very active.

AFAIK, the mainthing blocking this is the name of the feature. I asked the Python Steering Council to decide that: https://github.com/python/steering-council/issues/221

rebased onto 3839531a8950b00608b77edc78f9e4d09a705fd8

2 years ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/0411455f0d33476fbea10c95a89b3f43

This now no longer builds :(

Seems to be s390x and ppc64le only.

Both s390x and ppc64le fail with:

/builddir/build/BUILD/Python-3.13.0a2/Include/object.h: In function ‘_Py_ThreadId’:
/builddir/build/BUILD/Python-3.13.0a2/Include/object.h:265:5: error: #error "define _Py_ThreadId for this platform"
  265 |   # error "define _Py_ThreadId for this platform"
      |     ^~~~~

https://github.com/python/cpython/blob/v3.13.0a2/Include/object.h#L265

This was added in https://github.com/python/cpython/commit/6dfb8fe0236718e9afc8136ff2b58dcfbc182022#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a

static inline uintptr_t
_Py_ThreadId(void)
{
    uintptr_t tid;
#if defined(_MSC_VER) && defined(_M_X64)
    tid = __readgsqword(48);
#elif defined(_MSC_VER) && defined(_M_IX86)
    tid = __readfsdword(24);
#elif defined(_MSC_VER) && defined(_M_ARM64)
    tid = __getReg(18);
#elif defined(__i386__)
    __asm__("movl %%gs:0, %0" : "=r" (tid));  // 32-bit always uses GS
#elif defined(__MACH__) && defined(__x86_64__)
    __asm__("movq %%gs:0, %0" : "=r" (tid));  // x86_64 macOSX uses GS
#elif defined(__x86_64__)
   __asm__("movq %%fs:0, %0" : "=r" (tid));  // x86_64 Linux, BSD uses FS
#elif defined(__arm__)
    __asm__ ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tid));
#elif defined(__aarch64__) && defined(__APPLE__)
    __asm__ ("mrs %0, tpidrro_el0" : "=r" (tid));
#elif defined(__aarch64__)
    __asm__ ("mrs %0, tpidr_el0" : "=r" (tid));
#else
  # error "define _Py_ThreadId for this platform"
#endif
  return tid;
}

ccing @vstinner (the upstream maintainer for both those architectures) and @sharkcz (an expert).

What do I do here, other than disabling the freethreding build on those architectures?

1 new commit added

  • Don't build the freethreding packages on ppc64le/s390x for now
2 years ago

The "__builtin_thread_pointer" should be used preferably for all platforms where it exists ...

The "__builtin_thread_pointer" should be used preferably for all platforms where it exists ...

That seems to be the upstream conclusion as well.

Dan, sorry for summoning you immediately, I should have searched first.

no problem :-) I am still surprised why people are (re-)inventing the wheel all time ...

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/80ff37ffb2df497a916745a057c9f4da

rpminspect says:

Subpackage python3.13 on x86_64 carries 'Requires: libpython3.13t.so.1.0()(64bit)' which comes from subpackage python3.13-freethreading but does not carry an explicit package version requirement. Please add 'Requires: python3.13-freethreading = %{version}-%{release}' to the spec file to avoid the need to test interoperability between various combinations of old and new subpackages.

This is not intended:

$ rpm -qRp python3.13-3.13.0~a2-2.fc40.x86_64.rpm 
...
libpython3.13t.so.1.0()(64bit)
...

I suppose /usr/bin/python3.13 is now the freethreading version :/

$ rpm2cpio python3.13-3.13.0~a2-2.fc40.x86_64.rpm | cpio -idmv
./usr/bin/pydoc3.13
./usr/bin/python3.13
./usr/lib/.build-id
./usr/lib/.build-id/e0
./usr/lib/.build-id/e0/c4a5ea0aaf0c23bc60aca1842702b6a42d28b2
./usr/share/doc/python3.13
./usr/share/doc/python3.13/README.rst
./usr/share/man/man1/python3.13.1.gz
67 blocks

$ ldd ./usr/bin/python3.13
    linux-vdso.so.1 (0x00007ffd9ffa9000)
    libpython3.13t.so.1.0 => not found
    libc.so.6 => /lib64/libc.so.6 (0x00007f4dc22ff000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4dc2500000)

$ head -n1 ./usr/bin/pydoc3.13
#!/usr/bin/python3.13t

1 new commit added

  • fixup! Add the python3.13-freethreading and python3.13-freethreading-debug packages
2 years ago

1 new commit added

  • Update rpmlint.toml with regards to the freethreading builds
2 years ago

4 new commits added

  • Update rpmlint.toml with regards to the freethreading builds
  • fixup! Add the python3.13-freethreading and python3.13-freethreading-debug packages
  • Don't build the freethreding packages on ppc64le/s390x for now
  • Add the python3.13-freethreading and python3.13-freethreading-debug packages
2 years ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/d2bf132881e24780a1ec19c12704df07

rebased onto 84d78b3

2 years ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/3202fcff435c4f928aa61c6d4bf024fb

Could we use the new bcond syntax here or do you expect we could be in need of the legacy definition?

I didn't want to mix the old and new syntaxes in one spec file. We can probably switch to a new bcond syntax later, but I wanted to preserve the spec similarity with python3.12 for now and wait for python3.12 to be imported into RHEL 8 before changing the syntax in both.

  • description of the new packages feels sufficient to me
  • the new subpackages contain the respective files, nothing's left behind
  • packages are installable, interpreters work for basic operations (I haven't tested anything related to freethreading itself)
  • bconds work as designed (--without debug_build does not produce freethreading-debug, the excluded architectures don't build freethreading at all)
  • /usr/bin/python3.13 is NOT the freethreading version - this is expected
  • commits look sane in scope & contents
    All looks good to me.

Will you open PRs for the released Fedoras too?

Pull-Request has been merged by churchyard

2 years ago
Metadata