Skip to content

Commit

Permalink
env: only import packaging wherever required
Browse files Browse the repository at this point in the history
PR #395

Co-authored-by: Ravi Teja Gannavarapu <raviteja@clevertap.com>
  • Loading branch information
IamRaviTejaG and IamRaviTejaG committed Oct 23, 2021
1 parent 1f19a5d commit 0fffa12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/build/env.py
Expand Up @@ -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


Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_env.py
Expand Up @@ -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
Expand Down

0 comments on commit 0fffa12

Please sign in to comment.