mirror of
https://abf.rosa.ru/djam/python3.11.git
synced 2025-02-24 02:32:53 +00:00
107 lines
5.2 KiB
Text
107 lines
5.2 KiB
Text
%__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))")
|
|
|
|
%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
|
|
|
|
%py3_shbang_opts -s
|
|
|
|
%py3_build() %{expand:\
|
|
CFLAGS="%{optflags} -lpython%{py3_ver}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}\
|
|
}
|
|
|
|
%py3_install() %{expand:\
|
|
CFLAGS="%{optflags} -lpython%{py3_ver}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}\
|
|
}
|
|
|
|
%py3_test() %{expand:\
|
|
%{__python3} %{py_setup} %{?py_setup_args} test %{?1}\
|
|
}
|
|
|
|
%py3_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 \
|
|
%{-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 \
|
|
}
|
|
|
|
# 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}
|
|
|
|
%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 %{?*}
|
|
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
|
|
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
for distinfo in %{buildroot}%{python3_sitelib}/*.dist-info %{buildroot}%{python3_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
|
|
fi
|
|
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)
|
|
}
|
|
}
|