Skip to content
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

Closed
abalkin opened this issue Feb 9, 2015 · 5 comments
Closed

run_setup is broken in distutils #67614

abalkin opened this issue Feb 9, 2015 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@abalkin
Copy link
Member

abalkin commented Feb 9, 2015

BPO 23426
Nosy @abalkin, @rbtcollins, @merwok, @dstufft
Files
  • setup1.py
  • setup.py
  • issue23426.patch
  • issue23426-with-tests.patch
  • 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:

    assignee = None
    closed_at = <Date 2015-07-28.04:00:48.191>
    created_at = <Date 2015-02-09.21:06:45.198>
    labels = ['type-bug', 'library']
    title = 'run_setup is broken in distutils'
    updated_at = <Date 2015-07-28.04:00:48.190>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2015-07-28.04:00:48.190>
    actor = 'rbcollins'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-07-28.04:00:48.191>
    closer = 'rbcollins'
    components = ['Distutils']
    creation = <Date 2015-02-09.21:06:45.198>
    creator = 'belopolsky'
    dependencies = []
    files = ['38064', '38066', '38067', '38071']
    hgrepos = []
    issue_num = 23426
    keywords = ['patch']
    message_count = 5.0
    messages = ['235632', '235634', '235650', '247499', '247500']
    nosy_count = 5.0
    nosy_names = ['belopolsky', 'rbcollins', 'eric.araujo', 'python-dev', 'dstufft']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23426'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @abalkin
    Copy link
    Member Author

    abalkin commented Feb 9, 2015

    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']

    @abalkin abalkin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 9, 2015
    @abalkin
    Copy link
    Member Author

    abalkin commented Feb 9, 2015

    Attached patch fixes both issues.

    @abalkin
    Copy link
    Member Author

    abalkin commented Feb 10, 2015

    Added tests.

    @rbtcollins
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 28, 2015

    New changeset d8950778e3c2 by Robert Collins in branch 'default':
    Issue bpo-23426: run_setup was broken in distutils.
    https://hg.python.org/cpython/rev/d8950778e3c2

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants