diff --git a/README.md b/README.md index a4a63fd..1a33dfe 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ And install the wheel in `%install` with `%pyproject_install`: %install %pyproject_install -`%pyproject_install` installs all wheels in `$PWD/pyproject-wheeldir/`. +`%pyproject_install` installs all wheels in `pyproject-wheeldir/` located in the root of the source tree. Adding run-time and test-time dependencies diff --git a/macros.pyproject b/macros.pyproject index 67afe89..7c72f6c 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -1,5 +1,5 @@ # This is a directory where wheels are stored and installed from, relative to PWD -%_pyproject_wheeldir pyproject-wheeldir +%_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir # This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD # For proper debugsource packages, we create TMPDIR within PWD @@ -8,22 +8,22 @@ # This will be used in debugsource package paths (applies to extension modules only) # NB: pytest collects tests from here if not hidden # https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs -%_pyproject_builddir .pyproject-builddir +%_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir %pyproject_files %{_builddir}/pyproject-files %pyproject_ghost_distinfo %{_builddir}/pyproject-ghost-distinfo %pyproject_record %{_builddir}/pyproject-record %pyproject_wheel() %{expand:\\\ -mkdir -p "${PWD}/%{_pyproject_builddir}" -CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="${PWD}/%{_pyproject_builddir}" \\\ +mkdir -p "%{_pyproject_builddir}" +CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="%{_pyproject_builddir}" \\\ %{__python3} -m pip wheel --wheel-dir %{_pyproject_wheeldir} --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --no-clean --progress-bar off --verbose . } %pyproject_install() %{expand:\\\ specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/') -TMPDIR="${PWD}/%{_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} --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 98578bc..29603a0 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -112,6 +112,7 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog * Thu May 27 2021 Miro Hrončok - 0-40 - Don't leak $TMPDIR outside of pyproject macros +- Set %%_pyproject_wheeldir and %%_pyproject_builddir relative to the source tree, not $PWD * Thu Apr 22 2021 Miro Hrončok - 0-39.2 - Handle tox provision (tox.requires / tox.minversion) diff --git a/tests/python-flit-core.spec b/tests/python-flit-core.spec index 45df12b..d3333d8 100644 --- a/tests/python-flit-core.spec +++ b/tests/python-flit-core.spec @@ -5,13 +5,14 @@ Summary: Distribution-building parts of Flit License: BSD URL: https://pypi.org/project/flit-core/ -Source0: %{pypi_source flit_core} +Source0: https://github.com/takluyver/flit/archive/%{version}/flit-%{version}.tar.gz BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros %description +Test a wheel built from a subdirectory. Test a build with pyproject.toml backend-path = . flit-core builds with flit-core. @@ -24,15 +25,18 @@ Summary: %{summary} %prep -%autosetup -p1 -n flit_core-%{version} +%autosetup -p1 -n flit-%{version} %generate_buildrequires +cd flit_core %pyproject_buildrequires - +cd .. %build +cd flit_core %pyproject_wheel +cd .. %install