#4201 [Other] setup: sycl/setup_intel.py started with the system Python runs again with .venv's (Permission denied on /usr/.strata-pip.json)

open · @andersson82 · 0 comentarios · En GitHub

Setup & install

Descripción

Problem and result: if you run `python sycl/setup_intel.py` directly, setup runs with the system Python. On Fedora 44 (Python 3.14, Arc 140T) it got to Step 3, ran pip and then stopped:

```
  File "/home/johan/Strata/setup.py", line 3399, in pip_install
    stamp.write_text(json.dumps(sorted(set(have) | set(need)), indent=0))
PermissionError: [Errno 13] Permission denied: '/usr/.strata-pip.json'
```

`pip_install` writes its stamp to `sys.prefix`, which is `/usr` for the system Python. With this change the script runs itself again with `.venv/bin/python` when it is not in a virtual environment. If there is no `.venv`, it says to run `./setup.sh --backend sycl` and exits. Inside a virtual environment, such as through `setup.sh` or setup.py's `--backend sycl` hand-off, which both use the `.venv` Python, nothing changes.

Related discussion: none. I found no issue or PR about it.

Approach: a check in `sycl/setup_intel.py`'s `__main__`, before `install()`. `setup.py` is not changed, so the SYCL port stays out of the shared files. The check is not run at import, so the tests that import the module are not affected.

Validation:
  Passed: `.venv/bin/python tools/test_setup_sycl.py` on 4329ac1d (Fedora 44, Python 3.14.8): 26 tests OK. The new `UseVenv` test covers the hand-over to .venv, staying put inside a venv, and the message when there is no .venv.
  Passed: `python sycl/setup_intel.py --check` with the system Python in a checkout without `.venv` prints `This needs Strata's own Python environment. Run: ./setup.sh --backend sycl [setup's options]` and exits 1.
  Passed: in a checkout with `.venv`, starting the script with the system Python calls `os.execv` with `.venv/bin/python`, `sycl/setup_intel.py` and the same options. Checked with `os.execv` stubbed.
  Failed: none observed.
  Not run: a full setup run to the end after the hand-over. No engine build was needed, because no C++/SYCL file changed.

Limits: this only finds `.venv` in the checkout's root, the folder `setup.sh` creates. Another virtual environment the user has activated is used as it is. Packages that the system Python's pip installed before this fix stay where pip put them (usually `~/.local`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

En el sitio

Enlaces a install, modelos, releases.