From e9ea68926bdf55cacadf12862cc5b5316f72e597 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 16 Jun 2022 12:00:09 +0000 Subject: [PATCH] %pyproject_build_lib: support setuptools 62.1.0 and later Related: rhbz#2117571 --- README.md | 22 ++++++++++++++++++++-- macros.pyproject | 3 +++ pyproject-rpm-macros.spec | 5 ++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce32b7b..d2dcb98 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ in the `%build` section, e.g. to build the documentation with Sphinx. With pure Python packages, it might be possible to set `PYTHONPATH=${PWD}` or `PYTHONPATH=${PWD}/src`. However, it is a bit more complicated with extension modules. -The location of just-built modules might differ depending on Python version, architecture, pip version. +The location of just-built modules might differ depending on Python version, architecture, pip version, etc. Hence, the macro `%{pyproject_build_lib}` exists to be used like this: %build @@ -359,7 +359,25 @@ Depending on the pip version, the expanded value will differ: [python-devel list]: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/ -### New pip 21.3+ with in-tree-build (Fedora 36+) +### New pip 21.3+ with in-tree-build and setuptools 62.1+ (Fedora 37+) + +Always use the macro from the same directory where you called `%pyproject_wheel` from. +The value will expand to something like: + +* `/builddir/build/BUILD/%{name}-%{version}/build/lib.linux-x86_64-cpython-311` for wheels with extension modules +* `/builddir/build/BUILD/%{name}-%{version}/build/lib` for pure Python wheels + +If multiple wheels were built from the same directory, +some pure Python and some with extension modules, +the expanded value will be combined with `:`: + +* `/builddir/build/BUILD/%{name}-%{version}/build/lib.linux-x86_64-cypthon-311:/builddir/build/BUILD/%{name}-%{version}/build/lib` + +If multiple wheels were built from different directories, +the value will differ depending on the current directory. + + +### New pip 21.3+ with in-tree-build and older setuptools (Fedora 36) Always use the macro from the same directory where you called `%pyproject_wheel` from. The value will expand to something like: diff --git a/macros.pyproject b/macros.pyproject index 31267ac..a67a3f7 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -36,6 +36,9 @@ CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDI %pyproject_build_lib %{expand:\\\ $( pyproject_build_lib=() +if [ -d build/lib.%{python3_platform}-cpython-%{python3_version_nodots} ]; then + pyproject_build_lib+=( "${PWD}/build/lib.%{python3_platform}-cpython-%{python3_version_nodots}" ) +fi if [ -d build/lib.%{python3_platform}-%{python3_version} ]; then pyproject_build_lib+=( "${PWD}/build/lib.%{python3_platform}-%{python3_version}" ) fi diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 54bce50..dcdd07b 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -12,7 +12,7 @@ License: MIT # Increment Y and reset Z when new macros or features are added # Increment Z when this is a bugfix or a cosmetic change # Dropping support for EOL Fedoras is *not* considered a breaking change -Version: 1.3.1 +Version: 1.3.2 Release: 1%{?dist} # Macro files @@ -126,6 +126,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %license LICENSE %changelog +* Wed Jun 15 2022 Benjamin A. Beasley - 1.3.2-1 +- Update %%pyproject_build_lib to support setuptools 62.1.0 and later + * Fri May 27 2022 Owen Taylor - 1.3.1-1 - %%pyproject_install: pass %%{_prefix} explicitly to pip install