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

Python prefix is incorrect #70

Open
marcaurele opened this issue Feb 27, 2016 · 6 comments
Open

Python prefix is incorrect #70

marcaurele opened this issue Feb 27, 2016 · 6 comments

Comments

@marcaurele
Copy link

Hi,

When I do a pipsi install, the python prefix in the scripts first line is incorrect and point to the system python. I'm trying to figure why, but I can't find an explanation. Do you have any pointer where I should look? I'm using ZSH on OSX if that matters somehow.

This is the output with virtualenv -v and pip -v -v -v https://gist.github.com/marcaurele/ef8dd46b802bd0cde77a

If I do it manually, of course it works (virtualenv & pip), but that's not the point.

@RonnyPfannschmidt
Copy link
Contributor

at first glance this looks like a issue on osx, i cant verify it since i don't have fit hardware

@marcaurele
Copy link
Author

I'm eager to find the solution, let me know what i should try out.

@RonnyPfannschmidt
Copy link
Contributor

right now i have no idea myself, it seels to be related to virtualenv, but im just vaugely guessing

marcaurele added a commit to marcaurele/pipsi that referenced this issue Mar 4, 2016
If the venv module is found, use it to create the virtual env, otherwise
fallback to use virtualenv. An new paramater --virtualenv is available
to force the use of virtualenv.

It fixes the problem on OSX mitsuhiko#70
@cjrh
Copy link

cjrh commented Jan 21, 2017

The reasons behind this problem are quite obscure, as you'll see from the fix. The necessary ingredients are Python 3, virtualenv (not venv), OS X and Homebrew. To fix the problem, you have to pop an environment variable called PYVENV_LAUNCHER before launching the subprocess. I made the following changes in pipsi.py, around line 230:

        # Install virtualenv, use the pipsi used python version by default
        args = ['virtualenv', '-p', python or sys.executable, venv_path]

        try:
            env = dict(os.environ)                                 # <<== NEW
            env.pop('__PYVENV_LAUNCHER__', None)                   # <<== NEW
            if Popen(args, env=env).wait() != 0:                   # <<== env kwarg
                click.echo('Failed to create virtualenv.  Aborting.')
                return _cleanup()

            args = [os.path.join(venv_path, BIN_DIR, 'pip'), 'install']
            if editable:
                args.append('--editable')

            if Popen(args + install_args, env=env).wait() != 0:    # <<== env kwarg
                click.echo('Failed to pip install.  Aborting.')
                return _cleanup()
        except Exception:
            _cleanup()
            raise

The following links provide more background:

pypa/virtualenv#532
pypa/virtualenv#541
pypa/virtualenv#845

Finally, I found the initial problem with (OSX+Homebrew) Python 3.6 (most of the other links refer to 3.3 -> 3.5), and the resolution above also resolves the problem on 3.6.

EDIT: finally found a more complete description of the root cause: https://bugs.python.org/issue22490#msg227579

@RonnyPfannschmidt
Copy link
Contributor

@cjrh can you submit a pr? personally i am handing pipsi in a minimal workload on me mode, and a pr is far simpler to manage than needing to recreate a patch based on instructions (even if in this case it does look reasonably trivial

i also do wonder if there is any way to create a automated test for that case

@cjrh
Copy link

cjrh commented Jan 22, 2017

@RonnyPfannschmidt The problem goes away if #71 is merged, and I think that's the better solution than the hacky env var change above.

marcaurele added a commit to marcaurele/pipsi that referenced this issue Jan 23, 2017
If the venv module is found, use it to create the virtual env, otherwise
fallback to use virtualenv. An new paramater --virtualenv is available
to force the use of virtualenv.

Fixes mitsuhiko#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants