diff --git a/README.md b/README.md index 970580b..cd01b5d 100644 --- a/README.md +++ b/README.md @@ -336,91 +336,6 @@ These arguments are still required: Multiple subpackages are generated when multiple names are provided. -PROVISIONAL: Importing just-built (extension) modules in %build ---------------------------------------------------------------- - -Sometimes, it is desired to be able to import the *just-built* extension modules -in the `%build` section, e.g. to build the documentation with Sphinx. - - %build - %pyproject_wheel - ... build the docs here ... - -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, etc. -Hence, the macro `%{pyproject_build_lib}` exists to be used like this: - - %build - %pyproject_wheel - PYTHONPATH=%{pyproject_build_lib} ... build the docs here ... - -This macro is currently **provisional** and the behavior might change. -Please subscribe to Fedora's [python-devel list] if you use the macro. - -The `%{pyproject_build_lib}` macro expands to an Shell `$(...)` expression and does not work when put into single quotes (`'`). - -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 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: - -* `/builddir/build/BUILD/%{name}-%{version}/build/lib.linux-x86_64-3.10` 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-3.10:/builddir/build/BUILD/%{name}-%{version}/build/lib` - -If multiple wheels were built from different directories, -the value will differ depending on the current directory. - - -### Older pip with out-of-tree-build (Fedora 35 and EL 9) - -The value will expand to something like: - -* `/builddir/build/BUILD/%{name}-%{version}/.pyproject-builddir/pip-req-build-xxxxxxxx/build/lib.linux-x86_64-3.10` for wheels with extension modules -* `/builddir/build/BUILD/%{name}-%{version}/.pyproject-builddir/pip-req-build-xxxxxxxx/build/lib` for pure Python wheels - -Note that the exact value is **not stable** between builds -(the `xxxxxxxx` part is randomly generated, -neither you should consider the `.pyproject-builddir` directory to remain stable). - -If multiple wheels are built, -the expanded value will always be combined with `:` regardless of the current directory, e.g.: - -* `/builddir/build/BUILD/%{name}-%{version}/.pyproject-builddir/pip-req-build-xxxxxxxx/build/lib.linux-x86_64-3.10:/builddir/build/BUILD/%{name}-%{version}/.pyproject-builddir/pip-req-build-yyyyyyyy/build/lib.linux-x86_64-3.10:/builddir/build/BUILD/%{name}-%{version}/.pyproject-builddir/pip-req-build-zzzzzzzz/build/lib` - -**Note:** If you manage to build some wheels with in-tree-build and some with out-of-tree-build option, -the expanded value will contain all relevant directories. - - Limitations ----------- @@ -473,6 +388,12 @@ so be prepared for problems. [pip's documentation]: https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support +Deprecated +---------- + +The `%{pyproject_build_lib}` macro is deprecated, don't use it. + + Testing the macros ------------------ diff --git a/macros.pyproject b/macros.pyproject index 2387476..16efc58 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -34,7 +34,14 @@ CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDI } -%pyproject_build_lib %{expand:\\\ +%pyproject_build_lib %{!?__pyproject_build_lib_warned:%{warn:The %%{pyproject_build_lib} macro is deprecated. +It only works with setuptools and is not build-backend-agnostic. +The macro is not scheduled for removal, but there is a possibility of incompatibilities with future versions of setuptools. +As a replacement for the macro for the setuptools backend on Fedora 37+, you can use $PWD/build/lib for pure Python packages, +or $PWD/build/lib.%%{python3_platform}-cpython-%%{python3_version_nodots} for packages with extension modules. +Other build backends and older distributions may need different paths. +See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/HMLOPAU3RZLXD4BOJHTIPKI3I4U6U7OE/ for details. +}%{global __pyproject_build_lib_warned 1}}%{expand:\\\ $( pyproject_build_lib=() if [ -d build/lib.%{python3_platform}-cpython-%{python3_version_nodots} ]; then diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index b504287..0a238ec 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -10,7 +10,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.7.0 +Version: 1.8.0 Release: 1%{?dist} # Macro files @@ -147,6 +147,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog +* Tue Apr 18 2023 Miro Hrončok - 1.8.0-1 +- Deprecate the provisional %%{pyproject_build_lib} macro +- See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/HMLOPAU3RZLXD4BOJHTIPKI3I4U6U7OE/ + * Fri Mar 31 2023 Miro Hrončok - 1.7.0-1 - %%pyproject_buildrequires: Redirect stdout to stderr via Shell - Dependencies are recorded to a text file that is catted at the end