[Distutils] Something that doesn't run from an egg
Phillip J. Eby
pje at telecommunity.com
Wed Jul 6 22:46:44 CEST 2005
At 04:01 PM 7/6/2005 -0400, Kevin Dangoor wrote:
>On 7/6/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> > Can you give me the download URL for the py source distro so I can try to
> > reproduce this?
>
>Right now, it's only available from subversion:
>
>svn co http://codespeak.net/svn/py/dist py-dist
Note that you can just "easy_install http://codespeak.net/svn/py/dist" to
install it directly from subversion, without needing a manual
checkout. (You *do* need a subversion client on your PATH, however.)
Here's a patch to setuptools that appears to fix the problem (by not
running imported scripts as __main__), and it's probably a good idea to add
it to setuptools in any case. Meanwhile, however, somebody should probably
tell the py folks that _findpy is a horrible, *horrible* hack and should be
shot. :)
Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.36
diff -u -r1.36 pkg_resources.py
--- pkg_resources.py 6 Jul 2005 03:46:16 -0000 1.36
+++ pkg_resources.py 6 Jul 2005 20:42:14 -0000
@@ -104,11 +104,11 @@
def run_main(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
- import __main__
- __main__.__dict__.clear()
- __main__.__dict__.update({'__name__':'__main__'})
- require(dist_spec)[0].metadata.run_script(script_name, __main__.__dict__)
-
+ ns = sys._getframe(1).f_globals
+ name = ns['__name__']
+ ns.clear()
+ ns['__name__'] = name
+ require(dist_spec)[0].metadata.run_script(script_name, ns)
More information about the Distutils-SIG
mailing list