Bug 15372 - Mark python packages as externally managed
Summary: Mark python packages as externally managed
Status: NEW
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 4.3
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 6.2
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-01-29 14:30 UTC by Ross Burton
Modified: 2026-10-28 11:51 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.