At 03:39 PM 7/11/2005 +0100, Michael Hoffman wrote:
>I was trying to install setuptools in my home directory on a system I
>don't have root access to using the command "python setup.py install
>--home=~". Of course, since it installs as an egg, I can't use it
>unless I *specifically* add it to my PYTHONPATH. This would be a pain
>should it be necessary to add for every egg I install.

It isn't necessary.  All you need to do is ensure that the setuptools egg 
is on PYTHONPATH; everything else can then be handled by 
EasyInstall-generated script wrappers or by manual use of require().

So, basically, if you have this non-root scenario, you have to put the 
setuptools egg directly on your PYTHONPATH, and everything should be fine 
after that.


>I've added a workaround to my ~/lib/python/sitecustomize.py
>(~/lib/python is in PYTHONPATH) which uses the existing machinery in
>site.py to process .pth files in all of the entries of sys.path, not
>just the default sitedirs.

Unfortunately EasyInstall can't know that you're doing this, so it's not 
going to generate a .pth file in your ~/lib/python directory.  Basically, 
you need to learn to live with --multi-version mode, which has benefits as 
well as drawbacks.  When EasyInstall installs in multi-version mode, you 
can't just fire up the interpreter and import the package, you have to 
either call require() to ask for the package by name and version, *or* you 
can run any script that was installed with the package and it'll work just 
fine because EasyInstall creates a wrapper around the script that does the 
require() for you.

If you're using packages that depend on each other, or creating your own 
packages, you can create a wrapper package that's just a setup.py and 
whatever programs you need to run.  In the setup.py, you declare your 
dependencies on the other packages, and then you run "setup.py develop" to 
generate wrappers for your new scripts and set up your project as an 
egg.  The steps are detailed in the new setuptools Developers' Guide at:

     http://peak.telecommunity.com/DevCenter/setuptools

In particular, pay close attention to the sections on "Basic Use", 
"Declaring Dependencies", "Development Mode", and on the "develop" command.


>I've noticed, however, that Guido has rejected a patch
><http://www.python.org/sf/1174614> to have the default site.py search
>.pth files in other directories, mainly because all the extra path
>searching at each startup might slow down startup on some systems.
>
>The best solution I can think of is to think of is to have some
>directory that is explicitly searched for .pth files (or even
>.egg/.zip files) and has them added to the path. This would still
>require some changes to sitecustomize.py (and hopefully eventually
>site.py), so it keeps eggs from working OOTB on this type of system.
>
>What do you think is the best way to have eggs loaded from non-system
>installs?

I don't think that the patch makes much difference; there's nothing 
stopping web hosters or others from adding a line like this to a .pth file 
in site-packages now:

     import os; addsitedir(os.path.expanduser('~/lib/python2.3')) # or 2.4

Which will do the same as the patch proposes to do for every line in each 
.pth file.  If you can get your service provider to put this in a .pth file 
in site-packages, you're pretty much set, except for the fact that 
EasyInstall will still think you need to do a multi-version 
install.  However, you won't need PYTHONPATH and you won't need to manage 
it except by manipulating .pth files in your ~/lib/python2.3 or whatever 
directory.  And, I could probably add an option to EasyInstall (and 
setuptools install/develop commands) to force .pth usage even if you're 
installing somewhere other than site-packages.

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to