-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
distutils.errors.DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both #16
Comments
Hi @rouge8, Looks to be an known issue with Homebrew'd python: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md#note-on-pip-install---user Note that You can see that plain old
I tried one of the workarounds I found while googling around and it seemed to fix the problem:
However, you might still run into issues because that package (
|
Ha, I meant to do awscli, but ran into that issue with a few packages. I'm guessing anything where a wheel is unavailable is affected. I wonder if there's a workaround that can go into shiv because this is probably pretty common... I'll see if I can make anything work without needing a |
At first I tried using I'm definitely open to an elegant solution to this, but from perusing how this file is handled by distutils and how it's included (by homebrew folks) I'm not hopeful. I'll keep poking at it. |
I think the fix is actually pretty easy -- distutils will also read from a This is a minimal diff that seems to work: diff --git a/src/shiv/cli.py b/src/shiv/cli.py
index d95075d..dbae8e1 100644
--- a/src/shiv/cli.py
+++ b/src/shiv/cli.py
@@ -1,4 +1,5 @@
import importlib_resources # type: ignore
+import os
import shutil
import sys
import uuid
@@ -125,10 +126,13 @@ def main(
interpreter = validate_interpreter(python)
with TemporaryDirectory() as working_path:
+ with Path(working_path, "setup.cfg").open('w') as f:
+ f.write('[install]\nprefix=')
site_packages = Path(working_path, "site-packages")
site_packages.mkdir(parents=True, exist_ok=True)
# install deps into staged site-packages
+ os.chdir(working_path)
pip.install(
python or sys.executable,
["--target", site_packages.as_posix()] + list(pip_args), |
Turned that into a PR: #18 |
…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()
I think the reason #18 didn't actually work is pip changes to the directory of the package its installing when it's building from source. For whoever tries this next: make sure to set |
It sounds like what we want is for pypa/pip#4557 to be merged, but in the meantime could probably follow the same approach as Azure/azure-cli#4466 |
… configuration (#27) Write a temporary ~/.pydistutils.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 temporary `~/.pydistutils.cfg` containing: ```ini [install] prefix= ``` Inspired by Azure/azure-cli#4466. Fixes #16.
With shiv 0.0.14 from PyPI:
Here's the packages installed systemwide alongside shiv:
OS X, Python 3.6.5 from Homebrew.
The text was updated successfully, but these errors were encountered: