oprunner 0.1.0.dev1__tar.gz → 0.1.0.dev2__tar.gz
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.
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/PKG-INFO +1 -1
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/pyproject.toml +1 -1
- oprunner-0.1.0.dev2/src/oprunner/_pixi.py +104 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/runner.py +31 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/.gitignore +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/LICENSE +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/README.md +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/__init__.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/_adapt.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/_codec.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/_tiling.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/discovery.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/host.py +0 -0
- {oprunner-0.1.0.dev1 → oprunner-0.1.0.dev2}/src/oprunner/worker.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "oprunner"
|
|
7
|
-
version = "0.1.0.
|
|
7
|
+
version = "0.1.0.dev2"
|
|
8
8
|
description = "Run image-processing ops in their own environments, with Appose."
|
|
9
9
|
license = "BSD-2-Clause"
|
|
10
10
|
authors = [{name = "scikit-ops developers"}]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Keep appose's own pixi new enough to build environments.
|
|
2
|
+
|
|
3
|
+
Appose downloads a pixi of its own and builds every environment with it.
|
|
4
|
+
Released appose (0.12.0) pins pixi v0.58.0, and that pixi now fails fresh
|
|
5
|
+
builds with ``io error: unexpected end of file`` while solving: every recipe
|
|
6
|
+
under ``envs/`` that has PyPI packages, which is all of them. Environments
|
|
7
|
+
built earlier keep working, because an up-to-date environment is never
|
|
8
|
+
installed again; a new user cannot build any.
|
|
9
|
+
|
|
10
|
+
Appose's main fixed this upstream (apposed/appose-python#10, pin v0.81.0, and
|
|
11
|
+
then a self-update), but no release carries it yet. Until one does, this
|
|
12
|
+
does the same from here:
|
|
13
|
+
|
|
14
|
+
* Before appose has downloaded pixi, point its download at ``MINIMUM``, so a
|
|
15
|
+
new user gets that version and no other.
|
|
16
|
+
* If appose already has an older pixi, ``pixi self-update`` it once, before
|
|
17
|
+
the first build that needs to install anything.
|
|
18
|
+
|
|
19
|
+
Remove this module once scikit-ops requires an appose release whose pinned
|
|
20
|
+
pixi is at least ``MINIMUM``.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import re
|
|
26
|
+
import subprocess
|
|
27
|
+
from collections.abc import Callable
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
#: The pixi appose's main pins; the version apposed/appose-python#10 tested.
|
|
31
|
+
MINIMUM = "0.81.0"
|
|
32
|
+
|
|
33
|
+
_checked = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse(text: str) -> tuple[int, ...] | None:
|
|
37
|
+
found = re.search(r"(\d+)\.(\d+)\.(\d+)", text or "")
|
|
38
|
+
return tuple(int(part) for part in found.groups()) if found else None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _installed_version(command: Path) -> tuple[int, ...] | None:
|
|
42
|
+
out = subprocess.run(
|
|
43
|
+
[str(command), "--version"],
|
|
44
|
+
capture_output=True,
|
|
45
|
+
text=True,
|
|
46
|
+
timeout=60,
|
|
47
|
+
check=False,
|
|
48
|
+
)
|
|
49
|
+
return _parse(out.stdout)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def ensure_recent_pixi(report: Callable[[str], None] = print) -> None:
|
|
53
|
+
"""Make appose build with a pixi at least ``MINIMUM``. Once per process.
|
|
54
|
+
|
|
55
|
+
Never raises: a failure is reported, and the build goes ahead with
|
|
56
|
+
whatever pixi there is, so this can only ever help.
|
|
57
|
+
"""
|
|
58
|
+
global _checked
|
|
59
|
+
if _checked:
|
|
60
|
+
return
|
|
61
|
+
_checked = True
|
|
62
|
+
try:
|
|
63
|
+
from appose.tool.pixi import Pixi
|
|
64
|
+
except ImportError:
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
minimum = _parse(MINIMUM)
|
|
68
|
+
pinned = _parse(Pixi.PIXI_VERSION)
|
|
69
|
+
if pinned is not None and pinned >= minimum:
|
|
70
|
+
return # an appose that is new enough already
|
|
71
|
+
|
|
72
|
+
# Before appose's first download: fetch MINIMUM instead of its pin.
|
|
73
|
+
Pixi.PIXI_VERSION = f"v{MINIMUM}"
|
|
74
|
+
if Pixi.PIXI_BINARY:
|
|
75
|
+
Pixi.DOWNLOAD_URL = (
|
|
76
|
+
"https://github.com/prefix-dev/pixi/releases/download/"
|
|
77
|
+
f"{Pixi.PIXI_VERSION}/{Pixi.PIXI_BINARY}"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# After it: an older pixi already installed is updated in place.
|
|
81
|
+
try:
|
|
82
|
+
command = Path(Pixi().command)
|
|
83
|
+
if not command.exists():
|
|
84
|
+
return
|
|
85
|
+
installed = _installed_version(command)
|
|
86
|
+
if installed is None or installed >= minimum:
|
|
87
|
+
return
|
|
88
|
+
old = ".".join(map(str, installed))
|
|
89
|
+
report(
|
|
90
|
+
f"Updating appose's pixi from {old} to {MINIMUM} ({command}): "
|
|
91
|
+
f"pixi {old} can no longer build environments"
|
|
92
|
+
)
|
|
93
|
+
subprocess.run(
|
|
94
|
+
[str(command), "self-update", "--version", MINIMUM],
|
|
95
|
+
capture_output=True,
|
|
96
|
+
text=True,
|
|
97
|
+
timeout=600,
|
|
98
|
+
check=True,
|
|
99
|
+
)
|
|
100
|
+
now = _installed_version(command)
|
|
101
|
+
if now is None or now < minimum:
|
|
102
|
+
report(f"pixi still reports {now}; building with it anyway")
|
|
103
|
+
except Exception as e: # noqa: BLE001 - never block a build over this
|
|
104
|
+
report(f"Could not update appose's pixi ({e}); building with it anyway")
|
|
@@ -225,6 +225,16 @@ class Runner:
|
|
|
225
225
|
"""Hear the build tool's standard output, in raw chunks."""
|
|
226
226
|
self._build_output.append(subscriber)
|
|
227
227
|
|
|
228
|
+
def _say(self, message: str) -> None:
|
|
229
|
+
"""One line of the runner's own build news, where build output goes."""
|
|
230
|
+
if not self._build_output:
|
|
231
|
+
print(message, flush=True)
|
|
232
|
+
for subscriber in self._build_output:
|
|
233
|
+
try:
|
|
234
|
+
subscriber(message + "\n")
|
|
235
|
+
except Exception: # noqa: BLE001 - a listener must not stop a build
|
|
236
|
+
pass
|
|
237
|
+
|
|
228
238
|
def subscribe_build_error(self, subscriber: Callable[[str], None]) -> None:
|
|
229
239
|
"""Hear the build tool's standard error, in raw chunks.
|
|
230
240
|
|
|
@@ -384,6 +394,12 @@ class Runner:
|
|
|
384
394
|
if key in self._envs:
|
|
385
395
|
return self._envs[key]
|
|
386
396
|
|
|
397
|
+
if not _is_built(env):
|
|
398
|
+
# About to install: make sure appose's pixi can. See _pixi.
|
|
399
|
+
from ._pixi import ensure_recent_pixi
|
|
400
|
+
|
|
401
|
+
ensure_recent_pixi(self._say)
|
|
402
|
+
|
|
387
403
|
builder = appose.pixi(env.config).name(env.name)
|
|
388
404
|
for progress_subscriber in self._build_progress:
|
|
389
405
|
builder = builder.subscribe_progress(progress_subscriber)
|
|
@@ -850,6 +866,21 @@ class Env:
|
|
|
850
866
|
return Path(appose_envs_dir()) / self.name
|
|
851
867
|
|
|
852
868
|
|
|
869
|
+
def _is_built(env: Env) -> bool:
|
|
870
|
+
"""Whether *env* is built from its current file, so appose installs nothing.
|
|
871
|
+
|
|
872
|
+
The comparison ``Runner.environment_status`` makes, for any ``Env``.
|
|
873
|
+
"""
|
|
874
|
+
import json
|
|
875
|
+
|
|
876
|
+
record = env.folder / "appose.json"
|
|
877
|
+
try:
|
|
878
|
+
built = json.loads(record.read_text()).get("content", "")
|
|
879
|
+
return built.strip() == env.config.read_text().strip()
|
|
880
|
+
except (OSError, ValueError):
|
|
881
|
+
return False
|
|
882
|
+
|
|
883
|
+
|
|
853
884
|
def _package_name(module: str, root: Path) -> str:
|
|
854
885
|
"""Whose environments these are, for naming them: a package's name.
|
|
855
886
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|