Skip to content

Commit 2343c6a

Browse files
graingertgaborbernat
authored andcommitted
clarify legacy setup.py error message further (#1478)
a follow up to #1467
1 parent 760b034 commit 2343c6a

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Sorin Sbarnea
7878
Sridhar Ratnakumar
7979
Stephen Finucane
8080
Sviatoslav Sydorenko
81+
Thomas Grainger
8182
Tim Laurence
8283
Ville Skyttä
8384
Xander Johnson

docs/changelog/1478.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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

src/tox/package/builder/legacy.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@
88

99
def make_sdist(config, session):
1010
setup = config.setupdir.join("setup.py")
11-
if not setup.check():
11+
pyproject = config.setupdir.join("pyproject.toml")
12+
setup_check = setup.check()
13+
if not setup_check and not pyproject.check():
1214
reporter.error(
13-
"No setup.py file found. The expected location is:\n"
14-
" {}\n"
15+
"No pyproject.toml or setup.py file found. The expected locations are:\n"
16+
" {pyproject} or {setup}\n"
1517
"You can\n"
1618
" 1. Create one:\n"
1719
" https://tox.readthedocs.io/en/latest/example/package.html\n"
1820
" 2. Configure tox to avoid running sdist:\n"
1921
" https://tox.readthedocs.io/en/latest/example/general.html\n"
20-
" 3. Configure tox to use an isolated_build".format(setup)
22+
" 3. Configure tox to use an isolated_build".format(pyproject=pyproject, setup=setup)
23+
)
24+
raise SystemExit(1)
25+
if not setup_check:
26+
reporter.error(
27+
"pyproject.toml file found.\n"
28+
"To use a PEP 517 build-backend you are required to "
29+
"configure tox to use an isolated_build:\n"
30+
"https://tox.readthedocs.io/en/latest/example/package.html\n"
2131
)
2232
raise SystemExit(1)
2333
with session.newaction("GLOB", "packaging") as action:

tests/unit/test_z_cmdline.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import tempfile
88

9+
import pathlib2
910
import py
1011
import pytest
1112

@@ -411,7 +412,31 @@ def test_no_setup_py_exits(cmd, initproj):
411412
result = cmd()
412413
result.assert_fail()
413414
assert any(
414-
re.match(r".*ERROR.*No setup.py file found.*", l) for l in result.outlines
415+
re.match(r".*ERROR.*No pyproject.toml or setup.py file found.*", l)
416+
for l in result.outlines
417+
), result.outlines
418+
419+
420+
def test_no_setup_py_exits_but_pyproject_toml_does(cmd, initproj):
421+
initproj(
422+
"pkg123-0.7",
423+
filedefs={
424+
"tox.ini": """
425+
[testenv]
426+
commands=python -c "2 + 2"
427+
"""
428+
},
429+
)
430+
os.remove("setup.py")
431+
pathlib2.Path("pyproject.toml").touch()
432+
result = cmd()
433+
result.assert_fail()
434+
assert any(
435+
re.match(r".*ERROR.*pyproject.toml file found.*", l) for l in result.outlines
436+
), result.outlines
437+
assert any(
438+
re.match(r".*To use a PEP 517 build-backend you are required to*", l)
439+
for l in result.outlines
415440
), result.outlines
416441

417442

0 commit comments

Comments
 (0)