# ====================== # Production build conditionals # ====================== # Bootstrap OFF - this is the production build %bcond bootstrap 0 # Use bundled wheels (no rpmwheels on AL2023) %bcond rpmwheels 0 # PGO optimizations - ENABLED for production %bcond optimizations 1 # Run tests - disabled for now (enable in future) %bcond tests 0 # ================== # Top-level metadata # ================== %global _trivial .0 %global _buildid .1 %global pybasever 3.15 %global pyshortver 315 # This is NOT the main Python - it's a namespaced alternative %bcond main_python 0 # Use gcc14 toolchain %global toolchain gcc14 # _buildid to track bootstrap vs production builds Name: python%{pybasever} Summary: Version %{pybasever} of the Python interpreter URL: https://www.python.org/ %global general_version %{pybasever}.0 %global prerel b3 %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} Release: 1%{?dist}%{?_trivial}%{?_buildid} License: Python-2.0.1 # PYC magic number from Include/internal/pycore_magic_number.h %global magic_number 3666 # No debug build for production (keep it simple) %bcond debug_build 0 # No freethreading build for production (keep simple for now) %bcond freethreading_build 0 # JIT disabled for now - clang20 has issues building stencils for 3.15b3 # Can be re-enabled with prebuilt stencils or clang21 %bcond jit 0 # Main interpreter loop optimization %bcond computed_gotos 1 # ===================== # General global macros # ===================== %global pkgname python%{pybasever} %global exename python%{pybasever} %global python3_pkgversion %{pybasever} # Bundled wheel versions %global pip_version 26.1.2 %global setuptools_version 79.0.1 %global pip_bundled_provides %{expand: Provides: bundled(python3dist(pip)) = %{pip_version} Provides: bundled(python3dist(cachecontrol)) = 0.14.4 Provides: bundled(python3dist(certifi)) = 2026.2.25 Provides: bundled(python3dist(distlib)) = 0.4 Provides: bundled(python3dist(distro)) = 1.9 Provides: bundled(python3dist(idna)) = 3.11 Provides: bundled(python3dist(msgpack)) = 1.1.2 Provides: bundled(python3dist(packaging)) = 26.2 Provides: bundled(python3dist(platformdirs)) = 4.5.1 Provides: bundled(python3dist(pygments)) = 2.19.2 Provides: bundled(python3dist(pyproject-hooks)) = 1.2 Provides: bundled(python3dist(requests)) = 2.33.1 Provides: bundled(python3dist(resolvelib)) = 1.2.1 Provides: bundled(python3dist(rich)) = 14.2 Provides: bundled(python3dist(setuptools)) = 70.3 Provides: bundled(python3dist(tomli)) = 2.3.1 Provides: bundled(python3dist(tomli-w)) = 1.2 Provides: bundled(python3dist(truststore)) = 0.10.4 Provides: bundled(python3dist(urllib3)) = 2.6.3 } %global setuptools_bundled_provides %{expand: Provides: bundled(python3dist(setuptools)) = %{setuptools_version} Provides: bundled(python3dist(wheel)) = 0.45.1 Provides: bundled(python3dist(packaging)) = 24.2 Provides: bundled(python3dist(more-itertools)) = 10.3 Provides: bundled(python3dist(tomli)) = 2.0.1 Provides: bundled(python3dist(typing-extensions)) = 4.12.2 } # ABIFLAGS and LDVERSION %global ABIFLAGS_optimized %{nil} %global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized} %global pylibdir %{_libdir}/python%{pybasever} %global dynload_dir %{pylibdir}/lib-dynload # Arch triplet %global platform_triplet %{expand:%(echo %{_arch}-linux%{_gnu} | sed -E \\ -e 's/^arm(eb)?-linux-gnueabi$/arm\\1-linux-gnueabihf/' \\ -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} # libpython DSO version %global py_SOVERSION 1.0 %global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION} # Bytecode suffix %global bytecode_suffixes .cpython-%{pyshortver}*.pyc # Disable automatic bytecompilation %undefine py_auto_byte_compile # Exclude test archive data from shebang mangling (they have specific data offsets) %global __brp_mangle_shebangs_exclude_from ^%{pylibdir}/test/archivetestdata/exe_with_.*$ # Filter auto-requires for /usr/bin/python3 and python(abi) %global __requires_exclude ^(/usr/bin/python3|python\\(abi\\)) # ======================= # Build-time requirements # ======================= BuildRequires: autoconf BuildRequires: bluez-libs-devel BuildRequires: bzip2-devel BuildRequires: expat-devel BuildRequires: findutils BuildRequires: gcc14 BuildRequires: gcc14-c++ BuildRequires: gdbm-devel BuildRequires: glibc-devel BuildRequires: libffi-devel BuildRequires: libuuid-devel BuildRequires: libzstd-devel BuildRequires: make BuildRequires: mpdecimal-devel BuildRequires: ncurses-devel BuildRequires: openssl-devel BuildRequires: pkgconfig BuildRequires: python-rpm-macros BuildRequires: readline-devel BuildRequires: amazon-rpm-config BuildRequires: sqlite-devel BuildRequires: systemtap-sdt-devel BuildRequires: tcl-devel BuildRequires: tk-devel BuildRequires: tar BuildRequires: xz-devel BuildRequires: zlib-devel # Production-only BuildRequires (not needed for bootstrap) # python3.15 itself for regen-all BuildRequires: python%{pybasever} # For proper automatic provides/requires generation BuildRequires: python3-rpm-generators # JIT compiler (clang20 from COPR/AL2023) %if %{with jit} BuildRequires: clang20 BuildRequires: llvm20 %endif # ======================= # Source code and patches # ======================= Source0: %{url}ftp/python/%{general_version}/Python-%{upstream_version}.tar.xz Source8: check-pyc-timestamps.py # 00251 - Change user install location (Fedora downstream) Patch251: 00251-change-user-install-location.patch # 00466 - Skip tests not working with older expat version Patch466: 00466-downstream-only-skip-tests-not-working-with-older-expat-version.patch # ========================================== # Descriptions and metadata for subpackages # ========================================== Provides: python%{pyshortver} = %{version}-%{release} Requires: %{pkgname}-libs%{?_isa} = %{version}-%{release} %description Python %{pybasever} interpreter - production build for AL2023. This is a namespaced installation that does not conflict with the system Python. Built with PGO optimizations and JIT support. %package -n %{pkgname}-libs Summary: Python %{pybasever} runtime libraries %pip_bundled_provides %setuptools_bundled_provides Provides: bundled(mimalloc) = 2.12 License: Python-2.0.1 AND MIT AND BSD-3-Clause AND MIT-CMU AND HPND-SMC AND BSD-2-Clause AND dtoa AND Apache-2.0 AND ISC AND LGPL-2.1-only AND MPL-2.0 AND (Apache-2.0 OR BSD-2-Clause) Recommends: %{pkgname}%{?_isa} %description -n %{pkgname}-libs This package contains runtime libraries for use by Python %{pybasever}. %package -n %{pkgname}-devel Summary: Libraries and header files needed for Python %{pybasever} development License: Python-2.0.1 AND MIT Requires: %{pkgname} = %{version}-%{release} Requires: %{pkgname}-libs%{?_isa} = %{version}-%{release} %description -n %{pkgname}-devel This package contains the header files and configuration needed to compile Python %{pybasever} extension modules. %package -n %{pkgname}-idle Summary: A basic graphical development environment for Python %{pybasever} Requires: %{pkgname} = %{version}-%{release} Requires: %{pkgname}-tkinter = %{version}-%{release} %description -n %{pkgname}-idle IDLE is Python's Integrated Development and Learning Environment. %package -n %{pkgname}-tkinter Summary: A GUI toolkit for Python %{pybasever} Requires: %{pkgname} = %{version}-%{release} %description -n %{pkgname}-tkinter The Tkinter (Tk interface) library for Python %{pybasever}. %package -n %{pkgname}-test Summary: The self-test suite for Python %{pybasever} Requires: %{pkgname} = %{version}-%{release} Requires: %{pkgname}-libs%{?_isa} = %{version}-%{release} %description -n %{pkgname}-test The self-test suite for the Python %{pybasever} interpreter. # ====================================================== # Prep # ====================================================== %prep %autosetup -n Python-%{upstream_version} -p1 # Remove bundled libraries to use system copies rm -r Modules/expat rm -r Modules/_decimal/libmpdec # Remove files that should be generated by the build rm -f configure pyconfig.h.in # Patch out the version requirement on autoconf 2.72 # AL2023 has autoconf 2.69 sed -i "s/AC_PREREQ(\[2\.72\])/AC_PREREQ([2.69])/" configure.ac # Fix ambiguous python shebang in rot_13.py # brp-mangle-shebangs requires explicit python2 or python3 sed -i '1s|^#!/usr/bin/env python$|#!/usr/bin/python3|' Lib/encodings/rot_13.py # ====================================================== # Build # ====================================================== %build # Tell configure to not use git export HAS_GIT=not-found # Regenerate configure script autoconf autoheader # Remember the current directory topdir=$(pwd) # Use gcc14 export CC=gcc14-gcc export CXX=gcc14-g++ %if %{with jit} # JIT needs clang - make clang-20 available as 'clang' mkdir -p _jit_bin ln -sf /usr/bin/clang-20 _jit_bin/clang ln -sf /usr/bin/clang++-20 _jit_bin/clang++ export PATH="$(pwd)/_jit_bin:$PATH" export LLVM_VERSION=20 %endif # Set compiler/linker flags export CFLAGS="%{optflags} -fPIC -fwrapv" export CFLAGS_NODIST="%{optflags} -D_GNU_SOURCE -fPIC -fwrapv" export CXXFLAGS="%{optflags}" export CPPFLAGS="$(pkg-config --cflags-only-I libffi)" export OPT="%{optflags}" export CFLAGS="$CFLAGS $(pkg-config --cflags openssl)" export LDFLAGS="%{build_ldflags} $(pkg-config --libs-only-L openssl)" export LDFLAGS_NODIST="%{build_ldflags} -g $(pkg-config --libs-only-L openssl)" # Build optimized (non-debug) configuration only ConfName=optimized ConfDir=build/$ConfName mkdir -p $ConfDir pushd $ConfDir %global _configure $topdir/configure %configure \ --with-platlibdir=%{_lib} \ --enable-ipv6 \ --enable-shared \ --with-computed-gotos=yes \ --with-dbmliborder=gdbm:ndbm:bdb \ --with-system-expat \ --with-system-libmpdec \ --enable-loadable-sqlite-extensions \ --with-dtrace \ --with-lto \ --with-ssl-default-suites=openssl \ --without-static-libpython \ --without-ensurepip \ %if %{with optimizations} --enable-optimizations \ %else --disable-optimizations \ %endif %if %{with jit} --enable-experimental-jit=yes-off \ %endif %{nil} # regen-all needs a working python3.15 %if %{without bootstrap} %make_build \ EXTRA_CFLAGS="-O2" \ CFLAGS_NODIST="$CFLAGS_NODIST -O2" \ GITVERSION="true" \ GITTAG="echo '%{version}-%{release}.%{_arch}'" \ regen-all PYTHON_FOR_REGEN="python%{pybasever}" %endif %make_build \ EXTRA_CFLAGS="-O2" \ CFLAGS_NODIST="$CFLAGS_NODIST -O2" \ GITVERSION="true" \ GITTAG="echo '%{version}-%{release}.%{_arch}'" popd # ====================================================== # Install # ====================================================== %install topdir=$(pwd) # Use gcc14 export CC=gcc14-gcc export CXX=gcc14-g++ ConfDir=build/optimized pushd $ConfDir %make_install \ EXTRA_CFLAGS="-O2" \ CFLAGS_NODIST="%{optflags} -D_GNU_SOURCE -fPIC -fwrapv -O2" \ GITVERSION="true" \ GITTAG="echo '%{version}-%{release}.%{_arch}'" popd # Do NOT run ensurepip during install. # The ensurepip module (with bundled pip wheel) is installed as part of stdlib. # Users and the grand-bundle spec can invoke: python3.15 -m ensurepip # This avoids buildroot path contamination in pip's shebang. # Fix shebangs that may contain build-tree paths find %{buildroot}%{_bindir} -type f -exec \ sed -i '1s|^#!.*python.*$|#!/usr/bin/python%{pybasever}|' {} \; # Remove /usr/bin/python3 symlink and unversioned commands (we're not main_python) rm -f %{buildroot}%{_bindir}/python3 rm -f %{buildroot}%{_bindir}/python3-config rm -f %{buildroot}%{_bindir}/pydoc3 rm -f %{buildroot}%{_bindir}/idle3 rm -f %{buildroot}%{_bindir}/pip3 rm -f %{buildroot}%{_bindir}/2to3 # Remove man page for python3 (we only provide python3.15) # Be careful not to delete python3.15.1 man page rm -f %{buildroot}%{_mandir}/man1/python3.1 rm -f %{buildroot}%{_mandir}/man1/python3.1.gz # Remove libpython3.so unversioned symlink (conflicts with system python) rm -f %{buildroot}%{_libdir}/libpython3.so # Create pkgconfig symlink if [ -f %{buildroot}%{_libdir}/pkgconfig/python-%{pybasever}.pc ]; then ln -sf python-%{pybasever}.pc %{buildroot}%{_libdir}/pkgconfig/python%{pybasever}.pc fi # Install check-pyc-timestamps.py as a helper (non-executable to avoid shebang issues) install -m 0644 %{SOURCE8} %{buildroot}%{pylibdir}/ # ====================================================== # Files # ====================================================== %files %doc README.rst %license LICENSE %{_bindir}/python%{pybasever} %{_bindir}/pydoc%{pybasever} %{_mandir}/man1/python%{pybasever}.1* %files -n %{pkgname}-libs %license LICENSE %dir %{pylibdir} %{pylibdir}/LICENSE.txt %{pylibdir}/*.py %{pylibdir}/*.json %{pylibdir}/__pycache__/ %{pylibdir}/__phello__/ %{pylibdir}/_pyrepl/ %{pylibdir}/asyncio/ %{pylibdir}/collections/ %{pylibdir}/compression/ %{pylibdir}/concurrent/ %{pylibdir}/ctypes/ %{pylibdir}/curses/ %{pylibdir}/dbm/ %{pylibdir}/email/ %{pylibdir}/encodings/ %{pylibdir}/ensurepip/ %{pylibdir}/html/ %{pylibdir}/http/ %{pylibdir}/importlib/ %{pylibdir}/json/ %{pylibdir}/logging/ %{pylibdir}/multiprocessing/ %{pylibdir}/pathlib/ %{pylibdir}/profiling/ %{pylibdir}/pydoc_data/ %{pylibdir}/re/ %{pylibdir}/sqlite3/ %{pylibdir}/string/ %{pylibdir}/sysconfig/ %{pylibdir}/tomllib/ %{pylibdir}/turtledemo/ %{pylibdir}/unittest/ %{pylibdir}/urllib/ %{pylibdir}/venv/ %{pylibdir}/wsgiref/ %{pylibdir}/xml/ %{pylibdir}/xmlrpc/ %{pylibdir}/zipfile/ %{pylibdir}/zoneinfo/ %{pylibdir}/config-%{LDVERSION_optimized}-%{platform_triplet}/ %dir %{dynload_dir} %{dynload_dir}/*.so %exclude %{dynload_dir}/_tkinter.cpython-%{pyshortver}*.so %{_libdir}/libpython%{LDVERSION_optimized}.so.%{py_SOVERSION} %{_libdir}/libpython%{LDVERSION_optimized}.so # site-packages directory %dir %{pylibdir}/site-packages %{pylibdir}/site-packages/README.txt %files -n %{pkgname}-devel %{_bindir}/python%{pybasever}-config %{_libdir}/pkgconfig/python-%{pybasever}.pc %{_libdir}/pkgconfig/python-%{pybasever}-embed.pc %{_libdir}/pkgconfig/python%{pybasever}.pc # Remove unversioned pkgconfig files that conflict with system python %exclude %{_libdir}/pkgconfig/python3.pc %exclude %{_libdir}/pkgconfig/python3-embed.pc %{_includedir}/python%{LDVERSION_optimized}/ %files -n %{pkgname}-idle %{_bindir}/idle%{pybasever} %{pylibdir}/idlelib/ %files -n %{pkgname}-tkinter %{pylibdir}/tkinter/ %{dynload_dir}/_tkinter.cpython-%{pyshortver}*.so %files -n %{pkgname}-test %{pylibdir}/test/ # ====================================================== # Changelog # ====================================================== %changelog * Wed Jul 08 2026 Yonghang Wang - %{general_version}%{?prerel:~%{prerel}}-1%{?dist}%{?_trivial}%{?_buildid} - Build for al2023