Skip to content

pip wheel install scripts not respecting parameters after #!python #10661

Open
@mducle

Description

@mducle

Description

I'm not sure if this is a bug or if it's the desired behaviour (I couldn't find any docs on it), but if I create a script with an argument after the interpreter in the shebang, e.g. #!python -i the argument is ignored / missed out when the wheel is installed and the python string is replaced by the real python executable.

This doesn't happen if I install it as an egg.

Expected behavior

I expected that arguments in the shebang line are retained, and the behaviour in eggs and wheels are the same.

pip version

21.3.1

Python version

3.7

OS

Windows 10

How to Reproduce

My setup to reproduce this has the following structure:

top
|-- mypackage
|   |-- __init__.py
|-- scripts
|   |-- interactive_script.py
`-- setup.py

scripts/interactive_script.py is:

#!python -i

import mypackage

mypackage.do_some_preprocessing()

mypackage/__init__.py is:

def do_some_preprocessing():
    print('Done some preprocessing')
    print('Now starting an interactive session')

setup.py is:

from setuptools import setup

setup(
    name='mypackage',
    packages=['mypackage'],
    scripts=['scripts/interactive_script.py']
)

So, I expect that when I run interactive_script.py it would print the two lines and then go into a Python prompt. This is what happens when I do python setup.py install and install an egg.

But if I do python setup.py bdist_wheel or pip wheel . and then install the wheel, it just prints the two lines and exits.

Output

$ python setup.py install
$ interactive_script.py
Done some preprocessing
Now starting an interactive session
>>> quit()

$ pip uninstall mypackage
$ pip wheel .
$ pip install mypackage-0.0.0-py3-none-any.whl
$ interactive_script.py
Done some preprocessing
Now starting an interactive session
$

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: scriptsHow scripts and entry points are managedC: wheelThe wheel format and 'pip wheel' commandPEP implementationInvolves some PEPstate: awaiting PRFeature discussed, PR is neededtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions