Tools for using virtual environments and PEP 370

  • Thread starter Дамјан ГеоргиевÑки
  • Start date
Ð

Дамјан ГеоргиевÑки

Python 2.6 implemented PEP 370: Per-user site-packages Directory[1]
Now, are there any tools I could use to create and activate virtual
environments like workingenv, virtualenv etc. but that will use
PYTHONUSERBASE instead of hard-linking the python program.


[1]
http://docs.python.org/dev/whatsnew/2.6.html#pep-370-per-user-site-packages-directory

I tested again and setting PYTHONUSERBASE=<dir> where <dir> was created with virtualenv works just fine.
Now, it would be interesting to see if all those hacks that virtualenv does are neccesseary or not.

ps.
Of course I did try this before writing the original post, but it seems I was bitten by a bug in my own code.



--
дамјан ( http://softver.org.mk/damjan/ )

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Ð

Дамјан ГеоргиевÑки

Python 2.6 implemented PEP 370: Per-user site-packages Directory

Ok, you can completelly replace virtualenv with
a) setting PYTHONUSERBASE=<something>
b) Editing ~/.pydistutils.cfg to be like:
[install]
user=True

After this, installing new packages go to $PYTHONUSERBASE/lib/python2.6/site-packages/.

I've also tried pip.py and it mostly works fine with this setup except for one bug where
it tries to write a install-record-%s.txt file in /usr/lib/.../

I've hacked it with this crude patch (which is not correct always).

@@ -1388,7 +1389,8 @@
if sys.platform == 'win32':
install_location = os.path.join(sys.prefix, 'Lib')
else:
- install_location = os.path.join(sys.prefix, 'lib', 'python%s' % sys.version[:3])
+ import site
+ install_location = os.path.join(site.USER_BASE, 'lib', 'python%s' % sys.version[:3])
record_filename = os.path.join(install_location, 'install-record-%s.txt' % self.name)
## FIXME: I'm not sure if this is a reasonable location; probably not
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top