many: account for python shebang args in rewrite
Metadata
Current evaluation
Merged after reviewer approval and passing tests. Unifies Python shebang rewrite logic to properly handle arguments instead of relying on /usr/bin/env. Resolves Launchpad bugs #1730472 and #1673451.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Currently Snapcraft rewrites absolute Python shebangs to point into the snap by using `/usr/bin/env`. However, `/usr/bin/env` doesn't handle shebang args, whereas Python itself does.
This PR fixes LP: [#1730472](https://bugs.launchpad.net/snapcraft/+bug/1730472) by accounting for the possibility of shebang args in rewrite, and making sure that all components that rewrite the Python shebang use the same code path to do so. As a side effect of this last step, this PR also fixes LP: [#1673451](https://bugs.launchpad.net/snapcraft/+bug/1673451).
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged after reviewer approval and passing tests. Unifies Python shebang rewrite logic to properly handle arguments instead of relying on /usr/bin/env. Resolves Launchpad bugs #1730472 and #1673451. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged after local testing. Updates Snapcraft to handle Python shebang arguments during rewrite, resolving bugs #1730472 and #1673451. Unifies shebang rewriting logic across components. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Updates Snapcraft's Python shebang rewrite logic to handle shebang arguments unsupported by /usr/bin/env. Unifies the rewrite code path, resolving Launchpad bugs 1730472 and 1673451 after passing local tests. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #680 Rewrite shebangs generated by the python plugins. | snapcraft | merged | Merged changes that rewrite Python plugin shebangs to use env instead of hardcoded paths, resolving Launchpad bug #1597919. After adding requested integration tests, the changes were approved and merged across 13 files. | |
| #823 plainbox-provider plugin: rewrite python shebangs | snapcraft | merged | Merged rewrite of Python shebangs in the plainbox-provider plugin to use /usr/bin/env python. Approved by two reviewers across five files. Resolves LP: #1626587. Missing unit tests were noted but acknowledged as unavailable. | |
| #649 Use '/usr/bin/env python3' | snapcraft | merged | Merged an external contribution updating shebangs to /usr/bin/env python3 across two files, resolving Launchpad bug LP:#1602379. Accepted without review comments or CI checks. |