From 5ad844a89d573a38cf698393c8969d275be39672 Mon Sep 17 00:00:00 2001 From: Ravi Teja Gannavarapu Date: Sat, 23 Oct 2021 19:02:51 +0530 Subject: [PATCH 1/2] Import packaging wherever required --- src/build/env.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/build/env.py b/src/build/env.py index 4b0725ad..e6d22b5d 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -15,9 +15,6 @@ from types import TracebackType from typing import Callable, Iterable, List, Optional, Tuple, Type -import packaging.requirements -import packaging.version - import build @@ -62,6 +59,8 @@ def install(self, requirements: Iterable[str]) -> None: @functools.lru_cache(maxsize=None) def _should_use_virtualenv() -> bool: + import packaging.requirements + # virtualenv might be incompatible if it was installed separately # from build. This verifies that virtualenv and all of its # dependencies are installed as specified by build. @@ -254,6 +253,8 @@ def _create_isolated_env_venv(path: str) -> Tuple[str, str]: """ import venv + import packaging.version + venv.EnvBuilder(with_pip=True, symlinks=_fs_supports_symlink()).create(path) executable, script_dir, purelib = _find_executable_and_scripts(path) From b74a985e06675ba8f79fad98cc5c95689a56e9c9 Mon Sep 17 00:00:00 2001 From: Ravi Teja Gannavarapu Date: Sat, 23 Oct 2021 19:20:57 +0530 Subject: [PATCH 2/2] Fix failing test - test_isolated_env_log --- tests/test_env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_env.py b/tests/test_env.py index 7aeda328..9b5506fa 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -112,7 +112,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit): ('INFO', 'Installing packages in isolated environment... (something)'), ] if sys.version_info >= (3, 8): # stacklevel - assert [(record.lineno) for record in caplog.records] == [105, 103, 194] + assert [(record.lineno) for record in caplog.records] == [105, 102, 193] @pytest.mark.isolated