@ai-ecoverse/wasix-python 3.14.2-16 → 3.14.2-19

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/bin/python.wasm CHANGED
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/lib/libpython3.14.a
3
- size: 59362746 bytes
4
- sha256: b5320f13b4636974f7dcf92f662e9e9f488a051d092d7bff059ad787522bb0b1
3
+ size: 59362794 bytes
4
+ sha256: 4e66bda99fd67aa10c3914635ddbbd4d0a51d71c4cfe2da72851be8d7849a53b
@@ -24,9 +24,17 @@ resolves to (Node-style lookup from its real directory), if any, has the
24
24
  same exact version as this python: the same version is the same build, so
25
25
  native side modules never mix interpreter builds. The first package of a
26
26
  name wins; others are skipped (reported under -v).
27
- The result is cached in <python>/.slicc-site-cache, keyed on the package
28
- directories and their package.json stamps, plus the stamps of the
29
- wasix-python copies they resolved to; -v always rescans.
27
+ The result is cached per user in ${XDG_CACHE_HOME:-~/.cache}/slicc-site/
28
+ (3.14.2-17; before, <python>/.slicc-site-cache, which other users could not
29
+ write), keyed on the package directories and their package.json stamps, plus
30
+ the stamps of the wasix-python copies they resolved to; -v always rescans.
31
+ Without a home or a writable cache directory there is no cache.
32
+
33
+ system_site() (3.14.2-17): /usr/local/lib/python3.X/site-packages, when it
34
+ exists, goes on sys.path through site.addsitedir (so its .pth files run),
35
+ after python's own site-packages and the py-* directories: one place an
36
+ embedder can put a .pth for every user. Like discover(), it runs from the
37
+ base .pth only, so a venv sees it with --system-site-packages.
30
38
  """
31
39
  import os
32
40
  import sys
@@ -212,8 +220,8 @@ def discover():
212
220
  # slicc's OPFS; directory mtimes are not). A hit costs one stat per
213
221
  # package instead of realpath + read + parse + lookup.
214
222
  key = "\n".join(filter(None, [base, _stamp(real), *map(_stamp, found)]))
215
- cache = os.path.join(real, ".slicc-site-cache")
216
- if not sys.flags.verbose:
223
+ cache = _cache_path(real)
224
+ if cache and not sys.flags.verbose:
217
225
  try:
218
226
  with open(cache, encoding="utf-8") as f:
219
227
  head, _, rest = f.read().partition("\n\n")
@@ -231,15 +239,37 @@ def discover():
231
239
  for d in dirs:
232
240
  if d not in sys.path: # as PYTHONPATH would: .pth files there are not run
233
241
  sys.path.append(d)
242
+ if not cache:
243
+ return
234
244
  try:
245
+ os.makedirs(os.path.dirname(cache), exist_ok=True)
235
246
  tmp = f"{cache}.{os.getpid()}"
236
247
  with open(tmp, "w", encoding="utf-8") as f:
237
248
  f.write(key + "\n\n" + "\n".join(filter(None, map(_stamp, sorted(used)))) + "\n\n" + "\n".join(dirs))
238
249
  os.replace(tmp, cache)
239
- except OSError: # read-only install: no cache, scan every start
250
+ except OSError: # no writable cache directory: scan every start
240
251
  pass
241
252
 
242
253
 
254
+ def _cache_path(real):
255
+ base = os.environ.get("XDG_CACHE_HOME")
256
+ if not base:
257
+ home = os.environ.get("HOME")
258
+ if not home:
259
+ return None
260
+ base = os.path.join(home, ".cache")
261
+ return os.path.join(base, "slicc-site", real.strip("/").replace("/", "%") or "%")
262
+
263
+
264
+ def system_site():
265
+ d = f"/usr/local/lib/python{sys.version_info[0]}.{sys.version_info[1]}/site-packages"
266
+ if d in sys.path or not os.path.isdir(d):
267
+ return
268
+ import site
269
+
270
+ site.addsitedir(d)
271
+
272
+
243
273
  def _scan(real, found):
244
274
  me = _manifest(real)
245
275
  if not me or me.get("name") != _PY_PKG:
@@ -169,7 +169,13 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
169
169
  if verbosity:
170
170
  args += ["-" + "v" * verbosity]
171
171
 
172
- return _run_pip([*args, "pip"], [os.fsdecode(tmp_wheel_path)])
172
+ pip_path = [os.fsdecode(tmp_wheel_path)]
173
+ installed = sysconfig.get_path("purelib", vars={"base": sys.base_prefix, "platbase": sys.base_prefix})
174
+ if (sys.platform == "wasi" and sys.prefix != sys.base_prefix and not root and not user
175
+ and os.path.isdir(os.path.join(installed, f"pip-{_PIP_VERSION}.dist-info"))):
176
+ pip_path = [installed]
177
+ args += ["--ignore-installed"]
178
+ return _run_pip([*args, "pip"], pip_path)
173
179
 
174
180
 
175
181
  def _uninstall_helper(*, verbosity=0):
@@ -1 +1 @@
1
- import _slicc_site; _slicc_site.fix(); _slicc_site.discover()
1
+ import _slicc_site; _slicc_site.fix(); _slicc_site.discover(); _slicc_site.system_site()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/wasix-python",
3
- "version": "3.14.2-16",
3
+ "version": "3.14.2-19",
4
4
  "description": "CPython 3.14 for slicc WASIX (commands python, python3; cross-built in CI on wasix-sysroot)",
5
5
  "license": "PSF-2.0 AND GPL-3.0-or-later",
6
6
  "engines": {
@@ -55,6 +55,32 @@
55
55
  "PYTHONHOME": "./",
56
56
  "PYTHONDONTWRITEBYTECODE": "1"
57
57
  }
58
+ },
59
+ "pip": {
60
+ "wasm": "bin/python.wasm",
61
+ "argv0Path": true,
62
+ "env": {
63
+ "PYTHONHOME": "./",
64
+ "PYTHONDONTWRITEBYTECODE": "1"
65
+ },
66
+ "argv0": "python3",
67
+ "args": [
68
+ "-m",
69
+ "pip"
70
+ ]
71
+ },
72
+ "pip3": {
73
+ "wasm": "bin/python.wasm",
74
+ "argv0Path": true,
75
+ "env": {
76
+ "PYTHONHOME": "./",
77
+ "PYTHONDONTWRITEBYTECODE": "1"
78
+ },
79
+ "argv0": "python3",
80
+ "args": [
81
+ "-m",
82
+ "pip"
83
+ ]
58
84
  }
59
85
  },
60
86
  "python": {