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 18bb9a9 commit 63d21d4
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 @@ -170,6 +170,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 @@ -243,6 +253,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 63d21d4

Please sign in to comment.