Skip to content

mach_bootstrap.py may find system pip before virtualenv copy #8968

Closed

Description

@jbeich

Likely happens since 1a9263c. Also reported by @Yoric for OS X (MacPorts). To work around one may need to alter search order in PIP_NAMES e.g., prefer pip2.7 before pip-2.7.

Here's how the error looks on FreeBSD:

$ rm -rf ~/.cache/pip
$ ./mach build
Command "/usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-NlxkKB/blessings/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-iSyuXi-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-NlxkKB/blessings
Pip failed to execute properly.

Adding a print() before and dropping -q reveals more details:

/usr/local/bin/pip-2.7 install -r /path/to/servo/python/requirements.txt
...
    running install_lib
    error: could not create '/usr/local/lib/python2.7/site-packages/blessings': Perm
ission denied

because virtualenv naming is different from downstream

$ ls -1 /usr/local/bin/pip*
/usr/local/bin/pip
/usr/local/bin/pip-2.7

$ ls -1 python/_virtualenv/bin/pip*
python/_virtualenv/bin/pip
python/_virtualenv/bin/pip2
python/_virtualenv/bin/pip2.7

Activity

  1. changed the title [-]mach may find system pip before virtualenv copy[/-] [+]mach_bootstrap.py may find system pip before virtualenv copy[/+] on Dec 14, 2015
  2. jbeich commented on Dec 14, 2015

    @jbeich
    ContributorAuthor

    Also tracking downstream for FreeBSD.

  3. added
    A-build
    on Dec 14, 2015
  4. frewsxcv commented on Dec 14, 2015

    @frewsxcv
    Contributor

    Relevant issue that prompted that commit: #7784

  5. added
    L-python
    on Dec 14, 2015
  6. zbynekwinkler commented on Apr 14, 2016

    @zbynekwinkler
    Contributor

    I believe this issue might be related to #10595. If the 'quote' kicks in for any reason (it is no-op most of the time), the virtualenv fails to activate - meaning the search path for executing binaries is not updated correctly.

  7. campaul commented on May 11, 2016

    @campaul
    Contributor

    Since the virtualenv is already active at this point (assuming another bug hasn't prevented activation), I think it should be safe to replace pip = _get_exec(*PIP_NAMES) with just pip = find_executable("pip"). This solved the issue on my machine, but there may be edge cases I'm not considering.

  8. jhermann commented on Jul 1, 2016

    @jhermann

    For a more robust way and skipping the in-script virtualenv activation (which is tricky at best), you could also do this:

    pip_path = os.path.join(virtualenv_path, script_dir, "pip")
    

    (which I think will also work in Windows, but might need checks for .bat/.cmd extensions).

    This can then be used for an installation test combined with upgrading, like this:

    {pip_path} install -U "pip>8" setuptools wheel # pinning all versions CAN be a good idea, if they're maintained
    

    Please also note that sometimes an old distribute an cause trouble, and maybe should be uninstalled after the upgrade. Adding --log is also a good idea to ease diagnostics of any problems.

  9. piaoger commented on Aug 30, 2016

    @piaoger

    thanks @campaul , I can build servo on my mac successfully by using your solution.

  10. genodeftest commented on Nov 4, 2016

    @genodeftest
    Contributor

    I ran into this issue before but I think I don't any more. Is there a simple way to test other than running the steps above (which worked fine for me)?

  11. genodeftest commented on Nov 4, 2016

    @genodeftest
    Contributor

    Try removing python/_virtualenv and run ./mach build -d?

    Works fine for me.

  12. ghost closed this as completedon Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-buildL-python

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions