Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify legacy setup.py error message further #1478

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Sorin Sbarnea
Sridhar Ratnakumar
Stephen Finucane
Sviatoslav Sydorenko
Thomas Grainger
Tim Laurence
Ville Skyttä
Xander Johnson
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1478.misc.rst
Original file line number Diff line number Diff line change
@@ -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
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
27 changes: 26 additions & 1 deletion tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import tempfile

import pathlib2
import py
import pytest

Expand Down Expand Up @@ -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


Expand Down