New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run_setup is broken in distutils #67614
Comments
With the following simple setup.py $ cat setup.py
from distutils.core import setup
from distutils.command.install import install class install1(install):
sub_commands = install.sub_commamnds
setup(name='bug', cmdclass={'install': install1}) I get >>> from distutils.core import run_setup
>>> run_setup('setup.py')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Lib/distutils/core.py", line 216, in run_setup
exec(f.read(), g, l)
File "<string>", line 4, in <module>
File "<string>", line 5, in install1
NameError: name 'install' is not defined Furthermore, on an even simpler setup.py: $ cat setup1.py
from distutils.core import setup setup(name='bug') run_setup runs, but clobbers sys.argv: >>> from distutils.core import run_setup
>>> run_setup('setup1.py', script_args=['--name'])
bug
<distutils.dist.Distribution object at 0x101dddef0>
>>> import sys;sys.argv
['setup1.py', '--name'] |
Attached patch fixes both issues. |
Added tests. |
The change in exec doesn't make sense to me (but see lower :)) __file__ should be in globals, not locals, right? Also if it is right, then exec(foo, g) should be equivalent :) The reset of the patch looks ok. But I can see your patch shows this breaking - I'm guessing its one of the things I keep forgetting about module scope evaluation and the import system - anyhoo. Applying to 3.6. Also looking at it the saving of argv is still broken even with your patch - the original argv is mutated, and the /name/ not the /value/ is restored. We should rebind argv to the copy, then restore the binding. But that can be done later. |
New changeset d8950778e3c2 by Robert Collins in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: