<div dir="ltr">Hi all,<div><br></div><div>I'm trying to answer the question: "On a modern GNU/Linux, if you have no 'pip' command, and you want to live in the modern Python Packaging world, how do you start?"</div>
<div><br></div><div>Hypothetically, let's say you're on the latest Python 2.7.</div><div><br></div><div>Also, I am presuming that you either don't have root on the system, or you don't want to run things with sudo.</div>
<div><br></div><div><br></div><div>One answer I've seen (and given...) is to download virtualenv.py by itself, and hope that it can create a virtualenv in e.g. ~/venv/base, and then always activate it.</div><div><br></div>
<div>You can see that advice given here:  <a href="http://dubroy.com/blog/so-you-want-to-install-a-python-package/#the-better-way">http://dubroy.com/blog/so-you-want-to-install-a-python-package/#the-better-way</a> </div><div>
<br></div><div>This advice is not contradicted here <<a href="http://www.virtualenv.org/en/latest/virtualenv.html#installation">http://www.virtualenv.org/en/latest/virtualenv.html#installation</a>> although it seems like the advice basically is, "Make sure you have pip already, but if you don't, then we have no particular advice for you."</div>
<div><br></div><div><br></div><div>One alternative is to bootstrap via "get-pip.py", which happens (as far as I can tell) to operate properly as a ~/bin/pip. Then you can "pip install --user", and more.</div>
<div><br></div><div>However, get-pip.py <<a href="http://pip.readthedocs.org/en/latest/installing.html">http://pip.readthedocs.org/en/latest/installing.html</a>> seems to, if you run it with no arguments, want to write to /usr/bin/pip.<br>
<br>What I'm hoping exists is a variant of get-pip.py that I can suggest people put in ~/bin/pip (and tell them to fix their path to include $HOME/bin ), and then they can pip install --user to their heart's content. You could imagine this being called "heres-pip.py", rather than "get-pip.py", as in my imagination, running "heres-pip.py" would not be supposed to have side-effects like installing things unless you ask it to. You would just drop it into place.</div>
<div><br></div><div><br></div><div>Shell transcripts follow, to help you see what I'm seeing, in case I'm perhaps doing something wrong:</div><div><br></div><div><div>➜  /tmp  python get-pip.py</div><div>Downloading/unpacking pip from <a href="https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.4-py2.py3-none-any.whl#md5=f20bc8f31e322375ce06b26d73ce7b4f">https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.4-py2.py3-none-any.whl#md5=f20bc8f31e322375ce06b26d73ce7b4f</a></div>
<div>  Downloading pip-1.5.4-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded</div><div>Installing collected packages: pip</div><div>  Found existing installation: pip 1.4.1</div><div>    Uninstalling pip:</div><div>Cleaning up...</div>
<div>Exception:</div><div>Traceback (most recent call last):</div><div>  File "/tmp/tmpL4ws00/pip.zip/pip/basecommand.py", line 122, in main</div><div>    status = self.run(options, args)</div><div>  File "/tmp/tmpL4ws00/pip.zip/pip/commands/install.py", line 279, in run</div>
<div>    requirement_set.install(install_options, global_options, root=options.root_path)</div><div>  File "/tmp/tmpL4ws00/pip.zip/pip/req.py", line 1376, in install</div><div>    requirement.uninstall(auto_confirm=True)</div>
<div>  File "/tmp/tmpL4ws00/pip.zip/pip/req.py", line 594, in uninstall</div><div>    paths_to_remove.remove(auto_confirm)</div><div>  File "/tmp/tmpL4ws00/pip.zip/pip/req.py", line 1781, in remove</div>
<div>    renames(path, new_path)</div><div>  File "/tmp/tmpL4ws00/pip.zip/pip/util.py", line 295, in renames</div><div>    shutil.move(old, new)</div><div>  File "/usr/lib/python2.7/shutil.py", line 303, in move</div>
<div>    os.unlink(src)</div><div>OSError: [Errno 13] Permission denied: '/usr/bin/pip'</div></div><div><br></div><div><div>➜  /tmp  python get-pip.py --user --upgrade mwparser</div><div>Requirement already up-to-date: pip in /home/paulproteus/.local/lib/python2.7/site-packages</div>
<div>Downloading/unpacking mwparser</div><div>  Downloading mwparser-0.1.tar.gz</div><div>  Running setup.py (path:/tmp/pip_build_paulproteus/mwparser/setup.py) egg_info for package mwparser</div><div>    </div><div>Installing collected packages: mwparser</div>
<div>  Running setup.py install for mwparser</div><div>    /home/paulproteus/.local/lib/python2.7/site-packages/mwparser.py:13: SyntaxWarning: assertion is always true, perhaps remove parentheses?</div><div>      assert('<' not in tag and '>' not in tag, "sample tag is 'ol'")</div>
<div>    /home/paulproteus/.local/lib/python2.7/site-packages/mwparser.py:14: SyntaxWarning: assertion is always true, perhaps remove parentheses?</div><div>      assert(len(start_marker) == 1, "This code assumes start_marker's length is 1")</div>
<div>    </div><div>Successfully installed mwparser</div><div>Cleaning up...</div></div><div><br></div><div><br></div><div><br></div><div>So it seems that you can (ab?)use get-pip.py as a personal ~/bin/pip. You just have to know not to type "install". I'm guessing that "get-pip.py" is a "pip" binary with "install pip" pre-pended to sys.argv, so by passing more things, I happen to be able to cause it to do what I want. Either way, I'd like to know more about what is sensible to recommend as a bootstrapping process.</div>
<div><br></div><div>I presume that Mac OS users will have a similar issue as random GNU/Linux users who lack pip.</div><div><br></div><div>I will say, if get-pip.py wanted to do "pip install --user" rather than "pip install", then I'd be happy recommending it as-is.</div>
<div><br></div><div>(Other ideas welcome. I'm also semi-sure this is some kind of FAQ, but I don't see it in my reading of the distutils-sig list, so I thought I'd still ask it.)</div><div><br></div><div>Cheers,</div>
<div><br></div><div>Asheesh.</div><div><br></div><div>P.S. I am *so* tempted to add a no-op distribution called "install" to PyPI so that "pip install install" would look like it works.</div></div>