mitsuhiko / pipsi

pip script installer
Other
2k stars 133 forks source link

get-pipsi custom Python broken #100

Open pikeas opened 7 years ago

pikeas commented 7 years ago

Followup to https://github.com/mitsuhiko/pipsi/issues/88.

$ curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3
...
Installed pipsi binary in /Users/apikeas/.local/bin
pipsi is now installed.
$ pipsi install saws
Running virtualenv with interpreter /Users/apikeas/.local/venvs/pipsi/bin/python3.6
Using base prefix '/usr/local/Cellar/python3/3.6.1/bin/../Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/apikeas/.local/venvs/saws/bin/python3.6
Also creating executable in /Users/apikeas/.local/venvs/saws/bin/python
ERROR: The executable /Users/apikeas/.local/venvs/saws/bin/python3.6 is not functioning
ERROR: It thinks sys.prefix is '/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6' (should be '/Users/apikeas/.local/venvs/saws')
ERROR: virtualenv is not compatible with this system or executable
Failed to create virtualenv.  Aborting.

If I remove pipsi and retry with python instead of python3, everything works. Both Pythons were installed by Homebrew into /usr/local/bin.

pikeas commented 7 years ago

I have a little bit of additional color on this.

There is one happy path:

pip3 install virtualenv
curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3
# Change ~/.local/bin/pipsi shebang line to use .local/venvs/pipsi/bin

If these three conditions are met, in this order, everything seems to work fine. If virtualenv is installed after the fact or the shebang line isn't changed, pipsi and/or the packages installed by it fail in various weird ways.

jedie commented 7 years ago

I also used $ curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3 ... it worked, but pipsi env was made with python2 and not with python3 ;)

I made a simple sh script to install from git: https://gist.github.com/jedie/513d2f8415af0bebba70229d49f601b2

brettcannon commented 7 years ago

I had a problem today where I specified an installed Python 3.6 on macOS with the curl command and the shebang for pipsi wasn't set appropriately. I ended up manually editing the shebang to point to pipsi's own virtualenv python and everything seems to be working fine.

elgertam commented 7 years ago

I had quite a few problems getting Pipsi installed (Python 3.6.2 via Pyenv, macOS High Sierra). I first encountered errors because virtualenv was not installed. I attempted this suggestion (from https://github.com/mitsuhiko/pipsi/issues/89)

curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3 - --src 'git+https://github.com/mitsuhiko/pipsi.git#egg=pipsi'

and was able to install pipsi, but every subsequent package I attempted to install with pipsi (e.g.cookiecutter, pipenv, ansible) displayed the dreaded

Did not find any scripts. Uninstalling.

One solution might be to install virtualenv into my global site-packages. However, as a philosophical matter, I don't want to pollute my Python 3 global packages with virtualenv, since venv has been such a capable replacement. Maybe this is just hairsplitting, but it feels wrong to me, particularly because avoiding global site-packages pollution is a major use case for pipsi.

That led me to attempt a fork of @jedie's install script (https://gist.github.com/elgertam/2d50ea280d2395dd2bbedbb169c59d2e/cbc9f2132a945a2b7d44248f93eb749a6296830d) where I install virtualenv and pipsi into a virtualenv created with venv. Although I am able to install pipsi, I again experience the "Did not find any scripts" error for all packages I attempted to install.

I then revised the install script (https://gist.github.com/elgertam/2d50ea280d2395dd2bbedbb169c59d2e/0bba09f4ced1d702654fe51d5db75133a34749ef). Here I use a bootstrapping approach to first create a "bootstrapping" virtualenv via venv, into which I install virtualenv. Then I use this bootstrapping virtualenv to install pipsi into its own virtualenv using virtualenv. Finally, I clean up the bootstrapping virtualenv by removing it.

I mention this only as a way I was able to solve the problem. I haven't dug deep into the code to figure out why I was getting such bad behavior from pipsi under Python 3, but I have tested my installation pipsi against several packages, and all is working as I expect it to.

wxiv commented 6 years ago

@elgertam I tried using your script and it works with various packages (awscli) but I still get

Did not find any scripts. Uninstalling.

with boto3 and botocore.

elgertam commented 6 years ago

@wxiv I'm seeing the same problem.

I took a look at boto3 (and botocore), and these specify scripts=[] in setup() within setup.py. Here's boto3's:

https://github.com/boto/boto3/blob/1461984ff5cf03a789e7c46c0fac98cb0cc37cc7/setup.py#L35

In this case, pipsi really cannot find any scripts, and so is working as intended. I suppose someone could fork boto3 and specify the proper scripts location. Hope this helps somewhat.

tekumara commented 6 years ago

Unfortunately ran into the following with @elgertam's latest script:

Running virtualenv with interpreter python3
Using base prefix '/usr/local/bin/../Cellar/python/3.6.5/bin/../Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/tekumara/.local/venvs/pipsi/bin/python3
Also creating executable in /Users/tekumara/.local/venvs/pipsi/bin/python
ERROR: The executable /Users/tekumara/.local/venvs/pipsi/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6' (should be '/Users/tekumara/.local/venvs/pipsi')
ERROR: virtualenv is not compatible with this system or executable

@jedie's script installed, and I could install packages, but pipsi list and pipsi uninstall would fail with

FileNotFoundError: [Errno 2] No such file or directory: '/Users/tekumara/.local/venvs/pipsi/package_info.json'
halicki commented 6 years ago

@jedie's script installed, and I could install packages, but pipsi list and pipsi uninstall would fail with

FileNotFoundError: [Errno 2] No such file or directory: '/Users/tekumara/.local/venvs/pipsi/package_info.json'

@tekumara you can follow instructions from this comment. You need to create package_info.json yourself :(

EdJoJob commented 6 years ago

Some of this is going to be down to virtualenv. See pypa/virtualenv#1051.

As far as I can tell you can reproduce this by:

  1. Create a python3 virtualenv using python3 -m venv <path>
  2. Try creating a new virtualenv based off the previous one with virtualenv virtualenv -p <path>/bin/python <new-path>

If both virtualenvs are created with either virtualenv or python -m venv it all works fine.

cs01 commented 6 years ago

Just wanted to mention that I was running into this too so I recently decided to start a project called pipx that combines pipsi's functionality with npx's. It works with Python versions 3.6+. Would love to hear what you think! https://github.com/cs01/pipx