|
|
51cf4a |
# unversioned macros: used with user defined __python, no longer part of rpm >= 4.15
|
|
|
51cf4a |
# __python is defined to error by default in the srpm macros
|
|
|
51cf4a |
%python_sitelib %(%{__python} -Esc "import sysconfig; print(sysconfig.get_path('purelib'))")
|
|
|
51cf4a |
%python_sitearch %(%{__python} -Esc "import sysconfig; print(sysconfig.get_path('platlib'))")
|
|
|
51cf4a |
%python_version %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
|
|
|
51cf4a |
%python_version_nodots %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
|
|
|
51cf4a |
%python_platform %(%{__python} -Esc "import sysconfig; print(sysconfig.get_platform())")
|
|
|
51cf4a |
%python_platform_triplet %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
|
|
51cf4a |
%python_ext_suffix %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_setup setup.py
|
|
|
51cf4a |
%py_shbang_opts -s
|
|
|
51cf4a |
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
|
|
51cf4a |
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
|
|
51cf4a |
%py_shebang_fix %{expand:\\\
|
|
|
51cf4a |
if [ -f /usr/bin/pathfix%{python_version}.py ]; then
|
|
|
51cf4a |
pathfix=/usr/bin/pathfix%{python_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 "%{?py_shebang_flags}" ]; then
|
|
|
51cf4a |
shebang_flags="-k"
|
|
|
51cf4a |
else
|
|
|
51cf4a |
shebang_flags="-ka%{py_shebang_flags}"
|
|
|
51cf4a |
fi
|
|
|
51cf4a |
$pathfix -pni %{__python} $shebang_flags}
|
|
|
51cf4a |
|
|
|
51cf4a |
# Use the slashes after expand so that the command starts on the same line as
|
|
|
51cf4a |
# the macro
|
|
|
51cf4a |
%py_build() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py_shbang_opts}" %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_build_egg() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_build_wheel() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_install() %{expand:\\\
|
|
|
51cf4a |
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
|
|
51cf4a |
%{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
|
|
|
51cf4a |
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_install_egg() %{expand:\\\
|
|
|
51cf4a |
mkdir -p %{buildroot}%{python_sitelib}
|
|
|
51cf4a |
%{__python} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}
|
|
|
51cf4a |
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%py_install_wheel() %{expand:\\\
|
|
|
51cf4a |
%{__python} -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}%{python_sitelib}/*.dist-info %{buildroot}%{python_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 module(s).
|
|
|
51cf4a |
# Useful as a smoke test in %%check when running tests is not feasible.
|
|
|
51cf4a |
# Use spaces or commas as separators.
|
|
|
51cf4a |
%py_check_import() %{expand:\\\
|
|
|
51cf4a |
(cd %{_topdir} &&\\\
|
|
|
51cf4a |
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
|
|
51cf4a |
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
|
|
|
51cf4a |
PYTHONDONTWRITEBYTECODE=1\\\
|
|
|
51cf4a |
%{__python} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}"
|
|
|
51cf4a |
)
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%python_provide() %{lua:
|
|
|
51cf4a |
local python = require "fedora.srpm.python"
|
|
|
51cf4a |
function string.starts(String,Start)
|
|
|
51cf4a |
return string.sub(String,1,string.len(Start))==Start
|
|
|
51cf4a |
end
|
|
|
51cf4a |
local package = rpm.expand("%{?1}")
|
|
|
51cf4a |
local vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
|
|
|
51cf4a |
local provides = python.python_altprovides(package, vr)
|
|
|
51cf4a |
local default_python3_pkgversion = rpm.expand("%{__default_python3_pkgversion}")
|
|
|
51cf4a |
if (string.starts(package, "python3-")) then
|
|
|
51cf4a |
for i, provide in ipairs(provides) do
|
|
|
51cf4a |
print("\\nProvides: " .. provide)
|
|
|
51cf4a |
end
|
|
|
51cf4a |
--Obsoleting the previous default python package (if it doesn't have isa)
|
|
|
51cf4a |
if (string.sub(package, "-1") ~= ")") then
|
|
|
51cf4a |
print("\\nObsoletes: python-")
|
|
|
51cf4a |
print(string.sub(package,9,string.len(package)))
|
|
|
51cf4a |
print(" < " .. vr)
|
|
|
51cf4a |
end
|
|
|
51cf4a |
elseif (string.starts(package, "python" .. default_python3_pkgversion .. "-")) then
|
|
|
51cf4a |
for i, provide in ipairs(provides) do
|
|
|
51cf4a |
print("\\nProvides: " .. provide)
|
|
|
51cf4a |
end
|
|
|
51cf4a |
--Obsoleting the previous default python package (if it doesn't have isa)
|
|
|
51cf4a |
if (string.sub(package, "-1") ~= ")") then
|
|
|
51cf4a |
print("\\nObsoletes: python-")
|
|
|
51cf4a |
print(string.sub(package,8+string.len(default_python3_pkgversion),string.len(package)))
|
|
|
51cf4a |
print(" < " .. vr)
|
|
|
51cf4a |
end
|
|
|
51cf4a |
elseif (string.starts(package, "python")) then
|
|
|
51cf4a |
--No unversioned provides as other python3 cases are not the default
|
|
|
51cf4a |
elseif (string.starts(package, "pypy")) then
|
|
|
51cf4a |
--No unversioned provides as pypy is not default either
|
|
|
51cf4a |
else
|
|
|
51cf4a |
print("%python_provide: ERROR: ")
|
|
|
51cf4a |
print(package)
|
|
|
51cf4a |
print(" not recognized.")
|
|
|
51cf4a |
end
|
|
|
51cf4a |
}
|
|
|
51cf4a |
|
|
|
51cf4a |
%python_disable_dependency_generator() \
|
|
|
51cf4a |
%undefine __pythondist_requires \
|
|
|
51cf4a |
%{nil}
|