Clarify the need for setup.py with PEP517

There was a misunderstanding that PBRs PEP517 build hooks meant we no
longer needed a setup.py. But it turns out the setuptools build_meta
hooks that we wrap call out to setup.py. This means PBR will continue to
need to be used in conjunction with a setup.py.

This is better for backward compatibiltiy anyway so not a huge loss.

Document this more properly and update the test to reflect it.

Change-Id: If4320da1e89a5c765e0bfe56b724364f9cba34f3
This commit is contained in:
Clark Boylan 2021-11-08 08:56:18 -08:00
parent 09ee153410
commit d21c2caf1d
2 changed files with 12 additions and 7 deletions

View File

@ -37,8 +37,11 @@ something like this::
``pyproject.toml`` ``pyproject.toml``
------------------ ------------------
As an alternative to writing a ``setup.py`` you can instead setup PBR PBR can be configured as a PEP517 build-system in ``pyproject.toml``. This
through the PEP 517 build-system configuration in ``pyproject.toml``. currently continues to rely on setuptools which means you need the above
``setup.py`` file to be present. The main benefits to using a
``pyproject.toml`` file with PBR are that you can control the versions of
PBR, setuptools, and wheel that are used avoiding easy_install invocation.
Your build-system block in ``pyproject.toml`` will need to look something Your build-system block in ``pyproject.toml`` will need to look something
like this:: like this::
@ -46,6 +49,10 @@ like this::
requires = ["pbr>=5.7.0", "setuptools>=36.6.0", "wheel"] requires = ["pbr>=5.7.0", "setuptools>=36.6.0", "wheel"]
build-backend = "pbr.build" build-backend = "pbr.build"
Eventually PBR may grow its own direct support for PEP517 build hooks, but
until then it will continue to need setuptools and ``setup.py``.
.. _setup_cfg: .. _setup_cfg:
``setup.cfg`` ``setup.cfg``

View File

@ -229,9 +229,6 @@ class CreatePackages(fixtures.Fixture):
self.packages = packages self.packages = packages
def _writeFile(self, directory, file_name, contents): def _writeFile(self, directory, file_name, contents):
if not contents:
# We want to be able to override not having files
return
path = os.path.abspath(os.path.join(directory, file_name)) path = os.path.abspath(os.path.join(directory, file_name))
path_dir = os.path.dirname(path) path_dir = os.path.dirname(path)
if not os.path.exists(path_dir): if not os.path.exists(path_dir):
@ -924,6 +921,8 @@ class TestRequirementParsing(base.BaseTestCase):
class TestPEP517Support(base.BaseTestCase): class TestPEP517Support(base.BaseTestCase):
def test_pep_517_support(self): def test_pep_517_support(self):
# Note that the current PBR PEP517 entrypoints rely on a valid
# PBR setup.py existing.
pkgs = { pkgs = {
'test_pep517': 'test_pep517':
{ {
@ -931,8 +930,7 @@ class TestPEP517Support(base.BaseTestCase):
sphinx sphinx
iso8601 iso8601
"""), """),
# Override no setup.py. # Use default PBR test setup.py.
'setup.py': '',
'setup.cfg': textwrap.dedent("""\ 'setup.cfg': textwrap.dedent("""\
[metadata] [metadata]
name = test_pep517 name = test_pep517