msg63906 - (view) |
Author: Tarek Ziadé (tarek) *  |
Date: 2008-03-18 10:24 |
When calling run_setup, the execfile does not set the __file__ global variable, that is often used in setup.py modules (for instance to load a text file from the package to be used in the long_description) This patch adds this global variable so it does not fail. No test provided (distutils would need a test_core.py). I could work on some tests, but the previous test_* files I have added are not in yet, so i'd rather wait for that before proposing new tests modules. |
|
|
msg64328 - (view) |
Author: Tarek Ziadé (tarek) *  |
Date: 2008-03-22 14:59 |
new patch that adds __main__ and __file__, and make a chdir, so the function is called in a realistic way. this patch also adds test_core.py for this change. |
|
|
msg64916 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2008-04-04 05:42 |
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 test, either. 2. Apparently there are setup.py scripts that test __name__ (this surprised me, but Google Code Search says there are many: http://www.google.com/codesearch?q=file%3Asetup.py+%22__main__%22). 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 trunk. |
|
|
msg64917 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2008-04-04 05:52 |
Here's a patch that restores the current directory after running the script. The distutils-sig should probably determine if that's the right thing to do. Includes test. |
|
|
msg64924 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2008-04-04 11:34 |
Of course, my previous commit did what I said it should not in #1 above: it changed the current directory to the directory in which the setup.py script lived (which made __file__ wrong). Fixed in revision 62147, including test that checks that the script is run in the current directory of the caller. |
|
|
msg64925 - (view) |
Author: Tarek Ziadé (tarek) *  |
Date: 2008-04-04 11:42 |
right, I misused os.curdir, I wanted the current working directory. (getcwd()) Thanks for correcting it and making it a separate patch |
|
|
msg64927 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2008-04-04 11:43 |
Updated patch to add restoring the current directory after running the setup.py script in run_script. |
|
|
msg64928 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2008-04-04 12:34 |
It's also arguable that not providing __file__ was a bug, in which case that should be backported to Python 2.5.x. |
|
|