diff options
author | Thomas Grainger <tagrain@gmail.com> | 2019-12-06 11:22:38 +0000 |
---|---|---|
committer | Bernát Gábor <bgabor8@bloomberg.net> | 2019-12-06 11:22:38 +0000 |
commit | 2343c6a010bfdb24577e86ad7c3606ce8d12da62 (patch) | |
tree | 99909e959f7b8bae857e7c67c2409dc66d0e79b4 | |
parent | 760b0343808c8a8439784036827cfcb1c98e441f (diff) | |
download | tox-git-2343c6a010bfdb24577e86ad7c3606ce8d12da62.tar.gz |
clarify legacy setup.py error message further (#1478)
a follow up to #1467
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | docs/changelog/1478.misc.rst | 1 | ||||
-rw-r--r-- | src/tox/package/builder/legacy.py | 18 | ||||
-rw-r--r-- | tests/unit/test_z_cmdline.py | 27 |
4 files changed, 42 insertions, 5 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 54209380..f944ddb2 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -78,6 +78,7 @@ Sorin Sbarnea Sridhar Ratnakumar Stephen Finucane Sviatoslav Sydorenko +Thomas Grainger Tim Laurence Ville Skyttä Xander Johnson diff --git a/docs/changelog/1478.misc.rst b/docs/changelog/1478.misc.rst new file mode 100644 index 00000000..4ad6bb41 --- /dev/null +++ b/docs/changelog/1478.misc.rst @@ -0,0 +1 @@ +Clarify legacy setup.py error message: python projects should commit to a strong consistency of message regarding packaging. We no-longer tell people to add a setup.py to their already configured pep-517 project, otherwise it could imply that pyproject.toml isn't as well supported and recommended as it truly is - by :user:graingert diff --git a/src/tox/package/builder/legacy.py b/src/tox/package/builder/legacy.py index 935a68ab..ffe5ebd0 100644 --- a/src/tox/package/builder/legacy.py +++ b/src/tox/package/builder/legacy.py @@ -8,16 +8,26 @@ from tox.util.path import ensure_empty_dir def make_sdist(config, session): setup = config.setupdir.join("setup.py") - if not setup.check(): + pyproject = config.setupdir.join("pyproject.toml") + setup_check = setup.check() + if not setup_check and not pyproject.check(): reporter.error( - "No setup.py file found. The expected location is:\n" - " {}\n" + "No pyproject.toml or setup.py file found. The expected locations are:\n" + " {pyproject} or {setup}\n" "You can\n" " 1. Create one:\n" " https://tox.readthedocs.io/en/latest/example/package.html\n" " 2. Configure tox to avoid running sdist:\n" " https://tox.readthedocs.io/en/latest/example/general.html\n" - " 3. Configure tox to use an isolated_build".format(setup) + " 3. Configure tox to use an isolated_build".format(pyproject=pyproject, setup=setup) + ) + raise SystemExit(1) + if not setup_check: + reporter.error( + "pyproject.toml file found.\n" + "To use a PEP 517 build-backend you are required to " + "configure tox to use an isolated_build:\n" + "https://tox.readthedocs.io/en/latest/example/package.html\n" ) raise SystemExit(1) with session.newaction("GLOB", "packaging") as action: diff --git a/tests/unit/test_z_cmdline.py b/tests/unit/test_z_cmdline.py index f8681f74..71d2d796 100644 --- a/tests/unit/test_z_cmdline.py +++ b/tests/unit/test_z_cmdline.py @@ -6,6 +6,7 @@ import subprocess import sys import tempfile +import pathlib2 import py import pytest @@ -411,7 +412,31 @@ def test_no_setup_py_exits(cmd, initproj): result = cmd() result.assert_fail() assert any( - re.match(r".*ERROR.*No setup.py file found.*", l) for l in result.outlines + re.match(r".*ERROR.*No pyproject.toml or setup.py file found.*", l) + for l in result.outlines + ), result.outlines + + +def test_no_setup_py_exits_but_pyproject_toml_does(cmd, initproj): + initproj( + "pkg123-0.7", + filedefs={ + "tox.ini": """ + [testenv] + commands=python -c "2 + 2" + """ + }, + ) + os.remove("setup.py") + pathlib2.Path("pyproject.toml").touch() + result = cmd() + result.assert_fail() + assert any( + re.match(r".*ERROR.*pyproject.toml file found.*", l) for l in result.outlines + ), result.outlines + assert any( + re.match(r".*To use a PEP 517 build-backend you are required to*", l) + for l in result.outlines ), result.outlines |