[Distutils] Question on using distutils.core.run_setup
Tarek Ziadé
ziade.tarek at gmail.com
Tue Mar 18 17:55:13 CET 2008
On Tue, Mar 18, 2008 at 5:34 PM, Phillip J. Eby <pje at telecommunity.com>
wrote:
> [cut]
> I never could get run_setup() to work robustly.
>
>
> Here's how setuptools does it, and it works well with quite a lot of
> packages:
>
> os.chdir(setup_dir)
> try:
> sys.argv[:] = [setup_script]+list(args)
> sys.path.insert(0, setup_dir)
> DirectorySandbox(setup_dir).run(
> lambda: execfile(
> "setup.py",
> {'__file__':setup_script, '__name__':'__main__'}
> )
> )
> except SystemExit, v:
> if v.args and v.args[0]:
> raise
> # Normal exit, just return
>
> This is actually wrapped in a try-finally that saves and restores
> sys.argv, sys.path, os.chdir(), etc. Have a look at
> setuptools.sandbox.run_setup() for the full source.
>
Cool ! Maybe this could be pushed into distutils ? It looks more like a fix
to me
Tarek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/distutils-sig/attachments/20080318/de2615f1/attachment.htm
More information about the Distutils-SIG
mailing list