-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write a temporary setup.cfg to override any system distutils configur…
…ation (#18) * Write a temporary setup.cfg to override any system distutils configuration Previously, shiv could not install packages that did not provide wheels using Homebrew's Pythons, because `--target` is incompatible with Homebrew's `distutils.cfg`. We can work around that by creating a `setup.cfg` in the same directory we run `pip install` containing: ```ini [install] prefix= ``` Fixes #16. * Restore the previous directory after installing * Move temporary setup.cfg to clean_pip_env()
- Loading branch information
1 parent
29fb7c3
commit 33cf133
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
from pathlib import Path | ||
|
||
from shiv.constants import PIP_REQUIRE_VIRTUALENV | ||
from shiv.constants import SETUP_CFG_NO_PREFIX | ||
from shiv.pip import clean_pip_env | ||
|
||
|
||
def test_clean_pip_env(monkeypatch): | ||
before_env_var = 'foo' | ||
monkeypatch.setenv(PIP_REQUIRE_VIRTUALENV, before_env_var) | ||
|
||
before_cwd = Path.cwd() | ||
|
||
with clean_pip_env(): | ||
assert PIP_REQUIRE_VIRTUALENV not in os.environ | ||
|
||
cwd = Path.cwd() | ||
assert cwd != before_cwd | ||
|
||
with cwd.joinpath("setup.cfg").open() as f: | ||
assert f.read() == SETUP_CFG_NO_PREFIX | ||
|
||
assert os.environ.get(PIP_REQUIRE_VIRTUALENV) == before_env_var | ||
assert Path.cwd() == before_cwd |