diff options
| author | layday <layday@protonmail.com> | 2021-03-16 18:58:11 +0200 |
|---|---|---|
| committer | layday <layday@protonmail.com> | 2021-03-16 19:06:29 +0200 |
| commit | 024b1e13b644cc9829d2a15cd5867920e11c9a9e (patch) | |
| tree | f9036b027b5541e7e5c7fd1d44a616d3d02d8535 /setuptools | |
| parent | 8230bbf82b07d25bcc65e612e0e936dce269e463 (diff) | |
| download | python-setuptools-git-024b1e13b644cc9829d2a15cd5867920e11c9a9e.tar.gz | |
build_meta: produce informative error when a dist is not found
Previously, when `build_sdist` or `build_wheel` were unable
to build a distribution (and were therefore unable to find the
distribution file), they would throw a
ValueError: not enough values to unpack (expected 1, got 0)
which did not offer any clues as to where the issue might lie.
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/build_meta.py | 8 | ||||
| -rw-r--r-- | setuptools/tests/test_build_meta.py | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index b9e8a2b3..3c45db72 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -101,8 +101,12 @@ def _file_with_extension(directory, extension): f for f in os.listdir(directory) if f.endswith(extension) ) - file, = matching - return file + try: + return next(matching) + except StopIteration: + raise ValueError('No distribution was found. The distribution was ' + 'possibly not built. Ensure that your `setup.py` ' + 'is not empty and that it calls `setup()`.') def _open_setup_script(setup_script): diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index f33a6968..f776b09d 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -3,6 +3,7 @@ import shutil import tarfile import importlib from concurrent import futures +import re import pytest from jaraco import path @@ -442,6 +443,19 @@ class TestBuildMetaBackend: with pytest.raises(AssertionError): build_backend.build_sdist("temp") + @pytest.mark.parametrize('build_hook', ('build_sdist', 'build_wheel')) + def test_build_with_empty_setuppy(self, build_backend, build_hook): + files = {'setup.py': ''} + path.build(files) + + with pytest.raises( + ValueError, + match=re.escape( + 'No distribution was found. The distribution was ' + 'possibly not built. Ensure that your `setup.py` ' + 'is not empty and that it calls `setup()`.')): + getattr(build_backend, build_hook)("temp") + class TestBuildMetaLegacyBackend(TestBuildMetaBackend): backend_name = 'setuptools.build_meta:__legacy__' |
