diff --git a/py3.11bytecompile.macros b/py3.11bytecompile.macros deleted file mode 100644 index a8b79b2..0000000 --- a/py3.11bytecompile.macros +++ /dev/null @@ -1,12 +0,0 @@ -# Note that the path could itself be a python file, or a directory - -# Python's compile_all module only works on directories, and requires a max -# recursion depth - -%py_byte_compile()\ -python_binary="%1"\ -bytecode_compilation_path="%2"\ -find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ -\ -find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ -%{nil} diff --git a/python3.11.macros b/python3.11.macros index 5699e1f..ee48461 100644 --- a/python3.11.macros +++ b/python3.11.macros @@ -1,79 +1,52 @@ -%__python3.11 /usr/libexec/python3.11 -%python3_pkgversion 3 -%python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") -%python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") -%python3_sitearch %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '%{_prefix}'}))") -%python3_sitelib %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_path('purelib', vars={'base': '%{_prefix}'}))") -%python3_version %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") -%python3_version_nodots %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") +%__python311 /usr/libexec/python3.11 +%python311_platform %(RPM_BUILD_ROOT= %{__python311} -Ic "import sysconfig; print(sysconfig.get_platform())") +%python311_platform %(RPM_BUILD_ROOT= %{__python311} -Ic "import sysconfig; print(sysconfig.get_platform())") +%python311_sitearch %(RPM_BUILD_ROOT= %{__python311} -Ic "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '%{_prefix}'}))") +%python311_sitelib %(RPM_BUILD_ROOT= %{__python311} -Ic "import sysconfig; print(sysconfig.get_path('purelib', vars={'base': '%{_prefix}'}))") +%python311_version %(RPM_BUILD_ROOT= %{__python311} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") +%python311_version_nodots %(RPM_BUILD_ROOT= %{__python311} -Ic "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") -%py3_ver %(%{__python3} -c "import sys; v=sys.version_info[:2]; print('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON-NOT-FOUND) -%py3_prefix %(%{__python3} -c "import sys; print(sys.prefix)" 2>/dev/null || echo PYTHON-NOT-FOUND) -%py3_platsitedir %python3_sitearch -%py3_puresitedir %python3_sitelib -%py3_incdir %(RPM_BUILD_ROOT= %{__python3} -c "import sysconfig; print(sysconfig.get_path('include', vars={'installed_base': '%{_prefix}'}))" 2>/dev/null || echo PYTHON-INCLUDEDIR-NOT-FOUND) -%py3dir %{_builddir}/python3-%{name}-%{version}-%{release} -# %%py_setup setup.py # in rpm-openmandriva-setup +%py311_ver %(%{__python311} -c "import sys; v=sys.version_info[:2]; print('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON-NOT-FOUND) +%py311_prefix %(%{__python311} -c "import sys; print(sys.prefix)" 2>/dev/null || echo PYTHON-NOT-FOUND) +%py311_platsitedir %python311_sitearch +%py311_puresitedir %python311_sitelib +%py311_incdir %(RPM_BUILD_ROOT= %{__python311} -c "import sysconfig; print(sysconfig.get_path('include', vars={'installed_base': '%{_prefix}'}))" 2>/dev/null || echo PYTHON-INCLUDEDIR-NOT-FOUND) -%py3_shbang_opts -s - -%py3_build() %{expand:\ -CFLAGS="%{optflags} -lpython%{py3_ver}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}\ +%py311_build() %{expand:\ +CFLAGS="%{optflags} -lpython%{py311_ver}" %{__python311} %{py_setup} %{?py_setup_args} build --executable="%{__python311} %{py311_shbang_opts}" %{?*}\ } -%py3_install() %{expand:\ -CFLAGS="%{optflags} -lpython%{py3_ver}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}\ +%py311_install() %{expand:\ +CFLAGS="%{optflags} -lpython%{py311_ver}" %{__python311} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}\ } -%py3_test() %{expand:\ -%{__python3} %{py_setup} %{?py_setup_args} test %{?1}\ +%py311_test() %{expand:\ +%{__python311} %{py_setup} %{?py_setup_args} test %{?1}\ } -%py3_compile(O) \ +%py311_compile(O) \ find %1 -name '*.pyc' -exec rm -f {} \\; \ -%{__python3} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ +%{__python311} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ %{-O: \ find %1 -name '*.pyo' -exec rm -f {} \\; \ -%{__python3} -O -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ +%{__python311} -O -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \ } -# This is intended for Python 3 only, hence also no Python version in the name. -%__pytest /usr/bin/pytest-3 -%pytest %{expand:\\\ - CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ - PATH="%{buildroot}%{_bindir}:$PATH"\\\ - PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ - PYTHONDONTWRITEBYTECODE=1\\\ - %{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}\\\ - %__pytest} +%py311_shbang_opts -s +%py311_shbang_opts_nodash %(opts=%{py311_shbang_opts}; echo ${opts#-}) +%py311_shebang_flags %(opts=%{py311_shbang_opts}; echo ${opts#-}) +%py311_shebang_fix %{_bindir}/pathfix3.11.py -pni %{__python311} %{py311_shebang_flags}} -%py3_shbang_opts -s -%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-}) -%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-}) -%py3_shebang_fix %{expand:\\\ - if [ -f /usr/bin/pathfix%{python3_version}.py ]; then - pathfix=/usr/bin/pathfix%{python3_version}.py - else - # older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly - pathfix=/usr/bin/pathfix.py - fi - if [ -z "%{?py3_shebang_flags}" ]; then - shebang_flags="-k" - else - shebang_flags="-ka%{py3_shebang_flags}" - fi - $pathfix -pni %{__python3} $shebang_flags} - -%py3_install_egg() %{expand:\\\ - mkdir -p %{buildroot}%{python3_sitelib} - %{__python3} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*} +%py311_install_egg() %{expand:\\\ + mkdir -p %{buildroot}%{python311_sitelib} + %{__python311} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python311_version}.egg %{?*} rm -rfv %{buildroot}%{_bindir}/__pycache__ } -%py3_install_wheel() %{expand:\\\ - %{__python3} -m pip install -I dist/%{1} --root %{buildroot} --no-deps --no-index --no-warn-script-location +%py311_install_wheel() %{expand:\\\ + %{__python311} -m pip install -I dist/%{1} --root %{buildroot} --no-deps --no-index --no-warn-script-location rm -rfv %{buildroot}%{_bindir}/__pycache__ - for distinfo in %{buildroot}%{python3_sitelib}/*.dist-info %{buildroot}%{python3_sitearch}/*.dist-info; do + for distinfo in %{buildroot}%{python311_sitelib}/*.dist-info %{buildroot}%{python311_sitearch}/*.dist-info; do if [ -f ${distinfo}/direct_url.json ]; then rm -fv ${distinfo}/direct_url.json sed -i '/direct_url.json/d' ${distinfo}/RECORD @@ -81,27 +54,4 @@ find %1 -name '*.pyo' -exec rm -f {} \\; \ done } -# With $PATH and $PYTHONPATH set to the %%buildroot, -# try to import the Python 3 module(s) given as command-line args or read from file (-f). -# Respect the custom values of %%py3_shebang_flags or set nothing if it's undefined. -# Filter and check import on only top-level modules using -t flag. -# Exclude unwanted modules by passing their globs to -e option. -# Useful as a smoke test in %%check when running tests is not feasible. -# Use spaces or commas as separators if providing list directly. -# Use newlines as separators if providing list in a file. -%py3_check_import(e:tf:) %{expand:\\\ - PATH="%{buildroot}%{_bindir}:$PATH"\\\ - PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ - _PYTHONSITE="%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}"\\\ - PYTHONDONTWRITEBYTECODE=1\\\ - %{lua: - local command = "%{__python3} " - if rpm.expand("%{?py3_shebang_flags}") ~= "" then - command = command .. "-%{py3_shebang_flags}" - end - command = command .. " %{_rpmconfigdir}/redhat/import_all_modules.py " - -- handle multiline arguments correctly, see https://bugzilla.redhat.com/2018809 - local args=rpm.expand('%{?**}'):gsub("[%s\\\\]*%s+", " ") - print(command .. args) - } -} +%py311_shebang_sanity %{_bindir}/python3.11-shebang-sanity diff --git a/python3.11.spec b/python3.11.spec index f41cc7b..bbb5cd9 100644 --- a/python3.11.spec +++ b/python3.11.spec @@ -35,14 +35,13 @@ Summary: An interpreted, interactive object-oriented programming language Name: python3.11 Version: 3.11.3 -Release: 1 +Release: 2 License: Modified CNRI Open Source License Group: Development/Python Source0: https://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz Source1: https://docs.python.org/3/archives/python-%{docver}-docs-html.tar.bz2 Source2: python3.11.macros -Source3: py3.11bytecompile.macros Source4: import_all_modules.py Source5: python3.11-shebang-sanity.sh Source100: %{name}.rpmlintrc @@ -322,8 +321,7 @@ find %{buildroot} -type f \( -name "test_binascii.py*" -o -name "test_grp.py*" - chmod u+w %{buildroot}%{_libdir}/libpython%{lib_major}*.so.1.0 %{buildroot}%{_libdir}/libpython3.so -%install_macro python3.11 %{SOURCE2} -%install_macro py3.11bytecompile %{SOURCE3} +%install_macro python311 %{SOURCE2} # Script to perform import of each module given to %%py_check_import install -D -m644 %{SOURCE4} %{buildroot}%{_rpmconfigdir}/redhat/import_all_modules.py @@ -375,8 +373,7 @@ export TMP="/tmp" TMPDIR="/tmp" #WITHIN_PYTHON_RPM_BUILD= make test TESTOPTS="-u network -x $EXCLUDE" %files -%{_rpmmacrodir}/*python3* -%{_rpmmacrodir}/*py3.11bytecompile* +%{_rpmmacrodir}/*python311* %{_rpmconfigdir}/redhat/import_all_modules.py %{_includedir}/python*/pyconfig.h %{_libdir}/python*/config*/Makefile