commit
fe8bb86fbd
@ -0,0 +1,24 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# %py_byte_compile <interpereter> <path>
|
||||||
|
# Example:
|
||||||
|
# %py_byte_compile %{__python3} %{buildroot}%{_datadir}/spam/plugins/
|
||||||
|
|
||||||
|
# This will terminate build on SyntaxErrors, if you want to avoid that,
|
||||||
|
# use it in a subshell like this:
|
||||||
|
# (%{py_byte_compile <interpereter> <path>}) || :
|
||||||
|
|
||||||
|
%py_byte_compile()\
|
||||||
|
python_binary="%1"\
|
||||||
|
buildroot_path="%2"\
|
||||||
|
bytecode_compilation_path=".${buildroot_path/#$RPM_BUILD_ROOT}"\
|
||||||
|
failure=0\
|
||||||
|
pushd $RPM_BUILD_ROOT\
|
||||||
|
find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -m py_compile || failure=1\
|
||||||
|
find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -m py_compile || failure=1\
|
||||||
|
popd\
|
||||||
|
test $failure -eq 0
|
@ -0,0 +1,92 @@
|
|||||||
|
# %%__python is defined in /usr/lib/rpm/macros to raise an error
|
||||||
|
# so if you don't redefine it, you'll get the same error from %%python
|
||||||
|
%python %__python
|
||||||
|
|
||||||
|
%python_platform_triplet %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
||||||
|
%python_ext_suffix %(%{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
||||||
|
|
||||||
|
%py_setup setup.py
|
||||||
|
%py_shbang_opts -s
|
||||||
|
|
||||||
|
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||||
|
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||||
|
%py_shebang_fix %{expand:\\\
|
||||||
|
if [ -f /usr/bin/pathfix%{python_version}.py ]; then
|
||||||
|
pathfix=/usr/bin/pathfix%{python_version}.py
|
||||||
|
else
|
||||||
|
# unversioned pathfix.py provided by platform-python-devel
|
||||||
|
pathfix=/usr/bin/pathfix.py
|
||||||
|
fi
|
||||||
|
if [ -z "%{?py_shebang_flags}" ]; then
|
||||||
|
shebang_flags="-k"
|
||||||
|
else
|
||||||
|
shebang_flags="-ka%{py_shebang_flags}"
|
||||||
|
fi
|
||||||
|
$pathfix -pni %{__python} $shebang_flags}
|
||||||
|
|
||||||
|
# Use the slashes after expand so that the command starts on the same line as
|
||||||
|
# the macro
|
||||||
|
%py_build() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py_shbang_opts}" %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py_build_egg() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py_build_wheel() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py_install() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py_install_egg() %{expand:\\\
|
||||||
|
mkdir -p %{buildroot}%{python_sitelib}
|
||||||
|
easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py_install_wheel() %{expand:\\\
|
||||||
|
pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
|
||||||
|
}
|
||||||
|
|
||||||
|
%python_provide() %{lua:
|
||||||
|
function string.starts(String,Start)
|
||||||
|
return string.sub(String,1,string.len(Start))==Start
|
||||||
|
end
|
||||||
|
package = rpm.expand("%{?1}")
|
||||||
|
vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
|
||||||
|
if (string.starts(package, "python2-")) then
|
||||||
|
--No unversioned provides as python2 is not default
|
||||||
|
elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
|
||||||
|
--No unversioned provides as python3 is not default
|
||||||
|
elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
|
||||||
|
--No unversioned provides as python3_other is not default
|
||||||
|
elseif (string.starts(package, "pypy-")) then
|
||||||
|
--No unversioned provides as pypy is not default
|
||||||
|
elseif (string.starts(package, "pypy3-")) then
|
||||||
|
--No unversioned provides as pypy is not default
|
||||||
|
elseif (string.starts(package, "python-")) then
|
||||||
|
--Providing the current default python
|
||||||
|
print("Provides: python2-")
|
||||||
|
print(string.sub(package,8,string.len(package)))
|
||||||
|
print(" = ")
|
||||||
|
print(vr)
|
||||||
|
else
|
||||||
|
print("%python_provide: ERROR: ")
|
||||||
|
print(package)
|
||||||
|
print(" not recognized.")
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
%python_enable_dependency_generator() \
|
||||||
|
%global __python_requires %{_rpmconfigdir}/pythondistdeps.py --requires \
|
||||||
|
%{nil}
|
@ -0,0 +1,152 @@
|
|||||||
|
# python3_pkgversion specifies the version of Python 3 in the distro. It can be
|
||||||
|
# a specific version (e.g. 34 in Fedora EPEL7)
|
||||||
|
%python3_pkgversion 3
|
||||||
|
|
||||||
|
# Set to /bin/true to avoid %ifdefs and %{? in specfiles
|
||||||
|
%__python3_other /bin/true
|
||||||
|
%py3_other_build /bin/true
|
||||||
|
%py3_other_install /bin/true
|
||||||
|
|
||||||
|
# Define where Python wheels will be stored and the prefix of -wheel packages
|
||||||
|
# - In Fedora we want wheel subpackages named e.g. `python-pip-wheel` that
|
||||||
|
# install packages into `/usr/share/python-wheels`. Both names are not
|
||||||
|
# versioned, because they're used by all Python 3 stacks.
|
||||||
|
# - In RHEL we want wheel packages named e.g. `python3-pip-wheel` and
|
||||||
|
# `python3.11-pip-wheel` that install packages into similarly versioned
|
||||||
|
# locations. We want each Python stack in RHEL to have their own wheels,
|
||||||
|
# because the main python3 wheels (which we can't upgrade) will likely be
|
||||||
|
# quite old by the time we're adding new alternate Python stacks.
|
||||||
|
# - In ELN we want to follow Fedora, because builds for ELN and Fedora rawhide
|
||||||
|
# need to be interoperable.
|
||||||
|
%python_wheel_pkg_prefix python%{?rhel:%{!?eln:%{python3_pkgversion}}}
|
||||||
|
%python_wheel_dir %{_datadir}/%{python_wheel_pkg_prefix}-wheels
|
||||||
|
|
||||||
|
|
||||||
|
# === Macros for Build/Requires tags using Python dist tags ===
|
||||||
|
# - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
|
||||||
|
# - These macros need to be in macros.python-srpm, because BuildRequires tags
|
||||||
|
# get rendered as runtime requires into the metadata of SRPMs.
|
||||||
|
|
||||||
|
# Converts Python dist name to a canonical format
|
||||||
|
%py_dist_name() %{lua:\
|
||||||
|
name = rpm.expand("%{?1:%{1}}");\
|
||||||
|
canonical = string.gsub(string.lower(name), "[^%w%.]+", "-");\
|
||||||
|
print(canonical);\
|
||||||
|
}
|
||||||
|
|
||||||
|
# Creates Python 2 dist tag(s) after converting names to canonical format
|
||||||
|
# Needs to first put all arguments into a list, because invoking a different
|
||||||
|
# macro (%py_dist_name) overwrites them
|
||||||
|
%py2_dist() %{lua:\
|
||||||
|
args = {}\
|
||||||
|
arg = 1\
|
||||||
|
while (true) do\
|
||||||
|
name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
|
||||||
|
if (name == nil or name == '') then\
|
||||||
|
break\
|
||||||
|
end\
|
||||||
|
args[arg] = name\
|
||||||
|
arg = arg + 1\
|
||||||
|
end\
|
||||||
|
for arg, name in ipairs(args) do\
|
||||||
|
canonical = rpm.expand("%py_dist_name " .. name);\
|
||||||
|
print("python2dist(" .. canonical .. ") ");\
|
||||||
|
end\
|
||||||
|
}
|
||||||
|
|
||||||
|
# RHEL 9+ and Fedora compatibility macro
|
||||||
|
# Only use in macro backports, not intended to be used in spec files!
|
||||||
|
# In the future, the %%python3_pkgversion macro has a dot, e.g. 3.9 or 3.11
|
||||||
|
# However, in RHEL 8 at least, it does not, e.g. 38, 39
|
||||||
|
# This is a helpful macro that determines the proper "Python version" string with dot
|
||||||
|
# from %%python3_pkgversion without actually having Python installed.
|
||||||
|
# For values other than 3X, it should expand to %%python3_pkgversion unchanged.
|
||||||
|
# Examples of %%python3_pkgversion -> %%_python3_pkgversion_with_dot:
|
||||||
|
# 3 -> 3
|
||||||
|
# 38 -> 3.8
|
||||||
|
# 39 -> 3.9
|
||||||
|
# 310 -> 3.10
|
||||||
|
# 3.12 -> 3.12
|
||||||
|
# 4 -> 4
|
||||||
|
# 412 -> 412
|
||||||
|
%_python3_pkgversion_with_dot %{lua:print((rpm.expand("%python3_pkgversion"):gsub('^3(%d)', '3.%1')))}
|
||||||
|
|
||||||
|
# Creates Python 3 dist tag(s) after converting names to canonical format
|
||||||
|
# Needs to first put all arguments into a list, because invoking a different
|
||||||
|
# macro (%py_dist_name) overwrites them
|
||||||
|
%py3_dist() %{lua:\
|
||||||
|
python3_pkgversion_with_dot = rpm.expand("%_python3_pkgversion_with_dot")\
|
||||||
|
args = {}\
|
||||||
|
arg = 1\
|
||||||
|
while (true) do\
|
||||||
|
name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
|
||||||
|
if (name == nil or name == '') then\
|
||||||
|
break\
|
||||||
|
end\
|
||||||
|
args[arg] = name\
|
||||||
|
arg = arg + 1\
|
||||||
|
end\
|
||||||
|
for arg, name in ipairs(args) do\
|
||||||
|
canonical = rpm.expand("%py_dist_name " .. name);\
|
||||||
|
print("python" .. python3_pkgversion_with_dot .. "dist(" .. canonical .. ") ");\
|
||||||
|
end\
|
||||||
|
}
|
||||||
|
|
||||||
|
# Macro to replace overly complicated references to PyPI source files.
|
||||||
|
# Expands to the pythonhosted URL for a package
|
||||||
|
# Accepts zero to three arguments:
|
||||||
|
# 1: The PyPI project name, defaulting to %srcname if it is defined, then
|
||||||
|
# %pypi_name if it is defined, then just %name.
|
||||||
|
# 2: The PYPI version, defaulting to %version with tildes stripped.
|
||||||
|
# 3: The file extension, defaulting to "tar.gz". (A period will be added
|
||||||
|
# automatically.)
|
||||||
|
# Requires %__pypi_url and %__pypi_default_extension to be defined.
|
||||||
|
%__pypi_url https://files.pythonhosted.org/packages/source/
|
||||||
|
%__pypi_default_extension tar.gz
|
||||||
|
|
||||||
|
%pypi_source() %{lua:
|
||||||
|
local src = rpm.expand('%1')
|
||||||
|
local ver = rpm.expand('%2')
|
||||||
|
local ext = rpm.expand('%3')
|
||||||
|
local url = rpm.expand('%__pypi_url')
|
||||||
|
\
|
||||||
|
-- If no first argument, try %srcname, then %pypi_name, then %name
|
||||||
|
-- Note that rpm leaves macros unchanged if they are not defined.
|
||||||
|
if src == '%1' then
|
||||||
|
src = rpm.expand('%srcname')
|
||||||
|
end
|
||||||
|
if src == '%srcname' then
|
||||||
|
src = rpm.expand('%pypi_name')
|
||||||
|
end
|
||||||
|
if src == '%pypi_name' then
|
||||||
|
src = rpm.expand('%name')
|
||||||
|
end
|
||||||
|
\
|
||||||
|
-- If no second argument, use %version
|
||||||
|
if ver == '%2' then
|
||||||
|
ver = rpm.expand('%version'):gsub('~', '')
|
||||||
|
end
|
||||||
|
\
|
||||||
|
-- If no third argument, use the preset default extension
|
||||||
|
if ext == '%3' then
|
||||||
|
ext = rpm.expand('%__pypi_default_extension')
|
||||||
|
end
|
||||||
|
\
|
||||||
|
local first = string.sub(src, 1, 1)
|
||||||
|
\
|
||||||
|
print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Python packages in RHEL 8 should not provide unversioned python- names
|
||||||
|
# so this macro here is just a compatibility layer and only provides the given name.
|
||||||
|
%py_provides() %{lua:
|
||||||
|
local name = rpm.expand('%1')
|
||||||
|
if name == '%1' then
|
||||||
|
rpm.expand('%{error:%%py_provides requires at least 1 argument, the name to provide}')
|
||||||
|
end
|
||||||
|
local evr = rpm.expand('%2')
|
||||||
|
if evr == '%2' then
|
||||||
|
evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}')
|
||||||
|
end
|
||||||
|
print('Provides: ' .. name .. ' = ' .. evr .. '\\n')
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
%__python2 /usr/bin/python2
|
||||||
|
%python2_sitelib %(RHEL_ALLOW_PYTHON2_FOR_BUILD=1 %{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
||||||
|
%python2_sitearch %(RHEL_ALLOW_PYTHON2_FOR_BUILD=1 %{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
|
||||||
|
%python2_version %(RHEL_ALLOW_PYTHON2_FOR_BUILD=1 %{__python2} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
|
||||||
|
%python2_version_nodots %(RHEL_ALLOW_PYTHON2_FOR_BUILD=1 %{__python2} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
|
||||||
|
|
||||||
|
%py2_shbang_opts -s
|
||||||
|
|
||||||
|
# Use the slashes after expand so that the command starts on the same line as
|
||||||
|
# the macro
|
||||||
|
%py2_build() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py2_build_egg() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python2} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py2_build_wheel() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python2} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py2_install() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py2_install_egg() %{expand:\\\
|
||||||
|
mkdir -p %{buildroot}%{python2_sitelib}
|
||||||
|
easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py2_install_wheel() %{expand:\\\
|
||||||
|
pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
%__python3 /usr/libexec/platform-python
|
||||||
|
%python3 %__python3
|
||||||
|
%python3_sitelib %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
||||||
|
%python3_sitearch %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
|
||||||
|
%python3_version %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
|
||||||
|
%python3_version_nodots %(%{__python3} -Ic "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info).replace('.',''))")
|
||||||
|
%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
|
||||||
|
%python3_platform_triplet %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
||||||
|
%python3_ext_suffix %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
||||||
|
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
|
||||||
|
|
||||||
|
%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
|
||||||
|
# unversioned pathfix.py provided by platform-python-devel
|
||||||
|
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}
|
||||||
|
|
||||||
|
# Use the slashes after expand so that the command starts on the same line as
|
||||||
|
# the macro
|
||||||
|
%py3_build() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py3_build_egg() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py3_build_wheel() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
%py3_install() %{expand:\\\
|
||||||
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||||
|
%{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py3_install_egg() %{expand:\\\
|
||||||
|
mkdir -p %{buildroot}%{python3_sitelib}
|
||||||
|
CFLAGS="%{optflags}" %{__python3} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*}
|
||||||
|
}
|
||||||
|
|
||||||
|
%py3_install_wheel() %{expand:\\\
|
||||||
|
CFLAGS="%{optflags}" %{__python3} -m pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
|
||||||
|
}
|
||||||
|
|
||||||
|
# This only supports Python 3.5+ and will never work with Python 2.
|
||||||
|
# Hence, it has no Python version in the name.
|
||||||
|
%pycached() %{lua:
|
||||||
|
path = rpm.expand("%{?*}")
|
||||||
|
if (string.sub(path, "-3") ~= ".py") then
|
||||||
|
rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}")
|
||||||
|
else
|
||||||
|
print(path)
|
||||||
|
pyminor = path:match("/python3.(%d+)/") or "*"
|
||||||
|
dirname = path:match("(.*/)")
|
||||||
|
modulename = path:match(".*/([^/]+).py")
|
||||||
|
print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is intended for Python 3 only, hence also no Python version in the name.
|
||||||
|
%__pytest /usr/bin/pytest-%{_python3_pkgversion_with_dot}
|
||||||
|
%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}
|
@ -0,0 +1,245 @@
|
|||||||
|
Name: python-rpm-macros
|
||||||
|
Version: 3
|
||||||
|
Release: 45%{?dist}
|
||||||
|
Summary: The unversioned Python RPM macros
|
||||||
|
|
||||||
|
License: MIT
|
||||||
|
Source0: macros.python
|
||||||
|
Source1: macros.python-srpm
|
||||||
|
Source2: macros.python2
|
||||||
|
Source3: macros.python3
|
||||||
|
Source4: macros.pybytecompile
|
||||||
|
|
||||||
|
BuildArch: noarch
|
||||||
|
# For %%python3_pkgversion used in %%python_provide
|
||||||
|
Requires: python-srpm-macros
|
||||||
|
Obsoletes: python-macros < 3
|
||||||
|
Provides: python-macros = %{version}-%{release}
|
||||||
|
|
||||||
|
%description
|
||||||
|
This package contains the unversioned Python RPM macros, that most
|
||||||
|
implementations should rely on.
|
||||||
|
|
||||||
|
You should not need to install this package manually as the various
|
||||||
|
python?-devel packages require it. So install a python-devel package instead.
|
||||||
|
|
||||||
|
%package -n python-srpm-macros
|
||||||
|
Summary: RPM macros for building Python source packages
|
||||||
|
|
||||||
|
%description -n python-srpm-macros
|
||||||
|
RPM macros for building Python source packages.
|
||||||
|
|
||||||
|
%package -n python2-rpm-macros
|
||||||
|
Summary: RPM macros for building Python 2 packages
|
||||||
|
# For %%py_setup
|
||||||
|
Requires: python-rpm-macros = %{version}-%{release}
|
||||||
|
|
||||||
|
%description -n python2-rpm-macros
|
||||||
|
RPM macros for building Python 2 packages.
|
||||||
|
|
||||||
|
%package -n python3-rpm-macros
|
||||||
|
Summary: RPM macros for building Python 3 packages
|
||||||
|
# Older versions have old pathfix.py without -ka options support
|
||||||
|
Conflicts: platform-python-devel < 3.6.8-35
|
||||||
|
# For %%py_setup
|
||||||
|
Requires: python-rpm-macros = %{version}-%{release}
|
||||||
|
# For %%_python3_pkgversion_with_dot needed by %%__pytest
|
||||||
|
Requires: python-srpm-macros = %{version}-%{release}
|
||||||
|
|
||||||
|
%description -n python3-rpm-macros
|
||||||
|
RPM macros for building Python 3 packages.
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}/%{rpmmacrodir}
|
||||||
|
install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \
|
||||||
|
%{buildroot}/%{rpmmacrodir}/
|
||||||
|
|
||||||
|
|
||||||
|
%files
|
||||||
|
%{rpmmacrodir}/macros.python
|
||||||
|
%{rpmmacrodir}/macros.pybytecompile
|
||||||
|
|
||||||
|
%files -n python-srpm-macros
|
||||||
|
%{rpmmacrodir}/macros.python-srpm
|
||||||
|
|
||||||
|
%files -n python2-rpm-macros
|
||||||
|
%{rpmmacrodir}/macros.python2
|
||||||
|
|
||||||
|
%files -n python3-rpm-macros
|
||||||
|
%{rpmmacrodir}/macros.python3
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Wed Feb 22 2023 Miro Hrončok <mhroncok@redhat.com> - 3-45
|
||||||
|
- Fix %%python3_version macros for Python 3.10+
|
||||||
|
Resolves: rhbz#2169780
|
||||||
|
|
||||||
|
* Fri Oct 14 2022 Charalampos Stratakis <cstratak@redhat.com> - 3-44
|
||||||
|
- Backport the %%python_wheel_pkg_prefix and the %%python_wheel_dir macros from Fedora
|
||||||
|
Resolves: rhbz#2143991
|
||||||
|
|
||||||
|
* Tue Jul 26 2022 Tomas Orsava <torsava@redhat.com> - 3-43
|
||||||
|
- Make %%pytest macro respect %%python3_pkgversion
|
||||||
|
Resolves: rhbz#2091462
|
||||||
|
|
||||||
|
* Wed May 25 2022 Miro Hrončok <mhroncok@redhat.com> - 3-42
|
||||||
|
- Make %%py3_dist respect %%python3_pkgversion
|
||||||
|
Resolves: rhbz#2090007
|
||||||
|
|
||||||
|
* Mon Feb 01 2021 Lumír Balhar <lbalhar@redhat.com> - 3-41
|
||||||
|
- Fix dependencies between subpackages
|
||||||
|
Resolves: rhbz#1892797
|
||||||
|
|
||||||
|
* Thu Jan 14 2021 Lumír Balhar <lbalhar@redhat.com> - 3-40
|
||||||
|
- New macros backported from Fedora/EPEL
|
||||||
|
Resolves: rhbz#1892797
|
||||||
|
|
||||||
|
* Tue Jun 16 2020 Charalampos Stratakis <cstratak@redhat.com> - 3-39
|
||||||
|
- Strip tildes from %%version in %%pypi_source by default
|
||||||
|
- Resolves: rhbz#1844902
|
||||||
|
|
||||||
|
* Mon Oct 14 2019 Charalampos Stratakis <cstratak@redhat.com> - 3-38
|
||||||
|
- Fix the %%py_build macro to respect the global definition of %%__python
|
||||||
|
- Resolves: rhbz#1757833
|
||||||
|
|
||||||
|
* Fri Dec 14 2018 Miro Hrončok <mhroncok@redhat.com> - 3-37
|
||||||
|
- Workaround leaking buildroot PATH in %py_byte_compile
|
||||||
|
- Resolves: rhbz#1644455
|
||||||
|
|
||||||
|
* Fri Dec 14 2018 Miro Hrončok <mhroncok@redhat.com> - 3-36
|
||||||
|
- Make %%py_byte_compile terminate build on SyntaxErrors
|
||||||
|
- Resolves: rhbz#1620168
|
||||||
|
|
||||||
|
* Mon Sep 17 2018 Tomas Orsava <torsava@redhat.com> - 3-35
|
||||||
|
- Disable the python_provide macro for `python2-` prefixed packages
|
||||||
|
- Resolves: rhbz#1636029
|
||||||
|
|
||||||
|
* Mon Jul 16 2018 Tomas Orsava <torsava@redhat.com> - 3-34
|
||||||
|
- macros.pybytecompile: Macro was not line-continued properly and thus didn't work
|
||||||
|
|
||||||
|
* Wed Jul 11 2018 Tomas Orsava <torsava@redhat.com> - 3-33
|
||||||
|
- macros.pybytecompile: Detect Python version through sys.version_info instead
|
||||||
|
of guessing from the executable name
|
||||||
|
|
||||||
|
* Tue Jul 10 2018 Tomas Orsava <torsava@redhat.com> - 3-32
|
||||||
|
- Merging: (Tue Jul 10 2018 Tomas Orsava <torsava@redhat.com> - 3-32)
|
||||||
|
- Fix %%py_byte_compile macro: when invoked with a Python 2 binary it also
|
||||||
|
mistakenly ran py3_byte_compile
|
||||||
|
- Merging: (Tue Jul 03 2018 Miro Hrončok <mhroncok@redhat.com> - 3-31)
|
||||||
|
- Add %%python3_platform useful for PYTHONPATH on arched builds
|
||||||
|
- Merging: (Mon Jun 18 2018 Jason L Tibbitts III <tibbs@math.uh.edu> - 3-30)
|
||||||
|
- Add %%pypi_source macro, as well as %%__pypi_url and
|
||||||
|
%%_pypi_default_extension.
|
||||||
|
- Merging: (Wed Apr 18 2018 Miro Hrončok <mhroncok@redhat.com> - 3-29)
|
||||||
|
- move macros.pybytecompile from python3-devel
|
||||||
|
|
||||||
|
* Wed Jun 27 2018 Tomas Orsava <torsava@redhat.com> - 3-31
|
||||||
|
- Remove RHEL_ALLOW_PYTHON2_FOR_BUILD=1 from build and install macros,
|
||||||
|
as that is where the user needs to set it themself
|
||||||
|
|
||||||
|
* Thu Jun 21 2018 Tomas Orsava <torsava@redhat.com> - 3-30
|
||||||
|
- Explicitly enable Python 2 when invoking Python 2 macros
|
||||||
|
See: https://url.corp.redhat.com/rhel8-py2
|
||||||
|
|
||||||
|
* Wed May 09 2018 Tomas Orsava <torsava@redhat.com> - 3-29
|
||||||
|
- Switch the Python 3 executable to /usr/libexec/platform-python
|
||||||
|
- Update macros using pip or easy_install to be invoked through the main
|
||||||
|
executable
|
||||||
|
|
||||||
|
* Fri Apr 06 2018 Tomas Orsava <torsava@redhat.com> - 3-28
|
||||||
|
- Fix the %%py_dist_name macro to not convert dots (".") into dashes, so that
|
||||||
|
submodules can be addressed as well
|
||||||
|
Resolves: rhbz#1564095
|
||||||
|
|
||||||
|
* Fri Mar 23 2018 Miro Hrončok <mhroncok@redhat.com> - 3-27
|
||||||
|
- make LDFLAGS propagated whenever CFLAGS are
|
||||||
|
|
||||||
|
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3-26
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Jan 19 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 3-25
|
||||||
|
- Add %%python_enable_dependency_generator
|
||||||
|
|
||||||
|
* Tue Nov 28 2017 Tomas Orsava <torsava@redhat.com> - 3-24
|
||||||
|
- Remove platform-python macros (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack)
|
||||||
|
|
||||||
|
* Thu Oct 26 2017 Ville Skyttä <ville.skytta@iki.fi> - 3-23
|
||||||
|
- Use -Es/-I to invoke macro scriptlets (#1506355)
|
||||||
|
|
||||||
|
* Wed Aug 02 2017 Tomas Orsava <torsava@redhat.com> - 3-22
|
||||||
|
- Add platform-python macros (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack)
|
||||||
|
|
||||||
|
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3-21
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Mar 03 2017 Michal Cyprian <mcyprian@redhat.com> - 3-20
|
||||||
|
- Revert "Switch %%__python3 to /usr/libexec/system-python"
|
||||||
|
after the Fedora Change https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
|
||||||
|
was postponed
|
||||||
|
|
||||||
|
* Fri Feb 17 2017 Michal Cyprian <mcyprian@redhat.com> - 3-19
|
||||||
|
- Switch %%__python3 to /usr/libexec/system-python
|
||||||
|
|
||||||
|
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3-18
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||||
|
|
||||||
|
* Mon Jan 23 2017 Michal Cyprian <mcyprian@redhat.com> - 3-17
|
||||||
|
- Add --no-deps option to py_install_wheel macros
|
||||||
|
|
||||||
|
* Tue Jan 17 2017 Tomas Orsava <torsava@redhat.com> - 3-16
|
||||||
|
- Added macros for Build/Requires tags using Python dist tags:
|
||||||
|
https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
|
||||||
|
|
||||||
|
* Thu Nov 24 2016 Orion Poplawski <orion@cora.nwra.com> 3-15
|
||||||
|
- Make expanded macros start on the same line as the macro
|
||||||
|
|
||||||
|
* Wed Nov 16 2016 Orion Poplawski <orion@cora.nwra.com> 3-14
|
||||||
|
- Fix %%py3_install_wheel (bug #1395953)
|
||||||
|
|
||||||
|
* Wed Nov 16 2016 Orion Poplawski <orion@cora.nwra.com> 3-13
|
||||||
|
- Add missing sleeps to other build macros
|
||||||
|
- Fix build_egg macros
|
||||||
|
- Add %%py_build_wheel and %%py_install_wheel macros
|
||||||
|
|
||||||
|
* Tue Nov 15 2016 Orion Poplawski <orion@cora.nwra.com> 3-12
|
||||||
|
- Add %%py_build_egg and %%py_install_egg macros
|
||||||
|
- Allow multiple args to %%py_build/install macros
|
||||||
|
- Tidy up macro formatting
|
||||||
|
|
||||||
|
* Wed Aug 24 2016 Orion Poplawski <orion@cora.nwra.com> 3-11
|
||||||
|
- Use %%rpmmacrodir
|
||||||
|
|
||||||
|
* Tue Jul 12 2016 Orion Poplawski <orion@cora.nwra.com> 3-10
|
||||||
|
- Do not generate useless Obsoletes with %%{?_isa}
|
||||||
|
|
||||||
|
* Fri May 13 2016 Orion Poplawski <orion@cora.nwra.com> 3-9
|
||||||
|
- Make python-rpm-macros require python-srpm-macros (bug #1335860)
|
||||||
|
|
||||||
|
* Thu May 12 2016 Jason L Tibbitts III <tibbs@math.uh.edu> - 3-8
|
||||||
|
- Add single-second sleeps to work around setuptools bug.
|
||||||
|
|
||||||
|
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3-7
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jan 14 2016 Orion Poplawski <orion@cora.nwra.com> 3-6
|
||||||
|
- Fix typo in %%python_provide
|
||||||
|
|
||||||
|
* Thu Jan 14 2016 Orion Poplawski <orion@cora.nwra.com> 3-5
|
||||||
|
- Handle noarch python sub-packages (bug #1290900)
|
||||||
|
|
||||||
|
* Wed Jan 13 2016 Orion Poplawski <orion@cora.nwra.com> 3-4
|
||||||
|
- Fix python2/3-rpm-macros package names
|
||||||
|
|
||||||
|
* Thu Jan 7 2016 Orion Poplawski <orion@cora.nwra.com> 3-3
|
||||||
|
- Add empty %%prep and %%build
|
||||||
|
|
||||||
|
* Mon Jan 4 2016 Orion Poplawski <orion@cora.nwra.com> 3-2
|
||||||
|
- Combined package
|
||||||
|
|
||||||
|
* Wed Dec 30 2015 Orion Poplawski <orion@cora.nwra.com> 3-1
|
||||||
|
- Initial package
|
Loading…
Reference in new issue