Skip to content

Commit

Permalink
tox-dev#3165 Disabled cleaning of .sdist-extract folder
Browse files Browse the repository at this point in the history
Disabled cleaning of .sdist-extract folder and added testcase to catch issue caused by feature.
  • Loading branch information
Stefanhg committed Jan 16, 2024
1 parent fa390ce commit 3121627
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/tox/tox_env/python/virtual_env/package/cmd_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ def extract_install_info(self, for_env: EnvConfigSet, path: Path) -> list[Packag
package: Package = WheelPackage(path, deps)
else: # must be source distribution
work_dir = self.env_tmp_dir / "sdist-extract"
if work_dir.exists(): # pragma: no branch
shutil.rmtree(work_dir) # pragma: no cover
work_dir.mkdir()
if not work_dir.exists(): # pragma: no branch
work_dir.mkdir()
with tarfile.open(str(path), "r:gz") as tar:
tar.extractall(path=str(work_dir)) # noqa: S202
# the register run env is guaranteed to be called before this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def test_tox_install_pkg_wheel(tox_project: ToxProjectCreator, pkg_with_extras_p
assert calls == expected


@pytest.fixture(scope="session")
def pkg_with_sdist(
pkg_with_extras_project: Path,
pkg_builder: Callable[[Path, Path, list[str], bool], Path],
) -> Path:
dist = pkg_with_extras_project / "dist"
pkg_builder(dist, pkg_with_extras_project, ["sdist"], False)
return next(dist.iterdir())


@pytest.fixture()
def pkg_with_extras_project_sdist(
pkg_with_extras_project: Path,
Expand Down Expand Up @@ -162,3 +172,19 @@ def test_tox_install_pkg_with_skip_install(
project = tox_project({"tox.ini": ini, "pyproject.toml": (demo_pkg_inline / "pyproject.toml").read_text()})
result = project.run("-e", "py", "--installpkg", str(demo_pkg_inline_wheel))
result.assert_success()


def test_run_installpkg_targz(tox_project: ToxProjectCreator,
pkg_with_sdist: Path,
enable_pip_pypi_access: str | None, # noqa: ARG001
) -> None:
project = tox_project({"tox.ini": """
[tox]
envlist = base, flake8
[testenv]
package = sdist
[testenv:base]
[testenv:flake8]
"""})
outcome = project.run(f"--installpkg={pkg_with_sdist}")
outcome.assert_success()

0 comments on commit 3121627

Please sign in to comment.