1

If I create a virtualenv on Ubuntu 16.04 (Python2), then a directory local gets created which contains symlinks:

===> virtualenv symlinktest
New python executable in /home/tguettler/tmp/symlinktest/bin/python
Please make sure you remove any previous custom paths from your /home/tguettler/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.



===> ls -l symlinktest/local/



===> ls -l symlinktest/local/*
lrwxrwxrwx 1 tguettler tguettler 35 Mär  7 14:21 symlinktest/local/bin -> /home/tguettler/tmp/symlinktest/bin
lrwxrwxrwx 1 tguettler tguettler 39 Mär  7 14:21 symlinktest/local/include -> /home/tguettler/tmp/symlinktest/include
lrwxrwxrwx 1 tguettler tguettler 35 Mär  7 14:21 symlinktest/local/lib -> /home/tguettler/tmp/symlinktest/lib


===> virtualenv --version
15.0.3

This does not happen on other linux distributions.

Why and where does this symlink get created?

Update

On this plattform openSUSE 42.1 (x86_64) a symlink from lib64 to lib gets created ...

I don't understand the need for this symlink.

2
  • Wondering if we can somehow deduce that from stackoverflow.com/questions/8227120/…
    – nir0s
    Mar 8, 2017 at 19:31
  • @nir0s I don't run a five year old virtualenv :-) I use version 15.0.3. I use the same virtualenv version on SuSE linux and there the symlink does not get created. Nevertheless thank you for looking at my issue.
    – guettli
    Mar 9, 2017 at 8:45

1 Answer 1

1

So, after prying into the virtualenv code just a tad, it seems that the following happens:

create_environment calls install_python which calls fix_local_scheme (https://github.com/pypa/virtualenv/blob/master/virtualenv.py#L1492). Note how in the docstring they state that this is needed for posix systems like Ubuntu with Python 2.7 (which you're running)

>>> import platform
>>> platform.linux_distribution()
('Ubuntu', '16.04', 'xenial')

$ python2.7
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig._get_default_scheme()
'posix_local'


$ cat /usr/lib/python2.7/sysconfig.py
def _get_default_scheme():
    if os.name == 'posix':
        # the default scheme for posix on Debian/Ubuntu is posix_local
        # FIXME: return dist-packages/posix_prefix only for
        #   is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__
        # is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local')
        return 'posix_local'
    return os.name

You can also read the explanation on the different prefixes: https://pymotw.com/2/sysconfig/#installation-paths, for more information.

1
  • Thank you for this information. Now I see where the symlink gets created.... Leaving only one question left: Why is this needed?
    – guettli
    Mar 9, 2017 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.