Skip to content

Commit

Permalink
Do not reinstall in develop mode without setup.py (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentVanlaer committed Dec 29, 2021
1 parent 0985677 commit 72e2391
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Tim Laurence
Tyagraj Desigar
Usama Sadiq
Ville Skyttä
Vincent Vanlaer
Vlastimil Zíma
Xander Johnson
anatoly techtonik
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 where ``usedevelop`` would cause an invocation error if setup.py does not exist. -- by :user:`VincentVanlaer`
4 changes: 3 additions & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ Complete list of settings that you can put into ``testenv*`` sections:
Install the current package in development mode with "setup.py
develop" instead of installing from the ``sdist`` package. (This
uses pip's ``-e`` option, so should be avoided if you've specified a
custom :conf:`install_command` that does not support ``-e``).
custom :conf:`install_command` that does not support ``-e``). Note that
changes to the build/install process (including changes in dependencies)
are only detected when using setuptools with setup.py.

.. conf:: skip_install ^ true|false ^ false

Expand Down
4 changes: 4 additions & 0 deletions src/tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ def finish(self):

def _needs_reinstall(self, setupdir, action):
setup_py = setupdir.join("setup.py")

if not setup_py.exists():
return False

setup_cfg = setupdir.join("setup.cfg")
args = [self.envconfig.envpython, str(setup_py), "--name"]
env = self._get_os_environ()
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_create(mocksession, newconfig):
assert not venv.path.check()
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) >= 1
args = pcalls[0].args
Expand Down Expand Up @@ -135,6 +136,7 @@ def test_create_sitepackages(mocksession, newconfig):
venv = mocksession.getvenv("site")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) >= 1
args = pcalls[0].args
Expand All @@ -144,6 +146,7 @@ def test_create_sitepackages(mocksession, newconfig):
venv = mocksession.getvenv("nosite")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) >= 1
args = pcalls[0].args
Expand All @@ -165,6 +168,7 @@ def test_install_deps_wildcard(newmocksession):
venv = mocksession.getvenv("py123")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
distshare = venv.envconfig.config.distshare
Expand Down Expand Up @@ -201,6 +205,7 @@ def test_install_deps_indexserver(newmocksession):
venv = mocksession.getvenv("py123")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
pcalls[:] = []
Expand Down Expand Up @@ -233,6 +238,7 @@ def test_install_deps_pre(newmocksession):
venv = mocksession.getvenv("python")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
pcalls[:] = []
Expand Down Expand Up @@ -294,6 +300,7 @@ def test_install_sdist_extras(newmocksession):
venv = mocksession.getvenv("python")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
pcalls[:] = []
Expand All @@ -314,6 +321,7 @@ def test_develop_extras(newmocksession, tmpdir):
venv = mocksession.getvenv("python")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
pcalls[:] = []
Expand Down Expand Up @@ -519,6 +527,7 @@ def test_install_python3(newmocksession):
venv = mocksession.getvenv("py123")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) == 1
args = pcalls[0].args
Expand Down Expand Up @@ -1177,6 +1186,7 @@ def test_create_download(mocksession, newconfig, download):
venv = mocksession.getvenv("env")
with mocksession.newaction(venv.name, "getenv") as action:
tox_testenv_create(action=action, venv=venv)
venv.just_created = True
pcalls = mocksession._pcalls
assert len(pcalls) >= 1
args = pcalls[0].args
Expand Down

0 comments on commit 72e2391

Please sign in to comment.