Skip to content
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

cannot do --user install on homebrew #2683

Closed
glyph opened this issue Apr 14, 2015 · 10 comments
Closed

cannot do --user install on homebrew #2683

glyph opened this issue Apr 14, 2015 · 10 comments
Labels
auto-locked Outdated issues that have been locked by automation
Milestone

Comments

@glyph
Copy link

glyph commented Apr 14, 2015

With today's get-pip.py (and with every other version of pip I tried):

$ /usr/local/bin/python get-pip.py --user 
Collecting pip
Installing collected packages: pip
  Exception:
  Traceback (most recent call last):
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/basecommand.py", line 246, in main
      status = self.run(options, args)
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/commands/install.py", line 352, in run
      root=options.root_path,
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/req/req_set.py", line 693, in install
      **kwargs
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/req/req_install.py", line 817, in install
      self.move_wheel_files(self.source_dir, root=root)
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/req/req_install.py", line 1018, in move_wheel_files
      isolated=self.isolated,
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/wheel.py", line 138, in move_wheel_files
      name, user=user, home=home, root=root, isolated=isolated
    File "/var/folders/wd/y0p85qd48xx992w8rkclf7mc8xdc8d/T/tmpE5mm75/pip.zip/pip/locations.py", line 236, in distutils_scheme
      i.finalize_options()
    File "/usr/local/lib/python2.7/site-packages/setuptools-12.0.5-py2.7.egg/setuptools/command/install.py", line 38, in finalize_options
      orig.install.finalize_options(self)
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 268, in finalize_options
      raise DistutilsOptionError("can't combine user with prefix, "
  DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

For some reason, Pip thinks that every install into homebrew python (perhaps any python with a non-standard prefix?) is a --prefix install, and refuses to let me install anything as --user.

@rbtcollins
Copy link

FWIW I ran into a similar thing in a different context - with my cpython trunk build. There's some limitations in sysconfig that drive it, from memory.

@dstufft
Copy link
Member

dstufft commented Apr 17, 2015

Homebrew sets a Python specific distutils.cfg that sets the --prefix option which distutils doesn't allow you to set at the same time as --user. I think that @tdsmith probably knows more about the specifics of why Homebrew does this and if there's anything pip can do to help.

@tdsmith
Copy link
Contributor

tdsmith commented Apr 17, 2015

Homebrew changes the default install prefix so that packages are installed to the HOMEBREW_PREFIX (i.e. /usr/local) prefix and not to python's private, version-specific prefix (i.e. /usr/local/Cellar/python/2.7.8_2).

There's a good argument that Homebrew's solution is morally incorrect but we try hard to avoid carrying patches that will never be merged upstream.

There's an annoying but documented workaround involving passing prefix= at install time, like this:

pip install --user --install-option="--prefix=" spam

Proposals so far for resolving this are https://bugs.python.org/issue22269 (allowing --user to trump --prefix in distutils option parsing instead of complaining about a conflict) and Homebrew/legacy-homebrew#31811 (patching dist.py). (These are actually the same solution; Homebrew is happy to carry a patch as soon as it's accepted upstream, without waiting for it to actually appear in a release.)

A possible workaround is for pip to always pass a null prefix to setup.py when --user is selected, as in our workaround.

@glyph
Copy link
Author

glyph commented Apr 17, 2015

@tdsmith - The --install-option workaround doesn't work with wheels. Since I love wheels and I obsessively build them for everything nowadays (allowing me, among other things, to actually get work done on airplanes, which I will be on 4 more of in the coming month), that means I can't use homebrew without virtualenv, and homebrew's virtualenv is out of date :).

Back to easy_install I guess? ;-)

@dstufft
Copy link
Member

dstufft commented Apr 17, 2015

The --install-option work around would work if pip did it though.

@tdsmith
Copy link
Contributor

tdsmith commented Apr 17, 2015

Aside: I don't believe Homebrew packages virtualenv; I've rejected PRs for it before.

@tdsmith
Copy link
Contributor

tdsmith commented Apr 17, 2015

Thanks for flagging that our workaround doesn't work with wheels as is; I hadn't realized but I guess I should have.

@glyph
Copy link
Author

glyph commented Apr 17, 2015

@dstufft - are you suggesting that pip could always do --install-option=--prefix= when --user is specified? It seems like that might be the Right Thing to do.

@dstufft
Copy link
Member

dstufft commented Apr 17, 2015

Yes.

@dstufft dstufft added this to the 7.0 milestone May 9, 2015
@dstufft dstufft modified the milestones: 7.1, 7.0 May 21, 2015
jamezpolley added a commit to jamezpolley/pip that referenced this issue Jun 26, 2015
Fixes bug pypa#2683

There are two changes here; one to fix the using-wheels codepath and one
to fix the no-wheels codepath. Two tests are introduced, one to test
each codepath.
@dstufft
Copy link
Member

dstufft commented Jun 29, 2015

Closed by #2934

@dstufft dstufft closed this as completed Jun 29, 2015
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

4 participants