diff --git a/macros.pyproject b/macros.pyproject index 4b531be..e8cc8a6 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -97,10 +97,13 @@ echo 'python%{python3_pkgversion}dist(pip) >= 19' echo 'python%{python3_pkgversion}dist(packaging)' %{!-N:if [ -f pyproject.toml ]; then echo 'python%{python3_pkgversion}dist(toml)' -else +elif [ -f setup.py ]; then # Note: If the default requirements change, also change them in the script! echo 'python%{python3_pkgversion}dist(setuptools) >= 40.8' echo 'python%{python3_pkgversion}dist(wheel)' +else + echo 'ERROR: Neither pyproject.toml nor setup.py found, consider using %%%%pyproject_buildrequires -N if this is not a Python package.' >&2 + exit 1 fi} # Check if we can generate dependencies on Python extras if [ "%{py_dist_name []}" == "[]" ]; then diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 77e0ab7..7c2b283 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -104,11 +104,13 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %license LICENSE %changelog -* Fri Jul 09 2021 Miro HronĨok - 0-44 +* Fri Jul 09 2021 Python Maint - 0-44 - Escape weird paths generated by %%pyproject_save_files - Fixes rhbz#1976363 - Support x.* versions in %%pyproject_buildrequires - Fixes rhbz#1981558 +- %%pyproject_buildrequires fallbacks to setuptools only if setup.py exists +- Fixes: rhbz#1976459 * Thu Jul 01 2021 Tomas Hrnciar - 0-43 - Generate BuildRequires from file diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index 42fd77a..f507748 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -181,6 +181,10 @@ def get_backend(requirements): # missing, the source tree is not using this specification, and tools # should revert to the legacy behaviour of running setup.py # (either directly, or by implicitly invoking the [following] backend). + # If setup.py is also not present program will mimick pip's behavior + # and end with an error. + if not os.path.exists('setup.py'): + raise FileNotFoundError('File "setup.py" not found for legacy project.') backend_name = 'setuptools.build_meta:__legacy__' # Note: For projects without pyproject.toml, this was already echoed diff --git a/pyproject_buildrequires_testcases.yaml b/pyproject_buildrequires_testcases.yaml index 224503e..c1e4ee6 100644 --- a/pyproject_buildrequires_testcases.yaml +++ b/pyproject_buildrequires_testcases.yaml @@ -1,10 +1,7 @@ No pyproject.toml, nothing installed: installed: # empty - expected: | - python3dist(setuptools) >= 40.8 - python3dist(wheel) - result: 0 + except: FileNotFoundError Nothing installed yet: installed: @@ -14,7 +11,7 @@ Nothing installed yet: expected: | python3dist(setuptools) >= 40.8 python3dist(wheel) - result: 0 + except: FileNotFoundError Insufficient version of setuptools: installed: @@ -23,6 +20,7 @@ Insufficient version of setuptools: toml: 1 pyproject.toml: | # empty + setup.py: | expected: | python3dist(setuptools) >= 40.8 python3dist(wheel) @@ -53,6 +51,24 @@ Default build system, empty setup.py: python3dist(wheel) result: 0 +pyproject.toml with build-backend and setup.py: + generate_extras: true + installed: + setuptools: 50 + wheel: 1 + toml: 1 + setup.py: | + # empty + pyproject.toml: | + [build-system] + requires = [ + "foo", + ] + build-backend = "foo.build" + expected: | + python3dist(foo) + result: 0 + Erroring setup.py: installed: setuptools: 50 @@ -74,7 +90,8 @@ Single value version with unsupported compatible operator: toml: 1 pyproject.toml: | [build-system] - requires = ["pkg ~= 42"] + requires = ["pkg ~= 42", "foo"] + build-backend = "foo.build" stderr_contains: "WARNING: Skipping invalid requirement: pkg ~= 42" result: 0 @@ -83,7 +100,8 @@ Asterisk in version with unsupported compatible operator: toml: 1 pyproject.toml: | [build-system] - requires = ["pkg ~= 0.1.*"] + requires = ["pkg ~= 0.1.*", "foo"] + build-backend = "foo.build" stderr_contains: "WARNING: Skipping invalid requirement: pkg ~= 0.1.*" result: 0 @@ -113,6 +131,7 @@ Build system dependencies in pyproject.toml with extras: "py2 ; python_version < '2.7'", "py3 ; python_version > '3.0'", ] + build-backend = "foo.build" expected: | python3dist(foo) python3dist(bar) > 5 @@ -131,8 +150,6 @@ Build system dependencies in pyproject.toml with extras: python3dist(multi[extras2]) = 6 ((python3dist(combo) < 3 or python3dist(combo) > 3) with python3dist(combo) < 5 with python3dist(combo) > 2) python3dist(py3) - python3dist(setuptools) >= 40.8 - python3dist(wheel) result: 0 Build system dependencies in pyproject.toml without extras: @@ -147,11 +164,10 @@ Build system dependencies in pyproject.toml without extras: "bar[Baz] > 5", "multi[extras1,extras2] == 6.0", ] + build-backend = "foo.build" expected: | python3dist(bar) > 5 python3dist(multi) = 6 - python3dist(setuptools) >= 40.8 - python3dist(wheel) result: 0 Default build system, build dependencies in setup.py: