Bug 15372

Summary: Mark python packages as externally managed
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Ross Burton <ross.burton>
Component: devtools / tool chainAssignee: Ross Burton <ross.burton>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: Medium CC: meta.mr.watcher, meta.watcher, randy.macleod, tim.orling
Version: 4.3   
Target Milestone: 6.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Ross Burton 2024-01-29 14:30:28 UTC
As per https://packaging.python.org/en/latest/specifications/externally-managed-environments/, we should mark /usr/lib/python3.X as "externally managed", so that pip doesn't try and delete/upgrade/install into it directly.

1) tell python and pip to look in /usr/local/ so that there is still somewhere system-level to write to
2) Drop an EXTERNALLY-MANAGED file into /usr/lib/python3.X.

Regarding (1), https://github.com/pypa/distutils/pull/70 looks relevant.
Comment 1 Tim Orling 2024-03-28 15:18:47 UTC
I believe this means that for crops containers we will need virtualenv installed (which is already required for debian-12 anyway). Otherwise, the user cannot run `pip install --user` at runtime?
Comment 2 Tim Orling 2024-03-28 15:28:12 UTC
This would be possibly too invasive or affect other layers in some odd behaviour changes, so moving to 5.1 M1.
Comment 3 Ross Burton 2024-03-28 16:01:06 UTC
pip install --user will still work.
Comment 4 Tim Orling 2024-03-28 18:24:13 UTC
(In reply to Ross Burton from comment #3)
> pip install --user will still work.

Yeah, I think I meant `pip install` will not work without `--user`. Munging multiple things from some work happening in crops for debian-12 and virtualenv.