@ai-ecoverse/wasix-python 3.14.2-10 → 3.14.2-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,27 +28,33 @@ PYTHONPATH=<dir>/lib/python3.14/site-packages python -c "import six"
28
28
 
29
29
  On plain Wasmer without `_ssl`, use a local wheel (`--no-index --find-links`) until openssl/`_ssl` is enabled.
30
30
 
31
- ## Virtual environments (3.14.2-10)
31
+ ## Virtual environments (slicc-kernel ≥ 1.29.0)
32
32
 
33
33
  ```text
34
34
  python -m venv v && v/bin/pip install requests && v/bin/python -c "import requests"
35
35
  ```
36
36
 
37
- `lib/python3.14/sitecustomize.py` sets `sys.executable` from PATH (WASI
38
- `stat()` has no permission bits, so CPython cannot find itself), so
39
- `python -m venv` works. A `sitecustomize` of your own still runs.
37
+ **Venvs need slicc-kernel ≥ 1.29.0** (`engines` says so). On older kernels a
38
+ venv's `bin/python` and `bin/pip` run as the base interpreter: `v/bin/pip
39
+ install` then installs into the **base** package directory, not the venv.
40
40
 
41
- Whether a venv's own python sees the venv depends on the kernel:
41
+ CPython cannot find its own executable here (WASI `stat()` has no permission
42
+ bits, so its PATH search never matches), so `_slicc_site.py` sets
43
+ `sys.executable` from PATH. Two hooks run it:
44
+ `site-packages/slicc-executable.pth` for the base interpreter (a
45
+ `sitecustomize` of yours on `PYTHONPATH` cannot switch it off) and the stdlib
46
+ `sitecustomize.py` for venvs without system site-packages. A `sitecustomize`
47
+ of your own still runs after ours, and `import sitecustomize` returns yours.
42
48
 
43
- | | slicc-kernel < 1.29.0 | slicc-kernel ≥ 1.29.0 (#168) |
49
+ `python` and `python3` set `"argv0Path": true`, so slicc-kernel ≥ 1.29.0
50
+ (#168) passes a venv's `bin/python` path as `argv[0]`; that is how CPython
51
+ finds the venv's `pyvenv.cfg`:
52
+
53
+ | | slicc-kernel < 1.29.0 | slicc-kernel ≥ 1.29.0 |
44
54
  | --- | --- | --- |
45
- | `v/bin/python`, `v/bin/pip`, venv console scripts | run as the **base** interpreter (they install into, and import from, the base) | run **in the venv** |
46
- | `source v/bin/activate; python …` | base interpreter (`python` on PATH is a link to the command) | in the venv |
55
+ | `v/bin/python`, `v/bin/pip`, venv console scripts | run as the **base** interpreter (install into, and import from, the base) | run **in the venv** |
56
+ | `source v/bin/activate; python …` | base interpreter | in the venv |
47
57
  | `uv run …` ([`@ai-ecoverse/wasix-uv-shim`](https://www.npmjs.com/package/@ai-ecoverse/wasix-uv-shim)) | in the venv | in the venv |
48
58
 
49
- `python` and `python3` set `"argv0Path": true`, so a kernel with
50
- slicc-kernel#168 passes a venv's `bin/python` path as `argv[0]`; that is
51
- how CPython finds the venv's `pyvenv.cfg`. Until then,
52
- use `uv run` or set `PYTHONEXECUTABLE=$PWD/v/bin/python`.
53
-
54
- 3.14.2-10 is 3.14.2-9's files plus `sitecustomize.py`.
59
+ 3.14.2-11 is 3.14.2-9's files plus `sitecustomize.py`, `_slicc_site.py` and
60
+ `site-packages/slicc-executable.pth`.
@@ -0,0 +1,27 @@
1
+ """slicc (homescoop wasix-python): give the interpreter a sys.executable.
2
+
3
+ WASI stat() has no permission bits, so CPython's PATH search for argv[0]
4
+ (getpath's isxfile) never matches the kernel's /usr/bin commands and
5
+ sys.executable stays '' (python -m venv then refuses to run). fix() fills
6
+ it in from PATH. It runs twice per start, idempotently: from
7
+ site-packages/slicc-executable.pth (base interpreter; a sitecustomize on
8
+ PYTHONPATH cannot shadow it) and from the stdlib sitecustomize.py (venvs
9
+ without system site-packages, which skip the base .pth files). A venv's own
10
+ bin/python gets its path from argv[0] on slicc-kernel >= 1.29.0.
11
+ """
12
+ import os
13
+ import sys
14
+
15
+
16
+ def fix():
17
+ if sys.executable:
18
+ return
19
+ argv0 = sys.orig_argv[0] if sys.orig_argv else ""
20
+ name = os.path.basename(argv0) or "python3"
21
+ for d in os.environ.get("PATH", "/usr/bin:/bin").split(os.pathsep):
22
+ p = os.path.abspath(os.path.join(d or ".", name))
23
+ if os.path.isfile(p):
24
+ sys.executable = p
25
+ if not getattr(sys, "_base_executable", ""):
26
+ sys._base_executable = p
27
+ return
@@ -0,0 +1 @@
1
+ import _slicc_site; _slicc_site.fix()
@@ -1,28 +1,13 @@
1
- # slicc (homescoop wasix-python): fill in sys.executable when getpath could
2
- # not. WASI stat() has no permission bits, so CPython's PATH search for
3
- # argv[0] (isxfile) never matches the kernel's /usr/bin commands and
4
- # sys.executable stays '' (python -m venv then refuses to run). A venv's
5
- # python is found from argv[0] once slicc-kernel passes the invoked path
6
- # (slicc-kernel#168); this only covers the base interpreter.
7
- #
8
- # Shipped in the stdlib directory, so it shadows a sitecustomize further
9
- # down sys.path; that one is still run, after this.
1
+ # slicc (homescoop wasix-python): sys.executable for the interpreter, see
2
+ # _slicc_site.py. Shipped in the stdlib directory, so it shadows a
3
+ # sitecustomize further down sys.path; that one still runs, after this, and
4
+ # is what `import sitecustomize` then returns.
10
5
  import os
11
6
  import sys
12
7
 
8
+ import _slicc_site
13
9
 
14
- def _slicc_executable():
15
- if sys.executable:
16
- return
17
- argv0 = sys.orig_argv[0] if sys.orig_argv else ""
18
- name = os.path.basename(argv0) or "python3"
19
- for d in os.environ.get("PATH", "/usr/bin:/bin").split(os.pathsep):
20
- p = os.path.join(d or ".", name)
21
- if os.path.isfile(p):
22
- sys.executable = p
23
- if not getattr(sys, "_base_executable", ""):
24
- sys._base_executable = p
25
- return
10
+ _slicc_site.fix()
26
11
 
27
12
 
28
13
  def _slicc_chain():
@@ -35,12 +20,18 @@ def _slicc_chain():
35
20
  if spec is None or spec.origin == os.path.abspath(__file__):
36
21
  return
37
22
  module = importlib.util.module_from_spec(spec)
38
- spec.loader.exec_module(module)
23
+ ours = sys.modules.get("sitecustomize")
24
+ sys.modules["sitecustomize"] = module
25
+ try:
26
+ spec.loader.exec_module(module)
27
+ except BaseException:
28
+ if ours is not None:
29
+ sys.modules["sitecustomize"] = ours
30
+ raise
39
31
 
40
32
 
41
- _slicc_executable()
42
33
  try:
43
34
  _slicc_chain()
44
35
  except Exception as exc: # as site.py does for a failing sitecustomize
45
36
  print(f"Error in sitecustomize; set PYTHONVERBOSE for traceback:\n{type(exc).__name__}: {exc}", file=sys.stderr)
46
- del _slicc_executable, _slicc_chain
37
+ del _slicc_chain
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/wasix-python",
3
- "version": "3.14.2-10",
4
- "description": "CPython 3.14 for slicc WASIX (sys.executable set for venvs; packaging-only over 3.14.2-9)",
3
+ "version": "3.14.2-11",
4
+ "description": "CPython 3.14 for slicc WASIX (venvs on slicc-kernel >= 1.29.0; packaging-only over 3.14.2-9)",
5
5
  "license": "PSF-2.0",
6
+ "engines": {
7
+ "slicc-kernel": ">=1.29.0"
8
+ },
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "git+https://github.com/ai-ecoverse/homescoop.git",