Skip to content

Commit

Permalink
Move NoOpBuildEnvironment to its own file
Browse files Browse the repository at this point in the history
This makes it easier to notice that there's three implementations of
build environment management.
  • Loading branch information
pradyunsg committed Dec 11, 2022
1 parent 1ade932 commit 93d3308
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
7 changes: 2 additions & 5 deletions src/pip/_internal/build_env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

from typing import Literal

from pip._internal.build_env._base import (
BuildEnvironment,
NoOpBuildEnvironment,
get_runnable_pip,
)
from pip._internal.build_env._base import BuildEnvironment, get_runnable_pip
from pip._internal.build_env._custom import CustomBuildEnvironment
from pip._internal.build_env.noop import NoOpBuildEnvironment

BuildIsolationMode = Literal["noop", "custom", "venv"]
28 changes: 0 additions & 28 deletions src/pip/_internal/build_env/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,3 @@ def install_requirements(
kind: str,
) -> None:
raise NotImplementedError()


# This class is needed since you can't initialise a base class.
class NoOpBuildEnvironment(BuildEnvironment):
"""A build environment that does nothing."""

lib_dirs: List[str] = []

def __enter__(self) -> None:
return

def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> None:
return

def install_requirements(
self,
finder: "PackageFinder",
requirements: Iterable[str],
prefix_as_string: str,
*,
kind: str,
) -> None:
raise NotImplementedError("This should never get called.")
32 changes: 32 additions & 0 deletions src/pip/_internal/build_env/noop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from types import TracebackType
from typing import List, Optional, Type, Iterable

from pip._internal.build_env import BuildEnvironment
from pip._internal.index.package_finder import PackageFinder


class NoOpBuildEnvironment(BuildEnvironment):
"""A build environment that does nothing."""

lib_dirs: List[str] = []

def __enter__(self) -> None:
return

def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> None:
return

def install_requirements(
self,
finder: "PackageFinder",
requirements: Iterable[str],
prefix_as_string: str,
*,
kind: str,
) -> None:
raise NotImplementedError("This should never get called.")

0 comments on commit 93d3308

Please sign in to comment.