Skip to content

shebang rewrite in installed scripts do not respect extra args passed to the interpreter #14470

@mayeut

Description

@mayeut

Summary

e.g. a script in the wheel looks like:

#!python -E
import sys


from cmake import cpack

if __name__ == '__main__':
    if sys.argv[0].endswith('-script.pyw'):
        sys.argv[0] = sys.argv[0][: -11]
    elif sys.argv[0].endswith('.exe'):
        sys.argv[0] = sys.argv[0][: -4]

    sys.exit(cpack())

The script gets installed as:

#!/bin/sh
'''exec' '/private/var/folders/hb/2n_7f3yn20v06lzz3129dtw80000gn/T/cibw-run-sz3abzyq/cp39-macosx_universal2/venv-test-x86_64/bin/python3' "$0" "$@"
' ''' -E

import sys


from cmake import cpack

if __name__ == '__main__':
    if sys.argv[0].endswith('-script.pyw'):
        sys.argv[0] = sys.argv[0][: -11]
    elif sys.argv[0].endswith('.exe'):
        sys.argv[0] = sys.argv[0][: -4]

    sys.exit(cpack())

The -E argument is not being written where it should be.
pip installing the same wheel creates a working script.
The spec is unclear but the assumption in pip (or maybe distutils) is that arguments present behind the interpreter shall be left untouched (i.e. not removed).

Platform

macOS 15

Version

uv 0.7.19

Python version

Python 3.12.10

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompatibilityCompatibility with a specification or another toolhelp wantedContribution especially encouraged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions