[issue2385] run_setup can fail if the setup script uses __file__
Fred L. Drake, Jr.
report at bugs.python.org
Fri Apr 4 07:42:38 CEST 2008
Fred L. Drake, Jr. <fdrake at acm.org> added the comment:
I don't think these are the right thing to do.
1. Your run_setup() changes add a os.chdir(), but then uses the path to
the script as passed in; this assumes that the provided path is
absolute, which is not a good assumption. That is not currently
required. The effect is that a path that works currently may not
work after the change. A relative path will not be usable to locate
support files in this case, since it no longer refers to the
directory is used to.
Also, the way you restore the current directory doesn't work;
os.curdir isn't what you think it is. This isn't covered in the
2. Apparently there are setup.py scripts that test __name__ (this
surprised me, but Google Code Search says there are many:
This change would affect those that are currently seeing
"__builtin__" (picked up from the built-in namespace).
Arguably, it's reasonable to expect run_setup() to restore the current
directory if a setup.py script does change it, but it's not clear that
the change in behavior wouldn't cause problems for existing scripts.
I've adjusted the patch so that the __file__ is supported, but the other
behaviors are omitted. This has been commited in revision 62142 on the
assignee: -> fdrake
priority: -> low
Tracker <report at bugs.python.org>
More information about the Python-bugs-list