Skip to content

Commit

Permalink
Pass --isolated to 'pip install'
Browse files Browse the repository at this point in the history
Fixes pypa#90.

[The `--isolated` option](https://github.com/pypa/pip/blob/89a51a6fefec826256fb334ea6244dfb0b3455a0/src/pip/_internal/cli/cmdoptions.py#L153) ignores environment variables and user configuration, so only the passed command will be run. This fixes `python -m build` for users with `PIP_REQUIRE_VIRTUALENV`, and maybe some other cases.

I'm not sure if it will break other flows though, such as if a proxy is configured.
  • Loading branch information
adamchainz committed Sep 9, 2020
1 parent 10bf02e commit dd19792
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/build/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def install(self, requirements): # type: (Iterable[str]) -> None
req_file.write(os.linesep.join(requirements))
req_file.close()
cmd = [
sys.executable, '-m', 'pip', 'install', '--prefix',
self.path, '-r', os.path.abspath(req_file.name)
sys.executable, '-m', 'pip', 'install', '--isolated',
'--prefix', self.path, '-r', os.path.abspath(req_file.name)
]
subprocess.check_call(cmd)
os.unlink(req_file.name)
5 changes: 3 additions & 2 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def test_isolated_environment_install(mocker):
if sys.version_info[:2] != (3, 5):
subprocess.check_call.assert_called()
args = subprocess.check_call.call_args[0][0]
assert args[:7] == [
sys.executable, '-m', 'pip', 'install', '--prefix', env.path, '-r'
assert args[:8] == [
sys.executable, '-m', 'pip', 'install', '--isolated',
'--prefix', env.path, '-r'
]


Expand Down

0 comments on commit dd19792

Please sign in to comment.