You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be an issue with the way virtualenv locates the users site dir. While I have also seen the same issue on Linux (openSuse 11.4), I have only been able to test thoroughly on Mac OS X Lion.
uname output
Darwin asad-macbook 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
In the lib/site.py for both the Apples version of Python (at /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7) and the MacPorts version (at /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7) use the following function to find the user dir:
def addusersitepackages(known_paths):
"""Add a per user site-package to sys.path
Each user has its own python directory with site-packages in the
home directory.
"""
# get the per user site-package path
# this call will also make sure USER_BASE and USER_SITE are set
user_site = getusersitepackages()
if ENABLE_USER_SITE and os.path.isdir(user_site):
addsitedir(user_site, known_paths)
return known_paths
But inside the virtualenv, the lib/site.py uses:
def addusersitepackages(known_paths):
"""Add a per user site-package to sys.path
Each user has its own python directory with site-packages in the
home directory.
USER_BASE is the root directory for all Python versions
USER_SITE is the user specific site-packages directory
USER_SITE/.. can be used for data.
"""
global USER_BASE, USER_SITE, ENABLE_USER_SITE
env_base = os.environ.get("PYTHONUSERBASE", None)
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))
#if sys.platform in ('os2emx', 'riscos'):
# # Don't know what to put here
# USER_BASE = ''
# USER_SITE = ''
if os.name == "nt":
base = os.environ.get("APPDATA") or "~"
if env_base:
USER_BASE = env_base
else:
USER_BASE = joinuser(base, "Python")
USER_SITE = os.path.join(USER_BASE,
"Python" + sys.version[0] + sys.version[2],
"site-packages")
else:
if env_base:
USER_BASE = env_base
else:
USER_BASE = joinuser("~", ".local")
USER_SITE = os.path.join(USER_BASE, "lib",
"python" + sys.version[:3],
"site-packages")
if ENABLE_USER_SITE and os.path.isdir(USER_SITE):
addsitedir(USER_SITE, known_paths)
if ENABLE_USER_SITE:
for dist_libdir in ("lib", "local/lib"):
user_site = os.path.join(USER_BASE, dist_libdir,
"python" + sys.version[:3],
"dist-packages")
if os.path.isdir(user_site):
addsitedir(user_site, known_paths)
return known_paths
Which uses ~/,local as the USER_BASE, whereas on my system, the USER_BASE should be ~/Library/... I have also seen the same problem on my Linux (openSuse) machine.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.
There seems to be an issue with the way virtualenv locates the users site dir. While I have also seen the same issue on Linux (openSuse 11.4), I have only been able to test thoroughly on Mac OS X Lion.
uname output
In the lib/site.py for both the Apples version of Python (at
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
) and the MacPorts version (at/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
) use the following function to find the user dir:But inside the virtualenv, the lib/site.py uses:
Which uses ~/,local as the USER_BASE, whereas on my system, the USER_BASE should be ~/Library/... I have also seen the same problem on my Linux (openSuse) machine.
The text was updated successfully, but these errors were encountered: