From 40f028a40a3f4268f4803a7b3835c528f06c2e6f Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Sat, 13 Nov 2021 15:58:51 +0100 Subject: [PATCH 1/2] Do not reinstall in develop mode without setup.py The detection logic for figuring out whether a editable install needs to be reinstalled only works for setuptools based builds using setup.py. If setup.py cannot be found the code will fail with an invocation error. Currently no standard mechanism exists to query a package installed in editable mode whether it should be reinstalled or not. Hence, this change skips reinstallation if setup.py cannot be found. Fixes #2197 --- CONTRIBUTORS | 1 + docs/changelog/2197.bugfix.rst | 1 + docs/config.rst | 4 +++- src/tox/venv.py | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/2197.bugfix.rst diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 455d7918d..3b2700d64 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -115,6 +115,7 @@ Tim Laurence Tyagraj Desigar Usama Sadiq Ville Skyttä +Vincent Vanlaer Vlastimil Zíma Xander Johnson anatoly techtonik diff --git a/docs/changelog/2197.bugfix.rst b/docs/changelog/2197.bugfix.rst new file mode 100644 index 000000000..9fc18563a --- /dev/null +++ b/docs/changelog/2197.bugfix.rst @@ -0,0 +1 @@ +Fixed an issue where ``usedevelop`` would cause an invocation error if setup.py does not exist. -- by :user:`VincentVanlaer` diff --git a/docs/config.rst b/docs/config.rst index da10f38c9..231ccc053 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -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 diff --git a/src/tox/venv.py b/src/tox/venv.py index 7ba743f80..cdd6949a1 100644 --- a/src/tox/venv.py +++ b/src/tox/venv.py @@ -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() From 8c4d6af88c0c843298f72cf2628121c06e28191e Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Sat, 13 Nov 2021 17:03:22 +0100 Subject: [PATCH 2/2] Ensure new envs are marked just_created in tests Otherwise install_pkg will not behave correctly when is_develop=True --- tests/unit/test_venv.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/test_venv.py b/tests/unit/test_venv.py index 37c471f3e..2d019034b 100644 --- a/tests/unit/test_venv.py +++ b/tests/unit/test_venv.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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[:] = [] @@ -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[:] = [] @@ -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[:] = [] @@ -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[:] = [] @@ -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 @@ -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