Support PEP 517 list based backend-path

The PEP 517 shows an example backend-path like this:

    [build-system]
    # Defined by PEP 518:
    requires = ["flit"]
    # Defined by this PEP:
    build-backend = "local_backend"
    backend-path = ["backend"]

https://www.python.org/dev/peps/pep-0517/#source-trees

See that backend-path is a list. Our code previously only supported string path.

Obviously a string path is wrong, but we keep it to support projects that have
made the mistake, such as flit-core.

Add a small integration test for both cases.
Note that the new spec files deliberately don't do much, to save CI time.
This commit is contained in:
Miro Hrončok 2020-10-06 00:30:45 +02:00
parent d719a00b93
commit 290941c5f3
5 changed files with 102 additions and 2 deletions

View File

@ -6,7 +6,7 @@ License: MIT
# Keep the version at zero and increment only release
Version: 0
Release: 30%{?dist}
Release: 31%{?dist}
# Macro files
Source001: macros.pyproject
@ -94,6 +94,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%license LICENSE
%changelog
* Mon Oct 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-31
- Support PEP 517 list based backend-path
* Tue Sep 29 2020 Lumír Balhar <lbalhar@redhat.com> - 0-30
- Process RECORD files in %%pyproject_install and remove them
- Support the extras configuration option of tox in %%pyproject_buildrequires -t

View File

@ -185,7 +185,10 @@ def get_backend(requirements):
backend_path = buildsystem_data.get('backend-path')
if backend_path:
sys.path.insert(0, backend_path)
# PEP 517 example shows the path as a list, but some projects don't follow that
if isinstance(backend_path, str):
backend_path = [backend_path]
sys.path = backend_path + sys.path
module_name, _, object_name = backend_name.partition(":")
backend_module = importlib.import_module(module_name)

View File

@ -0,0 +1,43 @@
Name: python-flit-core
Version: 3.0.0
Release: 0%{?dist}
Summary: Distribution-building parts of Flit
License: BSD
URL: https://pypi.org/project/flit-core/
Source0: %{pypi_source flit_core}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
Test a build with pyproject.toml backend-path = .
flit-core builds with flit-core.
%package -n python3-flit-core
Summary: %{summary}
%description -n python3-flit-core
...
%prep
%autosetup -p1 -n flit_core-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files flit_core
%files -n python3-flit-core -f %{pyproject_files}

View File

@ -0,0 +1,45 @@
Name: python-poetry-core
Version: 1.0.0
Release: 0%{?dist}
Summary: Poetry PEP 517 Build Backend
License: MIT
URL: https://pypi.org/project/poetry-core/
Source0: %{pypi_source poetry-core}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
Test a build with pyproject.toml backend-path = [.]
poetry-core builds with poetry-core.
%package -n python3-poetry-core
Summary: %{summary}
%description -n python3-poetry-core
...
%prep
%autosetup -p1 -n poetry-core-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files poetry
%files -n python3-poetry-core -f %{pyproject_files}
%doc README.md
%license LICENSE

View File

@ -67,6 +67,12 @@
- dns_lexicon:
dir: .
run: ./mocktest.sh python-dns-lexicon
- flit_core:
dir: .
run: ./mocktest.sh python-flit-core
- poetry_core:
dir: .
run: ./mocktest.sh python-poetry-core
required_packages:
- mock
- rpmdevtools