Issue #112 resolved

lssitepackages and pypy

created an issue

Hi, just noticed that {{{lssitepackages}}} fails on a {{{pypy}}} environment, e.g.

{{{ $ mkvirtualenv -p pypy --no-site-packages pypyenv Running virtualenv with interpreter /usr/local/bin/pypy New pypy executable in pypyenv/bin/pypy Installing setuptools............................done. Installing pip...............done. virtualenvwrapper.user_scripts creating /home/hector/.virtualenvs/pypyenv/bin/predeactivate virtualenvwrapper.user_scripts creating /home/hector/.virtualenvs/pypyenv/bin/postdeactivate virtualenvwrapper.user_scripts creating /home/hector/.virtualenvs/pypyenv/bin/preactivate virtualenvwrapper.user_scripts creating /home/hector/.virtualenvs/pypyenv/bin/postactivate virtualenvwrapper.user_scripts creating /home/hector/.virtualenvs/pypyenv/bin/get_env_details

(pypyenv)$ lssitepackages ls: cannot access /home/hector/.virtualenvs/pypyenv/lib/python2.7: No such file or directory ls: cannot access 1.6/site-packages: No such file or directory

(pypyenv)$ ls -hl .virtualenvs/pypyenv/ total 16K drwxr-xr-x 2 hector hector 4.0K 2011-09-21 15:37 bin lrwxrwxrwx 1 hector hector 21 2011-09-21 15:37 include -> /opt/pypy-1.6/include drwxr-xr-x 2 hector hector 4.0K 2011-09-21 15:37 lib_pypy drwxr-xr-x 4 hector hector 4.0K 2011-09-21 15:37 lib-python drwxr-xr-x 3 hector hector 4.0K 2011-09-21 15:37 site-packages


Comments (10)

  1. Doug Hellmann repo owner

    Thanks for the bug report. I haven't done anything to make the wrappers work with pypy, but I would definitely like to support it. It looks like pypy uses a different structure for a virtualenv, so the location of site-packages is different. If you have time to work on a patch, that would be great. Otherwise I will keep this on the list of things to work on for a future release.

  2. Anonymous

    I believe that this is just a patch on the virtualenvwrapper_get_python_version assuming that one can identify that pypy is in use.

  3. Gabi Davar

    This also affects msys - add2virtualenv, cdsitepackages, lssitepackages, toggleglobalsitepackages

    # Prints the path to the site-packages directory for the current environment.
    function virtualenvwrapper_get_site_packages_dir {
        echo "$VIRTUAL_ENV/lib/site-packages" # GabiD - this works on msys
        #echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages"    
  4. Doug Hellmann repo owner

    That looks like a good spot to be testing whether or not VIRTUALENVWRAPPER_PYTHON is pypy or some other variant that doesn't use the version-specific path for site-packages. Do you know how to detect that, though?

  5. Gabi Davar

    This is what virtualenv does ... Can't get any hard coded than that. This looks like a virtualenv issue - it seems reasonable to have it set an environment variable pointing to the site packages directory(s?).

    base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    if sys.platform == 'win32':
        site_packages = os.path.join(base, 'Lib', 'site-packages')
        site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
    prev_sys_path = list(sys.path) 
  6. Carl Meyer

    Just use "distutils.sysconfig.get_python_lib()".

    It's hardcoded in virtualenv only because during the process of creating a virtualenv that function will return the system site-packages; it's a bootstrapping issue. But once you've got code running in a virtualenv that function will return the correct path.

  7. Dario Bertini

    uhm, I wrote this, I tried it on my environments, and it seems to work fine

    but when running tox, it fails several tests like the check for no-global-site-packages.txt after copying an environment (again: I tried manually a "mkvirtualenv --no-site-packages test && cpvirtualenv test test2" and I can't reproduce the error found by tox)

    it also complained about shwordsplit not being active in zsh, even tough the test code explicitly activates that option

    I removed virtualenvwrapper_get_site_packages_dir and added the call to distutils.sysconfig.get_python_lib inside activate to avoid slowing everything down when using an interpreter with a slow startup (like jython), but then I realized that virtualenv doesn't add a python symlink for jython, and thus this doesn't really help jython at all

  8. Doug Hellmann repo owner

    The error in is caused because that test script is using virtualenvwrapper_get_site_packages_dir, which was removed when you added the global variable. I tried changing the test to use the variable, but it didn't work that way. I think there's a sequencing issue with the export/unset calls or something. Redefining the function to use call distutils each time seems to be working, so I am planning to go ahead with that.

  9. Log in to comment