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

Fix usedevelop without setup.py #2198

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2197.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue when using usedevelop with a project that has no setup.py -- by :user:`AntoineD`.
34 changes: 21 additions & 13 deletions src/tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from itertools import chain

import py
import setuptools

import tox
from tox import reporter
Expand Down Expand Up @@ -323,20 +324,27 @@ def finish(self):
def _needs_reinstall(self, setupdir, action):
setup_py = setupdir.join("setup.py")
setup_cfg = setupdir.join("setup.cfg")
args = [self.envconfig.envpython, str(setup_py), "--name"]
env = self._get_os_environ()
output = action.popen(
args,
cwd=setupdir,
redirect=False,
returnout=True,
env=env,
capture_err=False,
)
name = next(
(i for i in output.split("\n") if i and not i.startswith("pydev debugger:")),
"",
)

if setup_py.exists():
args = [self.envconfig.envpython, str(setup_py), "--name"]
output = action.popen(
args,
cwd=setupdir,
redirect=False,
returnout=True,
env=env,
capture_err=False,
)
name = next(
(i for i in output.split("\n") if i and not i.startswith("pydev debugger:")),
"",
)
else:
dist = setuptools.Distribution()
dist.parse_config_files()
name = dist.metadata.name

args = [
self.envconfig.envpython,
"-c",
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,38 @@ def test_hello(pytestconfig):
assert "develop-inst-nodeps" in result.out


def test_usedevelop_with_setup_cfg_no_setup_py(cmd, initproj):
"""Verify that an env with usedevelop enabled, no setup.py and a setup.cfg
can survive more than one tox execution."""
name = "example123-spameggs"
initproj(
(name, "0.5"),
filedefs={
"tox.ini": """
[testenv]
usedevelop=True
""",
"setup.cfg": """
[metadata]
name={}
[options]
package_dir =
=.
packages = find:
[options.packages.find]
where = .
""".format(
name
),
},
add_missing_setup_py=False,
)
result = cmd("-v")
result.assert_success()
result = cmd("-v")
result.assert_success()


def test_warning_emitted(cmd, initproj):
initproj(
"spam-0.0.1",
Expand Down