Closed GoogleCodeExporter closed 8 years ago
The new script that virtualenv 1.3 provides contains:
import sys
import os
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3],
'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
One issue with this script is that it sets sys.prefix. Thus that this script is
offered as way of using virtualenv 1.3 with mod_python/mod_wsgi is wrong and
may cause
problems because it may override what would be correct sys.prefix.
The only part of this script which is really relevant to mod_wsgi is the
reordering of sys.path.
Original comment by Graham.Dumpleton@gmail.com
on 28 Sep 2008 at 7:05
Code for reordering sys.path added in revision 1102 of subversion trunk for
mod_wsgi 3.0.
Original comment by Graham.Dumpleton@gmail.com
on 28 Oct 2008 at 11:22
The actual Python code snippet you should use to do reordering, ie., with
unnecessary stuff above deleted is:
import sys
prev_sys_path = list(sys.path)
import site
site.addsitedir('/some/path/.../site-packages')
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
Ie., this would replace the:
site.addsitedir('/some/path/.../site-packages')
Ammendments to:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
coming soon.
Original comment by Graham.Dumpleton@gmail.com
on 27 Nov 2008 at 6:17
Backported to 2.X for 2.4 in r1248.
Original comment by Graham.Dumpleton@gmail.com
on 17 Mar 2009 at 6:44
In python 2.6 Python has gained the support for "Per user site-packages
directory"
(pep-370) ... actually it's not per user but per config, since a single user
can have
several of these local site-packages directories.
The important part is the site.adduserpackage() function
(http://www.python.org/dev/peps/pep-0370/#implementation) that does the correct
thing
vis-a-vis virtual environments.
Original comment by gdam...@gmail.com
on 1 Apr 2009 at 1:23
Version 2.4 of mod_wsgi now released.
Original comment by Graham.Dumpleton@gmail.com
on 11 Apr 2009 at 10:25
Original issue reported on code.google.com by
Graham.Dumpleton@gmail.com
on 26 Sep 2008 at 11:45