Skip to content

Commit

Permalink
Fix isolated environment call
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat authored and FFY00 committed Oct 13, 2020
1 parent f4af1a4 commit 80bbf2e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/build/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import sysconfig
import tempfile
import types

from typing import Dict, Iterable, List, Optional, Sequence, Type


if sys.version_info[0] == 2: # pragma: no cover
FileExistsError = OSError

Expand Down Expand Up @@ -58,6 +56,7 @@ def __init__(self, remove_paths, _executable=sys.executable): # type: (Sequence
self._path = None # type: Optional[str]
self._remove_paths = [] # type: List[str]
self._executable = _executable
self._old_executable = None # type: Optional[str]

# normalize paths so that we can compare them -- required on case insensitive systems
for path in remove_paths:
Expand Down Expand Up @@ -227,6 +226,8 @@ def __enter__(self): # type: () -> IsolatedEnvironment
self._create_env_venv()

self._pop_env('PIP_REQUIRE_VIRTUALENV')
# address https://github.com/pypa/pep517/pull/93
self._old_executable, sys.executable = sys.executable, self._executable

return self

Expand All @@ -235,6 +236,8 @@ def __exit__(self, typ, value, traceback):
"""
Restores the everything to the original state
"""
if self._old_executable is not None:
sys.executable = self._old_executable
if self.path and os.path.isdir(self.path):
shutil.rmtree(self.path)

Expand Down

0 comments on commit 80bbf2e

Please sign in to comment.