python plugin: do not leak snapcraft's site-packages
Metadata
Current evaluation
Merged #2901 fixed Python plugin builds leaking Snapcraft's $SNAP/site-packages by conditioning that path on SNAPCRAFT_INTERPRETER (commit c13c79d76).
Resolution: closed resolved
Reason: PR #2901 was merged as commit c13c79d76. Its sitecustomize change uses SNAPCRAFT_INTERPRETER to prevent Snapcraft runtime site-packages from leaking into ordinary build environments.
Evaluated by: mr-cal-bot
No scores available.
Issue body
The current sitecustomize generated by the python plugin always considers
adding site-packages from $SNAP which is only meant for runtime. This is a
problem as snapcraft runs in the context of a snap, so $SNAP always exists
in the environment.
When building, snapcraft exports SNAPCRAFT_INTERPRETER, use this as a condition
to export site-packages found under $SNAP.
LP: #1860884
Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged #2901 fixed Python plugin builds leaking Snapcraft's $SNAP/site-packages by conditioning that path on SNAPCRAFT_INTERPRETER (commit c13c79d76). | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2901 (commit c13c79d76) fixed Python builds leaking Snapcraft's $SNAP/site-packages; paths are now exposed only when SNAPCRAFT_INTERPRETER is set. Shipped in Snapcraft 3.10. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2901 stopped the Python plugin leaking $SNAP/site-packages into builds by exporting it only when SNAPCRAFT_INTERPRETER is set; commit c13c79d76. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged fix preventing the Python plugin from leaking snapcraft site-packages during builds. sitecustomize now conditionally exports $SNAP/site-packages only when SNAPCRAFT_INTERPRETER is set, resolving build environment pollution. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix preventing the Python plugin from leaking snapcraft's site-packages during builds. The change conditionally exports SNAP site-packages only when SNAPCRAFT_INTERPRETER is set, resolving LP #1860884. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1860884 Python plugin: paths for from the snapcraft snap in sys.path break dependencies | snapcraft (launchpad) | closed | Snapcraft's Python plugin no longer leaks its site-packages into part builds. Fixed by snapcore/snapcraft#2901 (c13c79d76a) and released in Snapcraft 3.10. | |
| #1631057 python plugin "No module named site" | snapcraft (launchpad) | closed | Fixed by snapcraft PR #858 (commit a2054b8a7), which made the Python plugin compatible with bzr-backed requirements. | |
| #1767434 Host python dist-packages in sys.path of snapcraft's python | snapcraft (launchpad) | closed | Merged in snapcore/snapcraft#2131 (commit 9dfbdbaba), disabling Python user site-packages for Snapcraft, closing this report about host/user paths leaking into snapcraft's python sys.path. |