Ian Bicking: the old part of his blog

Working env comment 000

The setuptools stuff is hacky, and now I can't remember why I did it the way I did. That lib/python2.4/setuptools.pth file should contain the real path to setuptools, which gets used by setuptools/__init__.py. I put in a slightly better error message in this case (at least not NameError). I've been trying to figure out if working-env.py should actually install setuptools locally as part of the setup; it kind of seems like it should.

Comment on Re: working-env.py
by Ian Bicking


I think that would be a logical way to do it. I was admittedly surprised that system-wide setuptools was required by working-env, since I was used to putting it locally into a virtual-python. I think it would be less hassle if it were possible to use working-env as a pre-setuptools bootstrap. Perhaps working-env could optionally/automatically run ez_setup.py within the newly-created environment?

I've switched back to virtual-python for now :)

# Matthew Scott

I have to second this comment. The whole reason for me running something like working-env or virtual-python is so that I don't have to mess with my virgin Python installation. If I have to install setuptools first, it kind of defeats the purpose....

# mbogosian

Your activate script is also kind of tricky (i.e., it looks like "activating" twice really means deactivate). If I may make a suggestion to rename it "toggle-wenv" or something to make that clearer.

Also, if PYTHONPATH is unset when it is run, the new PYTHONPATH will have a trailing ':' which may result in including the current working directory in the PYTHONPATH which may not be the best idea. It also may be harmless, but I don't think it hurts to be careful, especially if other modifying scripts acticipate a well-formed PYTHONPATH variable.

In addition, I might suggest using more unique names for your saved PYTHONPATH and PATH variables (this is a common trick and one probably doesn't want to risk a name clash). Here's a patch for working-env.py which includes all my suggestions (it's also a little friendlier to those WORKING_ENV paths which contain spaces:

--- working-env.py      2006-04-20 23:21:49.000000000 -0700
+++ working-env.py.new  2006-04-21 10:09:50.000000000 -0700
@@ -203,22 +203,22 @@
 script_dir = __WORKING__/bin/
-files_to_write['bin/activate'] = """\
-# This file must be used with "source bin/activate"
+files_to_write['bin/toggle-wenv'] = """\
+# This file must be used with "source bin/toggle-wenv"
 # you cannot run it directly
-export WORKING_ENV=%(working_env)s
-if [ -n "$_OLD_WORKING_PATH" ] ; then
+export WORKING_ENV='%(working_env)s'
+if [ -n "$_WORKING_ENV_OLD_PATH" ] ; then
-if [ -n "$_OLD_PYTHONPATH" ] ; then
+if [ -n "$_WORKING_ENV_OLD_PYTHONPATH" ] ; then
-export PYTHONPATH=$WORKING_ENV/lib/python%(python_version)s:$PYTHONPATH
+export PYTHONPATH="$WORKING_ENV/lib/python%(python_version)s${PYTHONPATH:+:}$PYTHONPATH"
 def make_working_environment(

I hope this helps a little.

# mbogosian


I forgot to also change this line:


To this (note the quotes):

export PATH="$WORKING_ENV/bin:$PATH"
# mbogosian