Skip to content

Adds shebang_templates configuration for overriding shebangs.#359

Merged
zooba merged 5 commits into
python:mainfrom
zooba:gh-307
Jun 4, 2026
Merged

Adds shebang_templates configuration for overriding shebangs.#359
zooba merged 5 commits into
python:mainfrom
zooba:gh-307

Conversation

@zooba
Copy link
Copy Markdown
Member

@zooba zooba commented Jun 2, 2026

Fixes #307
Fixes #348

@zooba
Copy link
Copy Markdown
Member Author

zooba commented Jun 2, 2026

Basically just waiting on more tests, but I also haven't tested thoroughly yet so I'm sure it'll break in places. Figured I'd put it out in the open now though - I'm hoping to get it done quickly and put out a beta with it (and the other recent changes).

@zooba zooba marked this pull request as ready for review June 3, 2026 20:50
@zooba zooba requested a review from Copilot June 3, 2026 21:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable shebang_templates support so users can override/route non-standard (and POSIX-style) shebangs via pymanager.json, improving compatibility with legacy scripts and cross-platform shebang conventions.

Changes:

  • Introduces shebang_templates config schema/defaults and wires it into shebang parsing.
  • Adds _replace_templates() and integrates it into _parse_shebang() to rewrite or directly resolve template-based shebangs.
  • Expands tests and test config stubs to cover the new config field and parsing paths.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_scriptutils.py Adds tests for shebang template replacement and _parse_shebang integration.
tests/test_install_command.py Updates test command stub to include shebang_templates.
tests/conftest.py Updates fake config to include shebang_templates and aligns get_install_to_run signature with production.
src/pymanager.json Adds default shebang_templates mappings.
src/manage/scriptutils.py Implements template replacement and integrates it into shebang parsing/warnings.
src/manage/commands.py Adds config schema + BaseCommand default for shebang_templates; adjusts default source_settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/manage/scriptutils.py Outdated
Comment thread src/manage/scriptutils.py
Comment thread src/pymanager.json
Comment thread src/manage/scriptutils.py
Comment thread tests/test_scriptutils.py
zooba and others added 2 commits June 3, 2026 23:09
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@zooba zooba merged commit 080ed44 into python:main Jun 4, 2026
4 checks passed
@zooba zooba deleted the gh-307 branch June 4, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PurePath.match() incorrectly intercepts and breaks absolute shebangs shebang backwards compatibility

2 participants