indygreg / indygreg/PyOxidizer

Respect PYTHONPATH

Open
#150 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
6.2k
Forks
256
PR merge metrics
No merged PRs in 30d

Description

Adding the ability to manipulate `PYTHONPATH` / `sys.path` would be a big first step towards https://github.com/indygreg/PyOxidizer/issues/141

```py
> PYTHONPATH=/usr/lib64/python3.7 ./build/apps/foo/x86_64-unknown-linux-gnu/debug/foo
>>> import sys
>>> import pkg_resources
>>> sys.path
[]
>>> sys.path.append('/usr/lib64/python3.7')
>>> import test
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'test'
```
That should keep the internal modules being loaded first, but also load `test` from the disk.

I have seen in recent commits that app-relative .py files might be supported. I'll try that next, but it doesnt negate the need for dynamic addition of paths, and fiddling with `PYTHONPATH` is a very common trick in distro packaging scripts.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the built app at build/apps/foo/x86_64-unknown-linux-gnu/debug/foo initializes Python imports and handles sys.path or environment variables. Reproduce the PYTHONPATH example from the issue, then verify that internal modules remain first while a disk module such as test becomes importable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.