Skip to content

shebang backwards compatibility #307

Closed

Description

@felixhirt

The problem: backwards compatibility with old python scripts using non-standard shebang lines is not available. Old py launcher supported such shebangs, new one cannot.
example:
python script:

#!/opt/indel/bin/indel-python2
import traceback
import time

py.ini:

[commands]
/opt/indel/bin/indel-python2=C:\indel\share\python\python27\python.exe
/opt/indel/bin/indel-pythonw2=C:\indel\share\python\python27\pythonw.exe

Could you add a way to define non-standard shebangs again? e.g. in pymanager.json a list of shebangs and target exes like in old py.ini?

Alternative: We installed py launcher again, but this is legacy

Activity

  1. zooba commented on Apr 10, 2026

    @zooba
    Member

    I really don't want shebangs to become a "run arbitrary executable" feature here - a lot of malicious code loves to hide behind legitimate programs, and we want py.exe to be treated as a legitimate program. So that really puts me off having it launch anything that it isn't responsible for.1

    Would it work if you could map an arbitrary command like /opt/indel/bin/indel-python2 to a -V option, like "/opt/indel/bin/indel-python2": "-V:PythonCore\\2.7"? Non-standard Python installs can be registered using PEP 514 for this (you can test if it's already registered with py -V:2.7), and managed ones (which we hope will be the future) are of course included.

    If you really do need a tool that handles shebangs to arbitrary executable, then I think you may need to find it elsewhere. We want the Python launcher to launch Python, not anything.

    Footnotes

    1. Malicious code can, of course, replace those legitimate executables and "win" that way, but that's outside of our threat model. ↩

  2. felixhirt commented on Apr 15, 2026

    @felixhirt
    Author

    Yes, this should work for us, would be great if you can implement this

  3. self-assigned this
    on Jun 2, 2026
  4. added a commit that references this issue on Jun 4, 2026
    080ed44
  5. zooba commented on Jun 4, 2026

    @zooba
    Member

    There is now a beta release at https://www.python.org/downloads/release/pymanager-263b1/ with the change to add the configuration setting I proposed. The docs are currently at https://github.com/python/cpython/pull/150931/changes but should be on the website today/tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions