From 681cc65e498dc1fdae9e7a497dfd944c3089272f Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Wed, 8 Jun 2022 12:11:27 +0000 Subject: [PATCH] %pyproject_install: pass %{_prefix} explicitly to pip install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes things work for %{_prefix} other than user, when combined with a change in python-rpm-macros to the definition of python3_sitelib/python3_sitearch. https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/KEQMMNJ4HTTHSQLK6P4DJJTVPA36SS3W/ Related: rhbz#2117571 Co-Authored-By: Miro Hrončok --- macros.pyproject | 2 +- pyproject-rpm-macros.spec | 5 ++++- tests/tldr.spec | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/macros.pyproject b/macros.pyproject index bf412f7..31267ac 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -54,7 +54,7 @@ echo $(IFS=:; echo "${pyproject_build_lib[*]}") %pyproject_install() %{expand:\\\ specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/') -TMPDIR="%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier +TMPDIR="%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --prefix %{_prefix} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier if [ -d %{buildroot}%{_bindir} ]; then %py3_shebang_fix %{buildroot}%{_bindir}/* rm -rfv %{buildroot}%{_bindir}/__pycache__ diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 09bf0f8..e264e2a 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.0 +Version: 1.3.1 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 +* Tue Jun 27 2022 Owen Taylor - 1.3.1-1 +- %%pyproject_install: pass %%{_prefix} explicitly to pip install + * Thu May 12 2022 Miro Hrončok - 1.3.0-1 - Use tomllib from the standard library on Python 3.11+ diff --git a/tests/tldr.spec b/tests/tldr.spec index 2924485..3788821 100644 --- a/tests/tldr.spec +++ b/tests/tldr.spec @@ -11,12 +11,19 @@ BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros +%if 0%{?fedora} >= 36 || 0%{?rhel} >= 10 +# Internal check for our macros: test that we can install to a custom prefix +BuildRequires: python3-rpm-macros >= 3.10-18 +%global _prefix /app +%endif + %description A Python package containing executables. Building this tests: - there are no bytecompiled files in %%{_bindir} - the executable's shebang is adjusted properly - file direct_url.json isn't created +- installation to custom prefix works %prep %autosetup -n %{name}-%{version} @@ -48,6 +55,12 @@ test "%{pyproject_build_lib}" == "${PWD}/build/lib" test "%{pyproject_build_lib}" == "$(echo %{_pyproject_builddir}/pip-req-build-*/build/lib)" %endif +%if 0%{?fedora} >= 36 || 0%{?rhel} >= 10 +# Internal check for custom prefix +grep '^/usr' %{pyproject_files} && exit 1 || true +grep '^/app' %{pyproject_files} +%endif + %files -f %pyproject_files %license LICENSE %doc README.md