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 Oct 29, 2021
1 parent d7720ca commit 6ba8e6d
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 @@ -185,6 +185,16 @@ class _DefaultIsolatedEnv(IsolatedEnv):
An isolated environment class which combines venv and virtualenv with pip.
"""

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

def __init__(self, isolated_env_manager: 'IsolatedEnvManager') -> None:
self._isolated_env_manager = isolated_env_manager
self._log = self._isolated_env_manager.log
Expand Down Expand Up @@ -247,6 +257,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 6ba8e6d

Please sign in to comment.