Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env: only import packaging wherever required #395

Merged
merged 2 commits into from Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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