esys-tools 0.2.0__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.
- esys_tools-0.2.0/PKG-INFO +101 -0
- esys_tools-0.2.0/README.md +87 -0
- esys_tools-0.2.0/pyproject.toml +47 -0
- esys_tools-0.2.0/setup.cfg +4 -0
- esys_tools-0.2.0/src/esys_tools/__init__.py +3 -0
- esys_tools-0.2.0/src/esys_tools/__main__.py +6 -0
- esys_tools-0.2.0/src/esys_tools/bootstrap.py +143 -0
- esys_tools-0.2.0/src/esys_tools/catalog.py +317 -0
- esys_tools-0.2.0/src/esys_tools/cli.py +472 -0
- esys_tools-0.2.0/src/esys_tools/commands/__init__.py +1 -0
- esys_tools-0.2.0/src/esys_tools/commands/doctor.py +395 -0
- esys_tools-0.2.0/src/esys_tools/commands/lifecycle.py +306 -0
- esys_tools-0.2.0/src/esys_tools/commands/list_versions.py +121 -0
- esys_tools-0.2.0/src/esys_tools/compat.py +198 -0
- esys_tools-0.2.0/src/esys_tools/conan.py +232 -0
- esys_tools-0.2.0/src/esys_tools/conan_env.py +215 -0
- esys_tools-0.2.0/src/esys_tools/exit_codes.py +17 -0
- esys_tools-0.2.0/src/esys_tools/path_install.py +213 -0
- esys_tools-0.2.0/src/esys_tools/process.py +114 -0
- esys_tools-0.2.0/src/esys_tools/python_env.py +346 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/PKG-INFO +101 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/SOURCES.txt +37 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/dependency_links.txt +1 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/entry_points.txt +3 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/requires.txt +6 -0
- esys_tools-0.2.0/src/esys_tools.egg-info/top_level.txt +1 -0
- esys_tools-0.2.0/tests/test_bootstrap.py +219 -0
- esys_tools-0.2.0/tests/test_catalog.py +247 -0
- esys_tools-0.2.0/tests/test_cli_help.py +54 -0
- esys_tools-0.2.0/tests/test_compat.py +139 -0
- esys_tools-0.2.0/tests/test_conan_env.py +221 -0
- esys_tools-0.2.0/tests/test_doctor.py +149 -0
- esys_tools-0.2.0/tests/test_integration_artifactory.py +217 -0
- esys_tools-0.2.0/tests/test_lifecycle.py +230 -0
- esys_tools-0.2.0/tests/test_list_versions.py +243 -0
- esys_tools-0.2.0/tests/test_path_install.py +201 -0
- esys_tools-0.2.0/tests/test_process.py +79 -0
- esys_tools-0.2.0/tests/test_python_env.py +197 -0
- esys_tools-0.2.0/tests/test_smoke.py +8 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: esys-tools
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Install and update catalogued LibESys command-line tools
|
|
5
|
+
Author: Project maintainers
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: typer>=0.12
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: pre-commit>=4.0; extra == "dev"
|
|
12
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
13
|
+
Requires-Dist: ruff>=0.8; extra == "dev"
|
|
14
|
+
|
|
15
|
+
# esys-tools
|
|
16
|
+
|
|
17
|
+
Control plane for installing, updating, listing, and removing native LibESys
|
|
18
|
+
command-line tools. It extends [esysrepo-ctl](https://gitlab.com/libesys/esysrepo/esysrepo-ctl),
|
|
19
|
+
which does this for `esysrepo` alone. Which other tools qualify is a Git
|
|
20
|
+
catalog, not a guess from the organization: `libesys/tools/esys-tools-catalog`.
|
|
21
|
+
|
|
22
|
+
Native commands stay the tool's own commands. For `esysrepo` those are
|
|
23
|
+
`esysrepo` and `erepo`. This package only manages lifecycle.
|
|
24
|
+
|
|
25
|
+
The decisions are Accepted ADRs under `docs/adr/`. `esysrepo` is the first
|
|
26
|
+
catalog entry and keeps the esysrepo-ctl package names:
|
|
27
|
+
`esysrepo-cli-static` by default, `esysrepo-cli` with `--linkage shared`.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pipx install esys-tools
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or from a development checkout:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m pip install -e ".[dev]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`esys-tools` and `etools` are the same command.
|
|
42
|
+
|
|
43
|
+
The host needs Python with a working `venv` module. Conan is installed into a
|
|
44
|
+
venv this tool manages. See `docs/adr/0008-three-python-env-modes.md`.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Interactive: detect mode, confirm, persist
|
|
48
|
+
esys-tools install esysrepo
|
|
49
|
+
|
|
50
|
+
# Non-interactive installer-like install
|
|
51
|
+
esys-tools install esysrepo --mode managed --yes
|
|
52
|
+
|
|
53
|
+
# Project-private: activate the project venv first
|
|
54
|
+
esys-tools install esysrepo --mode project --yes
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Mode | Conan lives in | Native wrappers |
|
|
58
|
+
|------|----------------|-----------------|
|
|
59
|
+
| `project` | Active project venv | That venv's `bin` / `Scripts` |
|
|
60
|
+
| `pipx` | Managed home venv | Managed `…/esys-tools/bin` |
|
|
61
|
+
| `managed` | Managed home venv | Managed `…/esys-tools/bin` |
|
|
62
|
+
|
|
63
|
+
Overrides: `ESYS_TOOLS_MODE`, `ESYS_TOOLS_YES=1`, `--reconfigure`. The choice is
|
|
64
|
+
stored under `ESYS_TOOLS_HOME` or the platform data directory.
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
| Command | Purpose |
|
|
69
|
+
|---------|---------|
|
|
70
|
+
| `install <tool>` | Install that tool's native CLI via Conan |
|
|
71
|
+
| `update <tool>` | Update it; may install it when missing |
|
|
72
|
+
| `list` | List tools in the catalog |
|
|
73
|
+
| `list <tool>` | List Conan versions of that tool |
|
|
74
|
+
| `remove <tool>` | Remove that tool's selected Conan package |
|
|
75
|
+
| `doctor` | Diagnose environment, catalog revision, and wrappers |
|
|
76
|
+
| `paths` | Print the data directory and catalog checkout |
|
|
77
|
+
| `version` | Print the control-plane version and installed tools |
|
|
78
|
+
| `catalog update` | Refresh the catalog without installing |
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
esys-tools --help
|
|
82
|
+
esys-tools --version
|
|
83
|
+
esys-tools list
|
|
84
|
+
esys-tools list esysrepo
|
|
85
|
+
esys-tools list esysrepo --dev
|
|
86
|
+
esys-tools install esysrepo --linkage shared
|
|
87
|
+
esys-tools install esysrepo --channel center
|
|
88
|
+
esys-tools update esysrepo
|
|
89
|
+
esys-tools doctor
|
|
90
|
+
esys-tools paths
|
|
91
|
+
esys-tools remove esysrepo
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
There is no default tool. `update <tool>` is the command that may auto-install.
|
|
95
|
+
Disable that with `--no-bootstrap`, `--strict`, or `CI=true`.
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [docs/adr/INDEX.md](docs/adr/INDEX.md) — decisions
|
|
100
|
+
- [docs/architecture/overview.md](docs/architecture/overview.md) — scope and structure
|
|
101
|
+
- [docs/asr/README.md](docs/asr/README.md) — quality requirements
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# esys-tools
|
|
2
|
+
|
|
3
|
+
Control plane for installing, updating, listing, and removing native LibESys
|
|
4
|
+
command-line tools. It extends [esysrepo-ctl](https://gitlab.com/libesys/esysrepo/esysrepo-ctl),
|
|
5
|
+
which does this for `esysrepo` alone. Which other tools qualify is a Git
|
|
6
|
+
catalog, not a guess from the organization: `libesys/tools/esys-tools-catalog`.
|
|
7
|
+
|
|
8
|
+
Native commands stay the tool's own commands. For `esysrepo` those are
|
|
9
|
+
`esysrepo` and `erepo`. This package only manages lifecycle.
|
|
10
|
+
|
|
11
|
+
The decisions are Accepted ADRs under `docs/adr/`. `esysrepo` is the first
|
|
12
|
+
catalog entry and keeps the esysrepo-ctl package names:
|
|
13
|
+
`esysrepo-cli-static` by default, `esysrepo-cli` with `--linkage shared`.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pipx install esys-tools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or from a development checkout:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install -e ".[dev]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`esys-tools` and `etools` are the same command.
|
|
28
|
+
|
|
29
|
+
The host needs Python with a working `venv` module. Conan is installed into a
|
|
30
|
+
venv this tool manages. See `docs/adr/0008-three-python-env-modes.md`.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Interactive: detect mode, confirm, persist
|
|
34
|
+
esys-tools install esysrepo
|
|
35
|
+
|
|
36
|
+
# Non-interactive installer-like install
|
|
37
|
+
esys-tools install esysrepo --mode managed --yes
|
|
38
|
+
|
|
39
|
+
# Project-private: activate the project venv first
|
|
40
|
+
esys-tools install esysrepo --mode project --yes
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Mode | Conan lives in | Native wrappers |
|
|
44
|
+
|------|----------------|-----------------|
|
|
45
|
+
| `project` | Active project venv | That venv's `bin` / `Scripts` |
|
|
46
|
+
| `pipx` | Managed home venv | Managed `…/esys-tools/bin` |
|
|
47
|
+
| `managed` | Managed home venv | Managed `…/esys-tools/bin` |
|
|
48
|
+
|
|
49
|
+
Overrides: `ESYS_TOOLS_MODE`, `ESYS_TOOLS_YES=1`, `--reconfigure`. The choice is
|
|
50
|
+
stored under `ESYS_TOOLS_HOME` or the platform data directory.
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
54
|
+
| Command | Purpose |
|
|
55
|
+
|---------|---------|
|
|
56
|
+
| `install <tool>` | Install that tool's native CLI via Conan |
|
|
57
|
+
| `update <tool>` | Update it; may install it when missing |
|
|
58
|
+
| `list` | List tools in the catalog |
|
|
59
|
+
| `list <tool>` | List Conan versions of that tool |
|
|
60
|
+
| `remove <tool>` | Remove that tool's selected Conan package |
|
|
61
|
+
| `doctor` | Diagnose environment, catalog revision, and wrappers |
|
|
62
|
+
| `paths` | Print the data directory and catalog checkout |
|
|
63
|
+
| `version` | Print the control-plane version and installed tools |
|
|
64
|
+
| `catalog update` | Refresh the catalog without installing |
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
esys-tools --help
|
|
68
|
+
esys-tools --version
|
|
69
|
+
esys-tools list
|
|
70
|
+
esys-tools list esysrepo
|
|
71
|
+
esys-tools list esysrepo --dev
|
|
72
|
+
esys-tools install esysrepo --linkage shared
|
|
73
|
+
esys-tools install esysrepo --channel center
|
|
74
|
+
esys-tools update esysrepo
|
|
75
|
+
esys-tools doctor
|
|
76
|
+
esys-tools paths
|
|
77
|
+
esys-tools remove esysrepo
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
There is no default tool. `update <tool>` is the command that may auto-install.
|
|
81
|
+
Disable that with `--no-bootstrap`, `--strict`, or `CI=true`.
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
- [docs/adr/INDEX.md](docs/adr/INDEX.md) — decisions
|
|
86
|
+
- [docs/architecture/overview.md](docs/architecture/overview.md) — scope and structure
|
|
87
|
+
- [docs/asr/README.md](docs/asr/README.md) — quality requirements
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "esys-tools"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Install and update catalogued LibESys command-line tools"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "Project maintainers" }]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"typer>=0.12",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
esys-tools = "esys_tools.cli:app"
|
|
19
|
+
etools = "esys_tools.cli:app"
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pre-commit>=4.0",
|
|
24
|
+
"pytest>=8.0",
|
|
25
|
+
"ruff>=0.8",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
package-dir = { "" = "src" }
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["src"]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
pythonpath = ["src"]
|
|
37
|
+
markers = [
|
|
38
|
+
"integration: live Conan/Artifactory tests (require ESYS_TOOLS_INTEGRATION=1)",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
line-length = 100
|
|
43
|
+
target-version = "py311"
|
|
44
|
+
src = ["src", "tests"]
|
|
45
|
+
|
|
46
|
+
[tool.ruff.lint]
|
|
47
|
+
select = ["E", "F", "I", "UP"]
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Auto-bootstrap one named tool on update (ADR-0005).
|
|
2
|
+
|
|
3
|
+
``install`` stays explicit. ``list`` and ``version`` do not install a native CLI.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from collections.abc import Mapping
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
from esys_tools.catalog import CatalogEntry
|
|
13
|
+
from esys_tools.commands.lifecycle import (
|
|
14
|
+
WRAPPER_MARKER,
|
|
15
|
+
install_tool,
|
|
16
|
+
wrapper_bin_for_mode,
|
|
17
|
+
wrapper_filename,
|
|
18
|
+
)
|
|
19
|
+
from esys_tools.exit_codes import ExitCode
|
|
20
|
+
from esys_tools.python_env import ModeNotConfirmedError, PythonEnvMode, resolve_mode
|
|
21
|
+
|
|
22
|
+
_TRUTHY = {"1", "true", "yes", "on"}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class EnsureResult:
|
|
27
|
+
"""Whether update may continue, and whether this call installed the tool."""
|
|
28
|
+
|
|
29
|
+
exit_code: ExitCode
|
|
30
|
+
bootstrapped: bool
|
|
31
|
+
error: str = ""
|
|
32
|
+
hint: str = ""
|
|
33
|
+
message: str = ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def bootstrap_permitted(
|
|
37
|
+
*,
|
|
38
|
+
no_bootstrap: bool = False,
|
|
39
|
+
strict: bool = False,
|
|
40
|
+
environ: Mapping[str, str] | None = None,
|
|
41
|
+
) -> bool:
|
|
42
|
+
"""Implicit install is off for ``--no-bootstrap``, ``--strict``, and ``CI=true``."""
|
|
43
|
+
if no_bootstrap or strict:
|
|
44
|
+
return False
|
|
45
|
+
env = os.environ if environ is None else environ
|
|
46
|
+
if _truthy(env.get("ESYS_TOOLS_NO_BOOTSTRAP")) or _truthy(env.get("ESYS_TOOLS_STRICT")):
|
|
47
|
+
return False
|
|
48
|
+
return not _truthy(env.get("CI"))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def native_wrappers_present(
|
|
52
|
+
entry: CatalogEntry,
|
|
53
|
+
mode: PythonEnvMode,
|
|
54
|
+
*,
|
|
55
|
+
environ: Mapping[str, str] | None = None,
|
|
56
|
+
) -> bool:
|
|
57
|
+
"""Return whether every command wrapper for this entry is already in place."""
|
|
58
|
+
bin_dir = wrapper_bin_for_mode(mode, environ=environ)
|
|
59
|
+
if not bin_dir.is_dir():
|
|
60
|
+
return False
|
|
61
|
+
for command in entry.commands:
|
|
62
|
+
path = bin_dir / wrapper_filename(command)
|
|
63
|
+
if not path.is_file():
|
|
64
|
+
return False
|
|
65
|
+
text = path.read_text(encoding="utf-8", errors="replace")
|
|
66
|
+
if WRAPPER_MARKER not in text or f"tool={entry.id}" not in text:
|
|
67
|
+
return False
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def ensure_for_update(
|
|
72
|
+
entry: CatalogEntry,
|
|
73
|
+
*,
|
|
74
|
+
linkage: str | None = None,
|
|
75
|
+
channel: str | None = None,
|
|
76
|
+
dev: bool = False,
|
|
77
|
+
mode: str | None = None,
|
|
78
|
+
yes: bool = False,
|
|
79
|
+
no_bootstrap: bool = False,
|
|
80
|
+
strict: bool = False,
|
|
81
|
+
environ: Mapping[str, str] | None = None,
|
|
82
|
+
) -> EnsureResult:
|
|
83
|
+
"""Install ``entry`` when its wrappers are missing and bootstrap is allowed.
|
|
84
|
+
|
|
85
|
+
The confirm path runs first. A refused mode does not call Conan. Only this
|
|
86
|
+
tool id is installed.
|
|
87
|
+
"""
|
|
88
|
+
try:
|
|
89
|
+
resolved, _source = resolve_mode(explicit=mode, yes=yes, environ=environ)
|
|
90
|
+
present = native_wrappers_present(entry, resolved, environ=environ)
|
|
91
|
+
except ModeNotConfirmedError as exc:
|
|
92
|
+
return EnsureResult(
|
|
93
|
+
exit_code=ExitCode.ENVIRONMENT_ERROR,
|
|
94
|
+
bootstrapped=False,
|
|
95
|
+
error=str(exc),
|
|
96
|
+
)
|
|
97
|
+
except ValueError as exc:
|
|
98
|
+
return EnsureResult(
|
|
99
|
+
exit_code=ExitCode.ENVIRONMENT_ERROR,
|
|
100
|
+
bootstrapped=False,
|
|
101
|
+
error=f"error: {exc}",
|
|
102
|
+
)
|
|
103
|
+
if present:
|
|
104
|
+
return EnsureResult(exit_code=ExitCode.SUCCESS, bootstrapped=False)
|
|
105
|
+
if not bootstrap_permitted(no_bootstrap=no_bootstrap, strict=strict, environ=environ):
|
|
106
|
+
return EnsureResult(
|
|
107
|
+
exit_code=ExitCode.MISSING_NATIVE_CLI,
|
|
108
|
+
bootstrapped=False,
|
|
109
|
+
error=f"error: native CLI for '{entry.id}' is not installed",
|
|
110
|
+
hint=f"hint: esys-tools install {entry.id}",
|
|
111
|
+
)
|
|
112
|
+
installed = install_tool(
|
|
113
|
+
entry,
|
|
114
|
+
linkage=linkage,
|
|
115
|
+
channel=channel,
|
|
116
|
+
dev=dev,
|
|
117
|
+
mode=mode,
|
|
118
|
+
yes=yes,
|
|
119
|
+
environ=environ,
|
|
120
|
+
)
|
|
121
|
+
if installed.exit_code is ExitCode.SUCCESS:
|
|
122
|
+
return EnsureResult(
|
|
123
|
+
exit_code=ExitCode.SUCCESS,
|
|
124
|
+
bootstrapped=True,
|
|
125
|
+
message=installed.message,
|
|
126
|
+
)
|
|
127
|
+
if installed.exit_code in {ExitCode.USAGE_ERROR, ExitCode.ENVIRONMENT_ERROR}:
|
|
128
|
+
return EnsureResult(
|
|
129
|
+
exit_code=installed.exit_code,
|
|
130
|
+
bootstrapped=False,
|
|
131
|
+
error=installed.error,
|
|
132
|
+
hint=installed.hint,
|
|
133
|
+
)
|
|
134
|
+
return EnsureResult(
|
|
135
|
+
exit_code=ExitCode.BOOTSTRAP_FAILURE,
|
|
136
|
+
bootstrapped=False,
|
|
137
|
+
error=installed.error or f"error: auto-bootstrap failed for {entry.id}",
|
|
138
|
+
hint=installed.hint or f"hint: esys-tools install {entry.id}",
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _truthy(value: str | None) -> bool:
|
|
143
|
+
return bool(value) and value.strip().lower() in _TRUTHY
|