Skip to content

Commit

Permalink
clarify legacy setup.py error message further
Browse files Browse the repository at this point in the history
a follow up to #1467
  • Loading branch information
graingert committed Dec 5, 2019
1 parent 760b034 commit f485d87
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/tox/package/builder/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@

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:
Expand Down
26 changes: 25 additions & 1 deletion tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,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")
os.touch("pyproject.toml")
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


Expand Down

0 comments on commit f485d87

Please sign in to comment.