chefe 0.0.1__py3-none-any.whl
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.
- chefe/__init__.py +14 -0
- chefe/backends/__init__.py +8 -0
- chefe/backends/cargo.py +49 -0
- chefe/backends/npm.py +32 -0
- chefe/backends/pixi.py +39 -0
- chefe/backends/tool.py +70 -0
- chefe/base.py +21 -0
- chefe/cli.py +37 -0
- chefe/compiled/__init__.py +6 -0
- chefe/compiled/npm.py +26 -0
- chefe/compiled/pixi.py +64 -0
- chefe/manager.py +198 -0
- chefe/manifest/__init__.py +17 -0
- chefe/manifest/document.py +108 -0
- chefe/manifest/schema.py +181 -0
- chefe/state.py +18 -0
- chefe/utils.py +24 -0
- chefe-0.0.1.dist-info/METADATA +112 -0
- chefe-0.0.1.dist-info/RECORD +22 -0
- chefe-0.0.1.dist-info/WHEEL +4 -0
- chefe-0.0.1.dist-info/entry_points.txt +2 -0
- chefe-0.0.1.dist-info/licenses/LICENSE +202 -0
chefe/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
# The package name *is* the project name (the build maps pyproject -> this package),
|
|
4
|
+
# so a rename is a single move of the `src/chefe` folder. Everything naming derives
|
|
5
|
+
# from it; reading pyproject.toml at runtime would be fragile (it isn't in the wheel).
|
|
6
|
+
NAME = __name__
|
|
7
|
+
|
|
8
|
+
# The manifest a user writes, and the env directory generated beside it.
|
|
9
|
+
MANIFEST = f"{NAME}.toml"
|
|
10
|
+
ENV_DIR = f".{NAME}"
|
|
11
|
+
|
|
12
|
+
# Domain constants: the non-conda ecosystems, and the sources pixi resolves itself.
|
|
13
|
+
ECOSYSTEMS = ("pypi", "cargo", "npm", "gem")
|
|
14
|
+
PIXI_RESOLVED = ("conda", "pypi")
|
chefe/backends/cargo.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tomllib
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from ..state import Installed
|
|
7
|
+
from .pixi import Pixi
|
|
8
|
+
from .tool import Tool
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Cargo(Tool):
|
|
12
|
+
"""The cargo backend: crates install into the pixi env prefix, so they share its PATH.
|
|
13
|
+
|
|
14
|
+
cargo lives inside the pixi env, so every command runs through `pixi run cargo`.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, out: Path, pixi: Pixi) -> None:
|
|
18
|
+
self.out = out
|
|
19
|
+
self.pixi = pixi
|
|
20
|
+
|
|
21
|
+
def __call__(self, verb: str, *args: str, **flags: bool | str | None) -> bool:
|
|
22
|
+
return self.pixi("run", "cargo", verb, *args, **flags)
|
|
23
|
+
|
|
24
|
+
def root(self, env: str) -> Path:
|
|
25
|
+
"""The pixi env prefix; crates install here so they share the env's activated PATH."""
|
|
26
|
+
return self.out / ".pixi" / "envs" / env
|
|
27
|
+
|
|
28
|
+
def installed(self, env: str) -> dict[str, Installed]:
|
|
29
|
+
crates = self.root(env) / ".crates.toml"
|
|
30
|
+
try:
|
|
31
|
+
entries = tomllib.loads(crates.read_text()).get("v1", {})
|
|
32
|
+
except FileNotFoundError:
|
|
33
|
+
return {}
|
|
34
|
+
return {
|
|
35
|
+
parts[0]: Installed(version=parts[1], kind="cargo")
|
|
36
|
+
for key in entries
|
|
37
|
+
if (parts := key.split())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def sync(self, env: str, declared: dict[str, str]) -> None:
|
|
41
|
+
"""Make ``env``'s crates match ``declared`` exactly: install missing, uninstall removed."""
|
|
42
|
+
at = str(self.root(env))
|
|
43
|
+
have = self.installed(env)
|
|
44
|
+
for name in have.keys() - declared.keys():
|
|
45
|
+
self("uninstall", "--root", at, name)
|
|
46
|
+
for name, spec in declared.items():
|
|
47
|
+
if name not in have:
|
|
48
|
+
version = () if spec in ("*", "") else ("--version", spec)
|
|
49
|
+
self("install", "--root", at, *version, name)
|
chefe/backends/npm.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from ..state import Installed
|
|
7
|
+
from .tool import Tool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Npm(Tool):
|
|
11
|
+
"""The npm backend, scoped to a workspace's env dir, owning its `package.json`."""
|
|
12
|
+
|
|
13
|
+
name = "npm"
|
|
14
|
+
filename = "package.json"
|
|
15
|
+
|
|
16
|
+
def __init__(self, out: Path) -> None:
|
|
17
|
+
self.out = out
|
|
18
|
+
self.manifest = out / self.filename
|
|
19
|
+
|
|
20
|
+
def scope(self) -> tuple[str, ...]:
|
|
21
|
+
return ("--prefix", str(self.out), "--no-audit", "--no-fund")
|
|
22
|
+
|
|
23
|
+
def available(self) -> bool:
|
|
24
|
+
return self.manifest.exists()
|
|
25
|
+
|
|
26
|
+
def installed(self, env: str) -> dict[str, Installed]:
|
|
27
|
+
manifests = (
|
|
28
|
+
*self.out.glob("node_modules/*/package.json"),
|
|
29
|
+
*self.out.glob("node_modules/@*/*/package.json"),
|
|
30
|
+
)
|
|
31
|
+
found = (json.loads(m.read_text()) for m in manifests)
|
|
32
|
+
return {data["name"]: Installed(version=data["version"], kind="npm") for data in found}
|
chefe/backends/pixi.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from ..state import Installed
|
|
7
|
+
from .tool import Tool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Pixi(Tool):
|
|
11
|
+
"""The pixi backend, pinned to the `pixi.toml` it owns inside a workspace's env dir."""
|
|
12
|
+
|
|
13
|
+
name = "pixi"
|
|
14
|
+
filename = "pixi.toml"
|
|
15
|
+
|
|
16
|
+
def __init__(self, out: Path) -> None:
|
|
17
|
+
self.manifest = out / self.filename
|
|
18
|
+
|
|
19
|
+
def scope(self) -> tuple[str, ...]:
|
|
20
|
+
return ("--manifest-path", str(self.manifest))
|
|
21
|
+
|
|
22
|
+
def installed(self, env: str) -> dict[str, Installed]:
|
|
23
|
+
records = json.loads(self.command["list", *self.scope(), "-e", env, "--json"]())
|
|
24
|
+
return {
|
|
25
|
+
rec["name"]: Installed(
|
|
26
|
+
version=rec["version"], kind=rec["kind"], explicit=rec["is_explicit"]
|
|
27
|
+
)
|
|
28
|
+
for rec in records
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def global_install(self, name: str, specs: list[str]) -> bool:
|
|
32
|
+
"""Install conda ``specs`` into a shared global pixi env named ``name``."""
|
|
33
|
+
argv = ("global", "install", *self.flags(environment=name), *specs)
|
|
34
|
+
return self.foreground(self.command[argv])
|
|
35
|
+
|
|
36
|
+
def exec(self, specs: tuple[str, ...], args: tuple[str, ...]) -> bool:
|
|
37
|
+
"""Run ``args`` in a throwaway env (like uvx), pulling extra ``specs`` as `--spec`."""
|
|
38
|
+
spec_flags = tuple(flag for spec in specs for flag in ("--spec", spec))
|
|
39
|
+
return self.foreground(self.command["exec", *spec_flags, *args])
|
chefe/backends/tool.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from functools import cached_property
|
|
4
|
+
|
|
5
|
+
from plumbum import TF, local
|
|
6
|
+
from plumbum.commands.base import BaseCommand
|
|
7
|
+
|
|
8
|
+
from ..state import Installed
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Tool:
|
|
12
|
+
"""A package-manager backend: call it to run a foreground command, query what's installed.
|
|
13
|
+
|
|
14
|
+
Subclasses set ``name`` and override ``scope`` (args that pin the command to the workspace)
|
|
15
|
+
and ``available`` (a guard). ``installed`` is theirs to implement per ecosystem.
|
|
16
|
+
|
|
17
|
+
plumbum is untyped, so this class is the single seam that touches it: every foreground run
|
|
18
|
+
funnels through ``foreground`` (which hands back a real `bool`), keeping the rest of the
|
|
19
|
+
codebase free of the `Any` that plumbum's `& TF(FG=True)` would otherwise leak.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
name: str = ""
|
|
23
|
+
|
|
24
|
+
@cached_property
|
|
25
|
+
def command(self) -> BaseCommand:
|
|
26
|
+
"""The resolved local command, looked up lazily so importing doesn't require it."""
|
|
27
|
+
return local[self.name]
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def foreground(command: BaseCommand) -> bool:
|
|
31
|
+
"""Run ``command`` attached to the terminal, returning whether it succeeded."""
|
|
32
|
+
return bool(command & TF(FG=True))
|
|
33
|
+
|
|
34
|
+
def scope(self) -> tuple[str, ...]:
|
|
35
|
+
"""Args injected after the verb to pin the command to this workspace (default none)."""
|
|
36
|
+
return ()
|
|
37
|
+
|
|
38
|
+
def available(self) -> bool:
|
|
39
|
+
"""Whether the command should run at all (e.g. npm needs a `package.json`)."""
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def flags(**options: bool | str | None) -> tuple[str, ...]:
|
|
44
|
+
"""Turn keyword options into CLI args (`_`→`-`); drop `False`/`None`/`""`.
|
|
45
|
+
|
|
46
|
+
A `True` becomes a bare `--flag`; any other value becomes `--flag value`.
|
|
47
|
+
"""
|
|
48
|
+
out: list[str] = []
|
|
49
|
+
for key, value in options.items():
|
|
50
|
+
if value is None or value is False or value == "":
|
|
51
|
+
continue
|
|
52
|
+
out.append(f"--{key.replace('_', '-')}")
|
|
53
|
+
if value is not True:
|
|
54
|
+
out.append(str(value))
|
|
55
|
+
return tuple(out)
|
|
56
|
+
|
|
57
|
+
def __call__(self, verb: str, *args: str, **flags: bool | str | None) -> bool:
|
|
58
|
+
"""Run the backend in the foreground, returning success; a no-op if unavailable.
|
|
59
|
+
|
|
60
|
+
Keyword ``flags`` translate to CLI args (`pypi=True` → `--pypi`, `feature=env` →
|
|
61
|
+
`--feature env`), inserted before the positional ``args``.
|
|
62
|
+
"""
|
|
63
|
+
if not self.available():
|
|
64
|
+
return True
|
|
65
|
+
argv = (verb, *self.scope(), *self.flags(**flags), *args)
|
|
66
|
+
return self.foreground(self.command[argv])
|
|
67
|
+
|
|
68
|
+
def installed(self, env: str) -> dict[str, Installed]:
|
|
69
|
+
"""Packages currently provisioned for ``env``: name -> :class:`Installed`."""
|
|
70
|
+
raise NotImplementedError
|
chefe/base.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
|
4
|
+
from typing_extensions import TypeAliasType
|
|
5
|
+
|
|
6
|
+
# A TOML value: scalars or arbitrarily nested arrays/tables, mirroring what tomllib parses.
|
|
7
|
+
# `TypeAliasType` (PEP 695 backport) gives a *named* recursive alias, which both pydantic's
|
|
8
|
+
# schema builder and mypy resolve without the infinite recursion a bare forward-ref triggers.
|
|
9
|
+
Toml = TypeAliasType("Toml", "str | int | float | bool | list[Toml] | dict[str, Toml]")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Model(BaseModel):
|
|
13
|
+
"""Strict, frozen base: only declared fields (unknown keys error), immutable after load."""
|
|
14
|
+
|
|
15
|
+
model_config = ConfigDict(extra="forbid", frozen=True, populate_by_name=True)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FlexModel(BaseModel):
|
|
19
|
+
"""Frozen base for specs that delegate unknown keys to pixi/uv, kept as extras."""
|
|
20
|
+
|
|
21
|
+
model_config = ConfigDict(extra="allow", frozen=True, populate_by_name=True)
|
chefe/cli.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from cyclopts import App
|
|
4
|
+
|
|
5
|
+
from . import NAME
|
|
6
|
+
from .manager import PackageManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def build(manager: PackageManager) -> App:
|
|
10
|
+
"""Wire ``manager``'s commands into a cyclopts app (bound methods register directly)."""
|
|
11
|
+
app = App(name=NAME, help="One manifest, many package managers.")
|
|
12
|
+
glob = App(name="global", help="Install the conda deps into the shared global pixi env.")
|
|
13
|
+
app.command(glob)
|
|
14
|
+
for method in (
|
|
15
|
+
manager.init,
|
|
16
|
+
manager.sync,
|
|
17
|
+
manager.install,
|
|
18
|
+
manager.update,
|
|
19
|
+
manager.clean,
|
|
20
|
+
manager.run,
|
|
21
|
+
manager.x,
|
|
22
|
+
manager.shell,
|
|
23
|
+
manager.tree,
|
|
24
|
+
manager.add,
|
|
25
|
+
manager.upgrade,
|
|
26
|
+
manager.remove,
|
|
27
|
+
):
|
|
28
|
+
app.command(method)
|
|
29
|
+
glob.command(manager.global_install, name="install")
|
|
30
|
+
return app
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
app = build(PackageManager())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
app()
|
chefe/compiled/npm.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from ..base import Model
|
|
4
|
+
from ..manifest import Manifest
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PackageJson(Model):
|
|
8
|
+
"""The compiled `package.json` emitted into the generated env."""
|
|
9
|
+
|
|
10
|
+
name: str
|
|
11
|
+
private: bool = True
|
|
12
|
+
dependencies: dict[str, str] = {}
|
|
13
|
+
|
|
14
|
+
def to_json(self) -> str:
|
|
15
|
+
"""Render to `package.json` text."""
|
|
16
|
+
return self.model_dump_json(indent=2) + "\n"
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def from_manifest(cls, m: Manifest) -> PackageJson | None:
|
|
20
|
+
"""Build package.json from ``[npm.deps]``, or None if there are none."""
|
|
21
|
+
if not m.npm.deps:
|
|
22
|
+
return None
|
|
23
|
+
return cls(
|
|
24
|
+
name=f"{m.workspace.name}-npm",
|
|
25
|
+
dependencies={package: spec.version or "*" for package, spec in m.npm.deps.items()},
|
|
26
|
+
)
|
chefe/compiled/pixi.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tomlkit
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from ..base import Model, Toml
|
|
7
|
+
from ..manifest import Manifest, Spec, Task
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PixiManifest(Model):
|
|
11
|
+
"""The compiled pixi manifest (`pixi.toml`) emitted into the generated env."""
|
|
12
|
+
|
|
13
|
+
workspace: dict[str, Toml]
|
|
14
|
+
system_requirements: dict[str, str] = Field(default_factory=dict, alias="system-requirements")
|
|
15
|
+
activation: dict[str, Toml] = {}
|
|
16
|
+
dependencies: dict[str, Spec] = {}
|
|
17
|
+
pypi_dependencies: dict[str, Spec] = Field(default_factory=dict, alias="pypi-dependencies")
|
|
18
|
+
pypi_options: dict[str, Toml] = Field(default_factory=dict, alias="pypi-options")
|
|
19
|
+
target: dict[str, Toml] = {}
|
|
20
|
+
feature: dict[str, Toml] = {}
|
|
21
|
+
environments: dict[str, Toml] = {}
|
|
22
|
+
tasks: dict[str, Task] = {}
|
|
23
|
+
|
|
24
|
+
def to_toml(self) -> str:
|
|
25
|
+
"""Render to `pixi.toml` text (hyphenated table names via the field aliases)."""
|
|
26
|
+
return tomlkit.dumps(self.model_dump(by_alias=True, exclude_defaults=True))
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def task(spec: Task) -> Task:
|
|
30
|
+
"""Translate a mise-style task into pixi's (`run` -> `cmd`, `depends` -> `depends-on`)."""
|
|
31
|
+
if isinstance(spec, str):
|
|
32
|
+
return spec
|
|
33
|
+
renamed = {"run": "cmd", "depends": "depends-on", "dir": "cwd"}
|
|
34
|
+
return {renamed.get(key, key): value for key, value in spec.items()}
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_manifest(cls, m: Manifest) -> PixiManifest:
|
|
38
|
+
"""Build the pixi manifest from a validated :class:`Manifest`."""
|
|
39
|
+
indexes = m.pypi.indexes
|
|
40
|
+
activation = {k: v for k, v in m.env.items() if not k.startswith("_.")}
|
|
41
|
+
return cls.model_validate(
|
|
42
|
+
{
|
|
43
|
+
"workspace": {
|
|
44
|
+
"name": m.workspace.name,
|
|
45
|
+
"version": m.workspace.version,
|
|
46
|
+
"channels": m.workspace.channels,
|
|
47
|
+
"platforms": m.workspace.platforms,
|
|
48
|
+
},
|
|
49
|
+
"system-requirements": m.system,
|
|
50
|
+
"activation": {"env": activation} if activation else {},
|
|
51
|
+
**m.tables(indexes),
|
|
52
|
+
"pypi-options": m.pypi.options(),
|
|
53
|
+
"target": {plat: scope.tables(indexes) for plat, scope in m.on.items()},
|
|
54
|
+
"feature": {name: env.feature(indexes) for name, env in m.envs.items()},
|
|
55
|
+
"environments": {
|
|
56
|
+
name: {
|
|
57
|
+
"features": [name],
|
|
58
|
+
**({"no-default-feature": True} if env.no_default else {}),
|
|
59
|
+
}
|
|
60
|
+
for name, env in m.envs.items()
|
|
61
|
+
},
|
|
62
|
+
"tasks": {name: cls.task(spec) for name, spec in m.tasks.items()},
|
|
63
|
+
}
|
|
64
|
+
)
|
chefe/manager.py
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from collections import Counter
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import tomlkit
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.markup import escape
|
|
10
|
+
from rich.table import Table
|
|
11
|
+
|
|
12
|
+
from . import ECOSYSTEMS, ENV_DIR, MANIFEST, NAME, PIXI_RESOLVED
|
|
13
|
+
from .backends import Cargo, Npm, Pixi
|
|
14
|
+
from .compiled import PackageJson, PixiManifest
|
|
15
|
+
from .manifest import Document, Manifest
|
|
16
|
+
from .state import Declared
|
|
17
|
+
from .utils import current_platform, satisfied
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PackageManager:
|
|
21
|
+
"""A workspace: one manifest, compiled into a generated env and run by the real tools."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, root: Path = Path()) -> None:
|
|
24
|
+
self.manifest = root / MANIFEST
|
|
25
|
+
self.out = root / ENV_DIR
|
|
26
|
+
self.pixi = Pixi(self.out)
|
|
27
|
+
self.npm = Npm(self.out)
|
|
28
|
+
self.cargo = Cargo(self.out, self.pixi)
|
|
29
|
+
self.console = Console()
|
|
30
|
+
|
|
31
|
+
def load(self) -> Manifest:
|
|
32
|
+
"""The validated manifest."""
|
|
33
|
+
return Manifest.load(self.manifest)
|
|
34
|
+
|
|
35
|
+
def declared(self, env: str) -> dict[str, Declared]:
|
|
36
|
+
"""Every dep declared for ``env`` on this host."""
|
|
37
|
+
return self.load().declared(env, current_platform())
|
|
38
|
+
|
|
39
|
+
def init(self, name: str = "") -> None:
|
|
40
|
+
"""Scaffold a starter manifest."""
|
|
41
|
+
if self.manifest.exists():
|
|
42
|
+
self.console.print(f"[yellow]{self.manifest.name} already exists[/yellow], untouched")
|
|
43
|
+
return
|
|
44
|
+
name = name or Path.cwd().name
|
|
45
|
+
self.manifest.write_text(
|
|
46
|
+
f'[workspace]\nname = "{name}"\nversion = "0.1.0"\n'
|
|
47
|
+
f'platforms = ["{current_platform()}"]\n'
|
|
48
|
+
'channels = ["conda-forge"]\n\n[deps]\npython = ">=3.11"\n'
|
|
49
|
+
)
|
|
50
|
+
self.console.print(
|
|
51
|
+
f"[green]created[/green] {self.manifest.name} for [bold]{escape(name)}[/bold]"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def sync(self) -> None:
|
|
55
|
+
"""Compile the manifest into the generated `{pixi.toml, package.json}`."""
|
|
56
|
+
manifest = self.load()
|
|
57
|
+
self.out.mkdir(exist_ok=True)
|
|
58
|
+
self.pixi.manifest.write_text(PixiManifest.from_manifest(manifest).to_toml())
|
|
59
|
+
if (package := PackageJson.from_manifest(manifest)) is not None:
|
|
60
|
+
self.npm.manifest.write_text(package.to_json())
|
|
61
|
+
self.console.print(f"[green]synced[/green] {self.manifest.name} → {self.out.name}/")
|
|
62
|
+
|
|
63
|
+
def install(self, env: str = "default") -> None:
|
|
64
|
+
"""Sync, then make ``env`` match the manifest across every ecosystem."""
|
|
65
|
+
self.sync()
|
|
66
|
+
self.pixi("install", "-e", env)
|
|
67
|
+
self.npm("install")
|
|
68
|
+
crates = {n: d.spec for n, d in self.declared(env).items() if d.source == "cargo"}
|
|
69
|
+
self.cargo.sync(env, crates)
|
|
70
|
+
self.console.print(f"[green]installed[/green] env [bold]{escape(env)}[/bold]")
|
|
71
|
+
|
|
72
|
+
def update(self, env: str = "default") -> None:
|
|
73
|
+
"""Re-solve to the newest allowed versions across ecosystems."""
|
|
74
|
+
self.sync()
|
|
75
|
+
self.pixi("update", "-e", env)
|
|
76
|
+
self.npm("update")
|
|
77
|
+
self.console.print(f"[green]updated[/green] env [bold]{escape(env)}[/bold]")
|
|
78
|
+
|
|
79
|
+
def clean(self) -> None:
|
|
80
|
+
"""Remove the generated env and manifests."""
|
|
81
|
+
shutil.rmtree(self.out, ignore_errors=True)
|
|
82
|
+
self.console.print(f"[green]removed[/green] {self.out.name}/")
|
|
83
|
+
|
|
84
|
+
def global_install(self, name: str = "") -> None:
|
|
85
|
+
"""Install the conda `[deps]` into a shared global pixi env."""
|
|
86
|
+
manifest = self.load()
|
|
87
|
+
name = name or manifest.workspace.name
|
|
88
|
+
specs = [
|
|
89
|
+
pkg if dep.version in (None, "*") else f"{pkg}{dep.version}"
|
|
90
|
+
for pkg, dep in manifest.deps.items()
|
|
91
|
+
]
|
|
92
|
+
self.pixi.global_install(name, specs)
|
|
93
|
+
self.console.print(
|
|
94
|
+
f"[green]installed[/green] {len(specs)} deps into [bold]{escape(name)}[/bold]"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def run(self, task: str, *args: str) -> None:
|
|
98
|
+
"""Run a task inside the env."""
|
|
99
|
+
self.pixi("run", task, *args)
|
|
100
|
+
|
|
101
|
+
def x(self, *args: str, with_: tuple[str, ...] = ()) -> None:
|
|
102
|
+
"""Run a command in a throwaway env, like uvx or pipx run; no manifest needed.
|
|
103
|
+
|
|
104
|
+
args: the command and its arguments, e.g. `chefe x ruff check .`.
|
|
105
|
+
with_: extra packages to make available, e.g. `--with build`.
|
|
106
|
+
"""
|
|
107
|
+
self.pixi.exec(with_, args)
|
|
108
|
+
|
|
109
|
+
def shell(self, env: str = "default") -> None:
|
|
110
|
+
"""Open an activated shell in ``env``."""
|
|
111
|
+
self.pixi("shell", "-e", env)
|
|
112
|
+
|
|
113
|
+
def add(
|
|
114
|
+
self,
|
|
115
|
+
*packages: str,
|
|
116
|
+
pypi: bool = False,
|
|
117
|
+
cargo: bool = False,
|
|
118
|
+
npm: bool = False,
|
|
119
|
+
gem: bool = False,
|
|
120
|
+
env: str = "",
|
|
121
|
+
spec: str = "*",
|
|
122
|
+
) -> None:
|
|
123
|
+
"""Add packages to the manifest, then sync; conda + pypi resolve through pixi.
|
|
124
|
+
|
|
125
|
+
Conda is the default source; `--pypi`/`--cargo`/`--npm`/`--gem` pick another.
|
|
126
|
+
"""
|
|
127
|
+
source = next(
|
|
128
|
+
(s for s, on in zip(ECOSYSTEMS, (pypi, cargo, npm, gem), strict=True) if on), "conda"
|
|
129
|
+
)
|
|
130
|
+
if source in PIXI_RESOLVED:
|
|
131
|
+
self.sync()
|
|
132
|
+
self.pixi("add", *packages, pypi=source == "pypi", feature=env)
|
|
133
|
+
self.pull()
|
|
134
|
+
else:
|
|
135
|
+
document = Document(self.manifest)
|
|
136
|
+
document.add(source, env, packages, spec)
|
|
137
|
+
document.save()
|
|
138
|
+
self.sync()
|
|
139
|
+
self.console.print(f"[green]added[/green] {escape(', '.join(packages))}")
|
|
140
|
+
|
|
141
|
+
def upgrade(self, *packages: str, env: str = "") -> None:
|
|
142
|
+
"""Bump conda + pypi constraints to the latest allowed, then sync in."""
|
|
143
|
+
self.sync()
|
|
144
|
+
self.pixi("upgrade", *packages, feature=env)
|
|
145
|
+
self.pull()
|
|
146
|
+
self.console.print(
|
|
147
|
+
f"[green]upgraded[/green] {escape(', '.join(packages) or 'all conda + pypi deps')}"
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def remove(self, *packages: str) -> None:
|
|
151
|
+
"""Remove packages from the manifest wherever declared, then re-sync."""
|
|
152
|
+
document = Document(self.manifest)
|
|
153
|
+
removed = document.remove(packages)
|
|
154
|
+
document.save()
|
|
155
|
+
gone = ", ".join(dict.fromkeys(removed)) or "(nothing found)"
|
|
156
|
+
self.console.print(f"[green]removed[/green] {escape(gone)}")
|
|
157
|
+
self.sync()
|
|
158
|
+
|
|
159
|
+
def pull(self) -> None:
|
|
160
|
+
"""Mirror pixi's resolved deps back into the manifest."""
|
|
161
|
+
document = Document(self.manifest)
|
|
162
|
+
document.pull(tomlkit.parse(self.pixi.manifest.read_text()).unwrap())
|
|
163
|
+
document.save()
|
|
164
|
+
|
|
165
|
+
@staticmethod
|
|
166
|
+
def row_status(spec: str, version: str | None) -> tuple[str, str, str]:
|
|
167
|
+
"""The (mark, shown version, tally bucket) for a declared dep vs what's installed."""
|
|
168
|
+
if version is None:
|
|
169
|
+
return "[red]✗ missing[/red]", "[dim]·[/dim]", "missing"
|
|
170
|
+
if satisfied(spec, version):
|
|
171
|
+
return "[green]✓[/green]", version, "ok"
|
|
172
|
+
return "[yellow]≠ drift[/yellow]", f"[yellow]{version}[/yellow]", "drift"
|
|
173
|
+
|
|
174
|
+
def tree(self, env: str = "default") -> None:
|
|
175
|
+
"""Show declared vs installed deps, each checked in its own ecosystem."""
|
|
176
|
+
declared = self.declared(env)
|
|
177
|
+
provisioned = self.pixi.installed(env)
|
|
178
|
+
by_source: dict[str, dict[str, str]] = {
|
|
179
|
+
"npm": {name: inst.version for name, inst in self.npm.installed(env).items()},
|
|
180
|
+
"cargo": {name: inst.version for name, inst in self.cargo.installed(env).items()},
|
|
181
|
+
}
|
|
182
|
+
for name, inst in provisioned.items():
|
|
183
|
+
by_source.setdefault(inst.kind, {})[name] = inst.version
|
|
184
|
+
table = Table(title=f"{NAME} · {env} · declared vs installed", header_style="bold cyan")
|
|
185
|
+
for column in ("package", "source", "declared", "installed", ""):
|
|
186
|
+
table.add_column(column)
|
|
187
|
+
tally: Counter[str] = Counter()
|
|
188
|
+
for name, dep in sorted(declared.items()):
|
|
189
|
+
installed = by_source.get(dep.source, {}).get(name)
|
|
190
|
+
mark, shown, bucket = self.row_status(dep.spec, installed)
|
|
191
|
+
tally[bucket] += 1
|
|
192
|
+
table.add_row(name, dep.source, dep.spec, shown, mark)
|
|
193
|
+
self.console.print(table)
|
|
194
|
+
transitive = sum(1 for inst in provisioned.values() if not inst.explicit)
|
|
195
|
+
self.console.print(
|
|
196
|
+
f"[green]{tally['ok']} ok[/green] · [yellow]{tally['drift']} drift[/yellow] · "
|
|
197
|
+
f"[red]{tally['missing']} missing[/red] · [dim]{transitive} transitive installed[/dim]"
|
|
198
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .document import Document
|
|
4
|
+
from .schema import Env, Header, Manifest, PyPI, Registry, Runtime, Scope, Spec, Task
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"Document",
|
|
8
|
+
"Env",
|
|
9
|
+
"Header",
|
|
10
|
+
"Manifest",
|
|
11
|
+
"PyPI",
|
|
12
|
+
"Registry",
|
|
13
|
+
"Runtime",
|
|
14
|
+
"Scope",
|
|
15
|
+
"Spec",
|
|
16
|
+
"Task",
|
|
17
|
+
]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
import tomlkit
|
|
8
|
+
from tomlkit import TOMLDocument
|
|
9
|
+
from tomlkit.items import InlineTable, Table
|
|
10
|
+
|
|
11
|
+
from .. import ECOSYSTEMS
|
|
12
|
+
from ..base import Toml
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Document:
|
|
16
|
+
"""Editable tomlkit view of the manifest (comments kept); the write twin of `Manifest`."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, path: Path) -> None:
|
|
19
|
+
self.path = path
|
|
20
|
+
self.doc: TOMLDocument = tomlkit.parse(path.read_text())
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def dep_path(source: str, env: str) -> list[str]:
|
|
24
|
+
"""The deps table path for ``source`` (conda = bare `[deps]`), nested under ``env``."""
|
|
25
|
+
base = ["deps"] if source == "conda" else [source, "deps"]
|
|
26
|
+
return ["envs", env, *base] if env else base
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def normalize(name: str) -> str:
|
|
30
|
+
"""Canonical package key for matching (case- and `_`/`-`-insensitive)."""
|
|
31
|
+
return name.lower().replace("_", "-")
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def dig(data: Mapping[str, Toml], *keys: str) -> Mapping[str, Toml]:
|
|
35
|
+
"""Walk ``keys`` into a nested table, returning the leaf mapping (or empty)."""
|
|
36
|
+
node: Toml | Mapping[str, Toml] = data
|
|
37
|
+
for key in keys:
|
|
38
|
+
node = node.get(key, {}) if isinstance(node, Mapping) else {}
|
|
39
|
+
return node if isinstance(node, Mapping) else {}
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def dep_in(scope: Toml, ecosystem: str) -> bool:
|
|
43
|
+
"""Whether ``scope`` has a `[<ecosystem>.deps]` table (e.g. `[pypi.deps]`)."""
|
|
44
|
+
return (
|
|
45
|
+
isinstance(scope, Mapping)
|
|
46
|
+
and ecosystem in scope
|
|
47
|
+
and isinstance(eco := scope[ecosystem], Mapping)
|
|
48
|
+
and "deps" in eco
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def save(self) -> None:
|
|
52
|
+
"""Write the document back to disk."""
|
|
53
|
+
self.path.write_text(tomlkit.dumps(self.doc))
|
|
54
|
+
|
|
55
|
+
def table(self, path: list[str]) -> Table:
|
|
56
|
+
"""The table at ``path``, creating intermediate tables as needed."""
|
|
57
|
+
node: Table | TOMLDocument = self.doc
|
|
58
|
+
for key in path:
|
|
59
|
+
if key not in node:
|
|
60
|
+
node[key] = tomlkit.table()
|
|
61
|
+
node = cast(Table, node[key])
|
|
62
|
+
return cast(Table, node)
|
|
63
|
+
|
|
64
|
+
def add(self, source: str, env: str, packages: tuple[str, ...], spec: str) -> None:
|
|
65
|
+
"""Write ``packages`` at ``spec`` into the ``source`` dep table."""
|
|
66
|
+
table = self.table(self.dep_path(source, env))
|
|
67
|
+
for package in packages:
|
|
68
|
+
table[package] = spec
|
|
69
|
+
|
|
70
|
+
def remove(self, packages: tuple[str, ...]) -> list[str]:
|
|
71
|
+
"""Drop ``packages`` from every dep table; return the names actually removed."""
|
|
72
|
+
tables: list[Table] = []
|
|
73
|
+
for scope in (self.doc, *self.doc.get("envs", {}).values()):
|
|
74
|
+
if "deps" in scope:
|
|
75
|
+
tables.append(cast(Table, scope["deps"]))
|
|
76
|
+
tables += [cast(Table, scope[e]["deps"]) for e in ECOSYSTEMS if self.dep_in(scope, e)]
|
|
77
|
+
return [p for t in tables for p in packages if t.pop(p, None) is not None]
|
|
78
|
+
|
|
79
|
+
def pull(self, pixi_doc: Mapping[str, Toml]) -> None:
|
|
80
|
+
"""Fold pixi's resolved conda + pypi deps from a `pixi.toml` dict back into the manifest.
|
|
81
|
+
|
|
82
|
+
Walks the base scope, each env (feature) and each platform (target), bumping declared
|
|
83
|
+
versions and adding what pixi added, while keeping comments and index aliases intact.
|
|
84
|
+
"""
|
|
85
|
+
scopes: list[tuple[tuple[str, ...], list[str]]] = [((), [])]
|
|
86
|
+
scopes += [(("feature", n), ["envs", n]) for n in self.dig(pixi_doc, "feature")]
|
|
87
|
+
scopes += [(("target", p), ["on", p]) for p in self.dig(pixi_doc, "target")]
|
|
88
|
+
for at, dest in scopes:
|
|
89
|
+
for source, sub in (
|
|
90
|
+
("dependencies", ["deps"]),
|
|
91
|
+
("pypi-dependencies", ["pypi", "deps"]),
|
|
92
|
+
):
|
|
93
|
+
resolved = self.dig(pixi_doc, *at, source)
|
|
94
|
+
if resolved:
|
|
95
|
+
self.merge(self.table([*dest, *sub]), resolved)
|
|
96
|
+
|
|
97
|
+
def merge(self, table: Table, resolved: Mapping[str, Toml]) -> None:
|
|
98
|
+
"""Bump versions of deps already in ``table`` (keeping index/source); add what's new."""
|
|
99
|
+
declared = {self.normalize(name): name for name in table}
|
|
100
|
+
for name, spec in resolved.items():
|
|
101
|
+
version = spec["version"] if isinstance(spec, Mapping) else spec
|
|
102
|
+
key = declared.get(self.normalize(name))
|
|
103
|
+
if key is None:
|
|
104
|
+
table[name] = spec
|
|
105
|
+
elif isinstance(table[key], str):
|
|
106
|
+
table[key] = version
|
|
107
|
+
else:
|
|
108
|
+
cast(InlineTable, table[key])["version"] = version
|
chefe/manifest/schema.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tomllib
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from pydantic import ConfigDict, Field, model_serializer, model_validator
|
|
8
|
+
|
|
9
|
+
from ..base import FlexModel, Model, Toml
|
|
10
|
+
from ..state import Declared
|
|
11
|
+
|
|
12
|
+
# A pixi/mise task: a bare command string, or a table (run/cmd, depends, cwd, ...).
|
|
13
|
+
Task = str | dict[str, Toml]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Spec(FlexModel):
|
|
17
|
+
"""A dependency spec: a bare version string, or an inline table carrying a source.
|
|
18
|
+
|
|
19
|
+
`version` and `index` are the keys we read (index resolves against `[pypi.indexes]`); any
|
|
20
|
+
other source key (git / url / path / branch / build / channel / ...) rides through as a
|
|
21
|
+
`FlexModel` extra to pixi/uv, which own their validation. Both forms render back to the
|
|
22
|
+
simplest shape, so the manifest reads exactly as written.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
version: str | None = None
|
|
26
|
+
index: str | None = None
|
|
27
|
+
|
|
28
|
+
@model_validator(mode="before")
|
|
29
|
+
@classmethod
|
|
30
|
+
def from_string(cls, data: Toml) -> Toml:
|
|
31
|
+
"""Accept a bare `"x"` spec as `{version: "x"}`."""
|
|
32
|
+
return {"version": data} if isinstance(data, str) else data
|
|
33
|
+
|
|
34
|
+
@model_serializer
|
|
35
|
+
def to_toml(self) -> str | dict[str, Toml]:
|
|
36
|
+
"""Render to a string when it is only a version, else to an inline table."""
|
|
37
|
+
extra = self.model_extra or {}
|
|
38
|
+
if self.index is None and not extra:
|
|
39
|
+
return self.version or "*"
|
|
40
|
+
named = {
|
|
41
|
+
key: value
|
|
42
|
+
for key, value in (("version", self.version), ("index", self.index))
|
|
43
|
+
if value
|
|
44
|
+
}
|
|
45
|
+
return {**named, **extra}
|
|
46
|
+
|
|
47
|
+
def with_index(self, indexes: dict[str, str]) -> Spec:
|
|
48
|
+
"""This spec with a named `index` swapped for its URL from `[pypi.indexes]`."""
|
|
49
|
+
if self.index in indexes:
|
|
50
|
+
return self.model_copy(update={"index": indexes[self.index]})
|
|
51
|
+
return self
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Registry(Model):
|
|
55
|
+
"""A non-default registry's packages (pypi / cargo / npm / gem): one ``deps`` map."""
|
|
56
|
+
|
|
57
|
+
deps: dict[str, Spec] = {}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class PyPI(Registry):
|
|
61
|
+
"""PyPI packages + named indexes; other keys (index-strategy, extra-index-urls)
|
|
62
|
+
ride through as extras into pixi's ``[pypi-options]``."""
|
|
63
|
+
|
|
64
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
65
|
+
|
|
66
|
+
indexes: dict[str, str] = {}
|
|
67
|
+
|
|
68
|
+
def options(self) -> dict[str, Toml]:
|
|
69
|
+
"""The extra (non-dep, non-index) settings → pixi ``[pypi-options]``."""
|
|
70
|
+
return {key: value for key, value in (self.model_extra or {}).items()}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Runtime(StrEnum):
|
|
74
|
+
"""The conda-forge language runtime each non-conda ecosystem needs to install and run.
|
|
75
|
+
|
|
76
|
+
The member name is the ecosystem, its value the package we ensure in `[deps]` so a
|
|
77
|
+
`[pypi.deps]` without an explicit `python` still works, the same for node/rust/ruby.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
pypi = "python"
|
|
81
|
+
npm = "nodejs"
|
|
82
|
+
cargo = "rust"
|
|
83
|
+
gem = "ruby"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Scope(Model):
|
|
87
|
+
"""A set of per-registry deps, shared by the base manifest, each platform overlay,
|
|
88
|
+
and each environment. `deps` is conda, the default source."""
|
|
89
|
+
|
|
90
|
+
deps: dict[str, Spec] = {}
|
|
91
|
+
pypi: PyPI = PyPI()
|
|
92
|
+
cargo: Registry = Registry()
|
|
93
|
+
npm: Registry = Registry()
|
|
94
|
+
gem: Registry = Registry()
|
|
95
|
+
|
|
96
|
+
def registries(self) -> dict[str, Registry]:
|
|
97
|
+
"""The non-conda registries by source name, discovered from the model's own fields."""
|
|
98
|
+
return {name: value for name, value in self if isinstance(value, Registry)}
|
|
99
|
+
|
|
100
|
+
def groups(self) -> dict[str, dict[str, Spec]]:
|
|
101
|
+
"""Every dep group by source name: conda plus each ecosystem registry."""
|
|
102
|
+
return {"conda": self.deps, **{name: reg.deps for name, reg in self.registries().items()}}
|
|
103
|
+
|
|
104
|
+
def tables(self, indexes: dict[str, str]) -> dict[str, Toml]:
|
|
105
|
+
"""This scope as pixi tables: conda `deps` (runtimes ensured) plus pypi.
|
|
106
|
+
|
|
107
|
+
Each spec renders to its TOML form (a version string or an inline table), so the
|
|
108
|
+
result is a plain nested `Toml` that pixi validates back into `Spec` on its own fields.
|
|
109
|
+
"""
|
|
110
|
+
deps = dict(self.deps)
|
|
111
|
+
for name, registry in self.registries().items():
|
|
112
|
+
if registry.deps:
|
|
113
|
+
deps.setdefault(Runtime[name].value, Spec(version="*"))
|
|
114
|
+
out: dict[str, Toml] = {}
|
|
115
|
+
if deps:
|
|
116
|
+
out["dependencies"] = {name: spec.to_toml() for name, spec in deps.items()}
|
|
117
|
+
if self.pypi.deps:
|
|
118
|
+
out["pypi-dependencies"] = {
|
|
119
|
+
name: spec.with_index(indexes).to_toml() for name, spec in self.pypi.deps.items()
|
|
120
|
+
}
|
|
121
|
+
return out
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class Env(Scope):
|
|
125
|
+
"""A named environment (→ pixi feature + environment); may carry its own overlays."""
|
|
126
|
+
|
|
127
|
+
on: dict[str, Scope] = {}
|
|
128
|
+
no_default: bool = Field(default=False, alias="no-default")
|
|
129
|
+
|
|
130
|
+
def feature(self, indexes: dict[str, str]) -> dict[str, Toml]:
|
|
131
|
+
"""This env as a pixi feature: its registries + any nested platform overlays."""
|
|
132
|
+
body: dict[str, Toml] = {}
|
|
133
|
+
body.update(self.tables(indexes))
|
|
134
|
+
target: dict[str, Toml] = {}
|
|
135
|
+
for plat, scope in self.on.items():
|
|
136
|
+
if tables := scope.tables(indexes):
|
|
137
|
+
target[plat] = tables
|
|
138
|
+
if target:
|
|
139
|
+
body["target"] = target
|
|
140
|
+
return body
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class Header(Model):
|
|
144
|
+
"""The ``[workspace]`` table: identity + solve surface."""
|
|
145
|
+
|
|
146
|
+
name: str
|
|
147
|
+
version: str = "0.1.0"
|
|
148
|
+
platforms: list[str] = []
|
|
149
|
+
channels: list[str] = ["conda-forge"]
|
|
150
|
+
dotenv: bool = True
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class Manifest(Scope):
|
|
154
|
+
"""The whole manifest: a :class:`Scope` plus identity, conditions, env, tasks."""
|
|
155
|
+
|
|
156
|
+
workspace: Header
|
|
157
|
+
system: dict[str, str] = {} # [system] → pixi [system-requirements]
|
|
158
|
+
on: dict[str, Scope] = {} # [on.<platform>] → pixi [target.*]
|
|
159
|
+
envs: dict[str, Env] = {} # [envs.<name>] → pixi [feature]+[environments]
|
|
160
|
+
env: dict[str, str] = {} # env vars
|
|
161
|
+
tasks: dict[str, Task] = {}
|
|
162
|
+
|
|
163
|
+
@classmethod
|
|
164
|
+
def load(cls, path: Path) -> Manifest:
|
|
165
|
+
"""Read and validate the manifest file into a typed manifest."""
|
|
166
|
+
return cls.model_validate(tomllib.loads(path.read_text()))
|
|
167
|
+
|
|
168
|
+
def declared(self, env: str, platform: str) -> dict[str, Declared]:
|
|
169
|
+
"""Every dep declared for ``env`` on ``platform``: name -> Declared(source, spec)."""
|
|
170
|
+
scopes: list[Scope] = [
|
|
171
|
+
self,
|
|
172
|
+
*(s for plat, s in self.on.items() if platform.startswith(plat)),
|
|
173
|
+
]
|
|
174
|
+
if env != "default" and env in self.envs:
|
|
175
|
+
scopes.append(self.envs[env])
|
|
176
|
+
return {
|
|
177
|
+
name: Declared(source=source, spec=spec.version or "*")
|
|
178
|
+
for scope in scopes
|
|
179
|
+
for source, deps in scope.groups().items()
|
|
180
|
+
for name, spec in deps.items()
|
|
181
|
+
}
|
chefe/state.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .base import Model
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Installed(Model):
|
|
7
|
+
"""A package found provisioned in an environment (keyed by name elsewhere)."""
|
|
8
|
+
|
|
9
|
+
version: str
|
|
10
|
+
kind: str # conda | pypi | npm | cargo
|
|
11
|
+
explicit: bool = True
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Declared(Model):
|
|
15
|
+
"""A dependency as written in the manifest (keyed by name elsewhere)."""
|
|
16
|
+
|
|
17
|
+
source: str # conda | pypi | cargo | npm | gem
|
|
18
|
+
spec: str # version constraint, for display
|
chefe/utils.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import platform
|
|
4
|
+
|
|
5
|
+
from packaging.specifiers import InvalidSpecifier, SpecifierSet
|
|
6
|
+
from packaging.version import InvalidVersion, Version
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def current_platform() -> str:
|
|
10
|
+
"""This host's pixi platform, e.g. `osx-arm64` / `linux-64` / `linux-aarch64`."""
|
|
11
|
+
osname = {"Darwin": "osx", "Linux": "linux", "Windows": "win"}[platform.system()]
|
|
12
|
+
arm = platform.machine() in ("arm64", "aarch64")
|
|
13
|
+
arch = "aarch64" if arm and osname == "linux" else "arm64" if arm else "64"
|
|
14
|
+
return f"{osname}-{arch}"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def satisfied(spec: str, version: str) -> bool:
|
|
18
|
+
"""Whether `version` meets `spec` (display-only; pixi is the real gate)."""
|
|
19
|
+
if spec in ("*", ""):
|
|
20
|
+
return True
|
|
21
|
+
try:
|
|
22
|
+
return Version(version) in SpecifierSet(spec)
|
|
23
|
+
except (InvalidVersion, InvalidSpecifier):
|
|
24
|
+
return True
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chefe
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: One manifest for every package manager | conda, PyPI, npm, cargo & more, behind a single file.
|
|
5
|
+
Project-URL: Homepage, https://github.com/phvv-me/chefe
|
|
6
|
+
Project-URL: Repository, https://github.com/phvv-me/chefe
|
|
7
|
+
Project-URL: Issues, https://github.com/phvv-me/chefe/issues
|
|
8
|
+
Author-email: Pedro Valois <contact@phvv.me>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: cargo,conda,monorepo,npm,package-manager,pixi,polyglot,pypi
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
+
Classifier: Topic :: System :: Software Distribution
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: cyclopts>=4
|
|
23
|
+
Requires-Dist: packaging>=24
|
|
24
|
+
Requires-Dist: plumbum>=1.8
|
|
25
|
+
Requires-Dist: pydantic>=2.7
|
|
26
|
+
Requires-Dist: rich>=13
|
|
27
|
+
Requires-Dist: tomlkit>=0.13
|
|
28
|
+
Requires-Dist: typing-extensions>=4.6
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: dirty-equals>=0.8; extra == 'dev'
|
|
31
|
+
Requires-Dist: faker>=30; extra == 'dev'
|
|
32
|
+
Requires-Dist: hypothesis>=6.100; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
34
|
+
Requires-Dist: pyrefly>=1; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-mock>=3.14; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-subprocess>=1.5; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
39
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
40
|
+
Requires-Dist: syrupy>=4; extra == 'dev'
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: mkdocs-llmstxt>=0.2; extra == 'docs'
|
|
43
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
<div align="center">
|
|
47
|
+
|
|
48
|
+
<img src="docs/assets/logo.svg" width="148" alt="chefe logo, a domed serving cloche" />
|
|
49
|
+
|
|
50
|
+
# chefe
|
|
51
|
+
|
|
52
|
+
**One manifest for every package manager.** 🧑🍳
|
|
53
|
+
|
|
54
|
+
[](https://github.com/phvv-me/chefe/actions/workflows/ci.yml)
|
|
55
|
+
[](https://pypi.org/project/chefe/)
|
|
56
|
+
[](https://phvv.me/chefe)
|
|
57
|
+
[](LICENSE)
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
> [!WARNING]
|
|
62
|
+
> **chefe is early (`0.0.x`).** The manifest and commands may still change.
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
curl -fsSL https://phvv.me/chefe/install.sh | sh
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This installs [pixi](https://pixi.sh) (the engine chefe compiles to) and chefe itself. Prefer the raw package? Use `pip install chefe` or `uv tool install chefe`.
|
|
71
|
+
|
|
72
|
+
## What it is
|
|
73
|
+
|
|
74
|
+
Conda, PyPI, npm, cargo. Real projects need several at once, scattered across `pixi.toml`, `package.json`, and `Cargo.toml`. chefe is the head chef. You write **one `chefe.toml`** recipe, chefe runs the line (pixi, npm, cargo) and plates a single environment. It never re-implements a solver. It runs the cooks.
|
|
75
|
+
|
|
76
|
+
```toml
|
|
77
|
+
[workspace]
|
|
78
|
+
name = "my-project"
|
|
79
|
+
channels = ["conda-forge"]
|
|
80
|
+
|
|
81
|
+
[deps] # bare table is conda, the default source
|
|
82
|
+
python = ">=3.11"
|
|
83
|
+
ripgrep = "*"
|
|
84
|
+
|
|
85
|
+
[pypi.deps] # resolved by pixi-via-uv, in the same env
|
|
86
|
+
torch = ">=2.6"
|
|
87
|
+
|
|
88
|
+
[cargo.deps] # other ecosystems are explicit via [<eco>.deps]
|
|
89
|
+
bookokrat = "*"
|
|
90
|
+
|
|
91
|
+
[npm.deps]
|
|
92
|
+
prettier = ">=3"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
chefe init # scaffold a chefe.toml
|
|
99
|
+
chefe add ripgrep # add deps, use --pypi / --cargo / --npm for others
|
|
100
|
+
chefe install # provision every ecosystem at once
|
|
101
|
+
chefe tree # what's declared vs installed, per ecosystem
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> [!TIP]
|
|
105
|
+
> Run `chefe tree` anytime to see declared vs installed across every ecosystem at a glance. ✅
|
|
106
|
+
|
|
107
|
+
> [!NOTE]
|
|
108
|
+
> Full documentation lives at **[phvv.me/chefe](https://phvv.me/chefe)**.
|
|
109
|
+
|
|
110
|
+
## Lore
|
|
111
|
+
|
|
112
|
+
A head chef never cooks every dish alone. They write the recipe and run the line, and the cooks each work their station. chefe does the same for your dependencies. One recipe in, one plated environment out, with pixi, npm, and cargo working the stations. 🧑🍳
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
chefe/__init__.py,sha256=Cr3reKib2f7P8BwG_b3T5QyhT8e0kAIpLpuAgysSXjs,593
|
|
2
|
+
chefe/base.py,sha256=H3R5OayHvI24P0tjsQecMXwLSzrPrvskX5clmEwQFeE,894
|
|
3
|
+
chefe/cli.py,sha256=d7vw4-p01FoapZ7pIvv8QBpTpmXsyD5qs0HsiHvZk0U,910
|
|
4
|
+
chefe/manager.py,sha256=MKVKyAxSYFWN6nGKrDFIRIA_7mpi_K8v5DvLorBg_PM,8290
|
|
5
|
+
chefe/state.py,sha256=EdIeaDJCuy01XYlTIZwH3RYkQrxGqb5H7J0ezR-BY9g,461
|
|
6
|
+
chefe/utils.py,sha256=sZpzb6spiHiMsdb_HXtgPgmZtYxPArRXJuvqHxQNnpY,845
|
|
7
|
+
chefe/backends/__init__.py,sha256=OHJfEap69ImC0eG6NnPU1eEBIotXdMalRoLHQiD8Mzs,172
|
|
8
|
+
chefe/backends/cargo.py,sha256=75uMvaj4Z69bPLaei-U-vLbHSAIpGaCyd6Zct5P6_og,1749
|
|
9
|
+
chefe/backends/npm.py,sha256=rX_NZ57132o5io7yNoNS00kjh92nAbDmAWYYB6ku0Jw,947
|
|
10
|
+
chefe/backends/pixi.py,sha256=iSgcO2q6WYJaKkja7NrzM-6r74E5yJ9G2Ld92CtZv04,1415
|
|
11
|
+
chefe/backends/tool.py,sha256=a9FAyJfeyru64a4AWc4i-es_IRHkqNzlX4LNhHmCTF8,2728
|
|
12
|
+
chefe/compiled/__init__.py,sha256=Xw2qT_sE1FaXdR8lMbmDhY-eFN_Nj-80rwnh0qdldV0,139
|
|
13
|
+
chefe/compiled/npm.py,sha256=So2tjCHYxljSkDVzn8YSfSXFqDMAZTzE9v2guaxITSE,782
|
|
14
|
+
chefe/compiled/pixi.py,sha256=fBw30Ze9zQ1_3A59lrtWCOhXYOOeXgO_m0a7a-3LlyA,2702
|
|
15
|
+
chefe/manifest/__init__.py,sha256=2nk4z3rxpS6RGqwEjqRi_eaFZGCPX7DrwUrvzQKzMuU,305
|
|
16
|
+
chefe/manifest/document.py,sha256=-b9kfCLI6AjDioTwKss_-2tSsUJ6MFs_cUel4AuPplM,4591
|
|
17
|
+
chefe/manifest/schema.py,sha256=0dIx7e5J0On18VRqysR3M5zZ7WJNjJA9QEqWMCMAh-E,6687
|
|
18
|
+
chefe-0.0.1.dist-info/METADATA,sha256=_9oSbMI_iFQShtwtuHtp7C6i-kqoQKaCrmIFYxkNo30,4265
|
|
19
|
+
chefe-0.0.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
20
|
+
chefe-0.0.1.dist-info/entry_points.txt,sha256=bMskgJVjwC2uYHXC9K3oqlob3qvfcxGuxhSTjYIVWZQ,40
|
|
21
|
+
chefe-0.0.1.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
22
|
+
chefe-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|