|
|
51cf4a |
%python3_sitelib %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_path('purelib'))")
|
|
|
51cf4a |
%python3_sitearch %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_path('platlib'))")
|
|
|
51cf4a |
%python3_version %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
|
|
|
51cf4a |
%python3_version_nodots %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
|
|
|
51cf4a |
%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
|
|
|
51cf4a |
%python3_platform_triplet %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
|
|
51cf4a |
%python3_ext_suffix %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
|
|
51cf4a |
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_shbang_opts -s
|
|
|
51cf4a |
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
|
|
51cf4a |
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
|
|
51cf4a |
%py3_shebang_fix %{expand:\\\
|
|
|
51cf4a |
if [ -f /usr/bin/pathfix%{python3_version}.py ]; then
|
|
|
51cf4a |
pathfix=/usr/bin/pathfix%{python3_version}.py
|
|
|
51cf4a |
else
|
|
|
51cf4a |
# older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly
|
|
|
51cf4a |
pathfix=/usr/bin/pathfix.py
|
|
|
51cf4a |
fi
|
|
|
51cf4a |
if [ -z "%{?py3_shebang_flags}" ]; then
|
|
|
51cf4a |
shebang_flags="-k"
|
|
|
51cf4a |
else
|
|
|
51cf4a |
shebang_flags="-ka%{py3_shebang_flags}"
|
|
|
51cf4a |
fi
|
|
|
51cf4a |
$pathfix -pni %{__python3} $shebang_flags}
|
|
|
51cf4a |
|
|
|
51cf4a |
# Use the slashes after expand so that the command starts on the same line as
|
|
|
51cf4a |
# the macro
|
|
|
51cf4a |
%py3_build() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_build_egg() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_build_wheel() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_install() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
|
|
|
51cf4a |
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_install_egg() %{expand:\\\
|
|
|
51cf4a |
mkdir -p %{buildroot}%{python3_sitelib}
|
|
|
51cf4a |
%{__python3} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*}
|
|
|
51cf4a |
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py3_install_wheel() %{expand:\\\
|
|
|
51cf4a |
%{__python3} -m pip install -I dist/%{1} --root %{buildroot} --no-deps --no-index --no-warn-script-location
|
|
|
51cf4a |
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
|
51cf4a |
for distinfo in %{buildroot}%{python3_sitelib}/*.dist-info %{buildroot}%{python3_sitearch}/*.dist-info; do
|
|
|
51cf4a |
if [ -f ${distinfo}/direct_url.json ]; then
|
|
|
51cf4a |
rm -fv ${distinfo}/direct_url.json
|
|
|
51cf4a |
sed -i '/direct_url.json/d' ${distinfo}/RECORD
|
|
|
51cf4a |
fi
|
|
|
51cf4a |
done
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
# With $PATH and $PYTHONPATH set to the %%buildroot,
|
|
|
51cf4a |
# try to import the given Python 3 module(s).
|
|
|
51cf4a |
# Useful as a smoke test in %%check when running tests is not feasible.
|
|
|
51cf4a |
# Use spaces or commas as separators.
|
|
|
51cf4a |
%py3_check_import() %{expand:\\\
|
|
|
51cf4a |
(cd %{_topdir} &&\\\
|
|
|
51cf4a |
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
|
|
51cf4a |
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
|
|
51cf4a |
PYTHONDONTWRITEBYTECODE=1\\\
|
|
|
51cf4a |
%{__python3} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}"
|
|
|
51cf4a |
)
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
# This only supports Python 3.5+ and will never work with Python 2.
|
|
|
51cf4a |
# Hence, it has no Python version in the name.
|
|
|
51cf4a |
%pycached() %{lua:
|
|
|
51cf4a |
path = rpm.expand("%{?*}")
|
|
|
51cf4a |
if (string.sub(path, "-3") ~= ".py") then
|
|
|
51cf4a |
rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}")
|
|
|
51cf4a |
else
|
|
|
51cf4a |
print(path)
|
|
|
51cf4a |
pyminor = path:match("/python3.(%d+)/") or "*"
|
|
|
51cf4a |
dirname = path:match("(.*/)")
|
|
|
51cf4a |
modulename = path:match(".*/([^/]+).py")
|
|
|
51cf4a |
print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
|
|
|
51cf4a |
end
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
# This is intended for Python 3 only, hence also no Python version in the name.
|
|
|
51cf4a |
%__pytest /usr/bin/pytest%(test %{python3_pkgversion} == 3 || echo -%{python3_version})
|
|
|
51cf4a |
%pytest %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
|
|
51cf4a |
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
|
|
51cf4a |
PYTHONDONTWRITEBYTECODE=1\\\
|
|
|
51cf4a |
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}\\\
|
|
|
51cf4a |
%__pytest}
|