Skip to content

Commit

Permalink
env: remove leaky vars from pep517 environ
Browse files Browse the repository at this point in the history
Closes pypa#377.
  • Loading branch information
layday committed Nov 6, 2021
1 parent 3aef796 commit 2e196b5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/build/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ def _get_min_pip_version() -> str:
class _DefaultIsolatedEnv(IsolatedEnv):
"""An isolated environment which combines venv or virtualenv with pip."""

_LEAKY_ENV_VARS = frozenset(
{
'PYTHONHOME',
'PYTHONPATH',
'PYTHONPLATLIBDIR',
'PYTHONSTARTUP',
'PYTHONNOUSERSITE',
}
)

def __init__(self, isolated_env_manager: 'IsolatedEnvManager') -> None:
self._log = isolated_env_manager.log
self._env_created = False
Expand Down Expand Up @@ -239,6 +249,8 @@ def install_packages(self, requirements: Iterable[str]) -> None:

def prepare_environ(self) -> Dict[str, str]:
environ = os.environ.copy()
for name in self._LEAKY_ENV_VARS:
environ.pop(name, None)

# Make the virtual environment's scripts available to the project's build dependecies.
path = environ.get('PATH')
Expand Down

0 comments on commit 2e196b5

Please sign in to comment.