Support distro-packaged Python environments (read-only sys.executable)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- build-system, tooling
Research direction
Start with commands/upgrade.py and proc.py, tracing get_pythonexe_path() and copy_pythonpath_to_osenv() for assumptions about writable interpreters and filtered sys.path entries. Review the issue's proposed self-update, PYTHONPATH, and venv options before choosing a focused scope. Done should include a supported behavior for read-only distro environments without breaking normal installs.
Written by the indexing model from the issue text.
Description
PlatformIO is packaged by several Linux distributions (NixOS, Guix, Arch, Fedora, etc.). Distro packages install PlatformIO into a read-only Python environment where sys.executable points to an interpreter that can't be written to by pip install.
This causes a few problems that distro maintainers currently work around with patches:
upgrade.pyrunspip install --upgradeagainst a read-only interpreter
commands/upgrade.py calls pip install --upgrade using get_pythonexe_path(). On distro installs, this fails because the site-packages directory is in a read-only store. An env var like PLATFORMIO_DISABLE_SELF_UPDATE=1 (or detecting a read-only prefix) would let distro packages skip this cleanly.
copy_pythonpath_to_osenv()filters paths by looking forclick/orplatformio/directories
proc.py only adds sys.path entries to PYTHONPATH if they contain a click or platformio subdirectory. Distro packages install each dependency in its own prefix (e.g., NixOS has one store path per package), so this heuristic drops most of them. The SCons subprocess then can't import PlatformIO's dependencies.
NixOS patches this to just use sys.path directly. Would you accept a change that uses sys.path unconditionally on Linux, or respects an existing PYTHONPATH when set?
- Framework build scripts (esp-idf, Zephyr) assume they can
pip installintosys.executable's environment
This isn't PlatformIO's code directly, but PlatformIO controls which Python the frameworks see. If get_pythonexe_path() could point to a writable venv that inherits the system packages (via --system-site-packages), frameworks could install their deps there without touching the system Python.
Would you consider supporting a PLATFORMIO_PYTHON_VENV env var? If set, PlatformIO would create a venv at that path (or reuse an existing one) and use it as the Python for builds. This would let PlatformIO and its frameworks install deps freely while the base installation stays read-only.
For context, NixOS currently carries a bunch of patches against platformio-core to work around these issues, plus wraps the whole thing in a bubblewrap FHS chroot. I'd rather reduce that patch surface if there's a way to do it that works for you too.
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 916
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from platformio/platformio-core
-
Toolchain include order from DumpIntegrationIncludes depends on directory order (unsorted glob)Possibly taken @Leooo21 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
platformio/platformio-core#5555 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
platformio/platformio-core#5554 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
platformio/platformio-core#5552 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
platformio/platformio-core#5551 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
platformio/platformio-core#5553 ·
Maintainers usually reply within 1 day
All issues in platformio/platformio-core
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day