pkgmgr-kunrunic 0.1.1.dev0__tar.gz → 0.1.1.dev1__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.
- {pkgmgr_kunrunic-0.1.1.dev0/pkgmgr_kunrunic.egg-info → pkgmgr_kunrunic-0.1.1.dev1}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/cli.py +16 -2
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/config.py +5 -1
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/shell_integration.py +37 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1/pkgmgr_kunrunic.egg-info}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt +1 -0
- pkgmgr_kunrunic-0.1.1.dev1/tests/test_cli_install.py +66 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_config.py +13 -1
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/README.md +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/gitcollect.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/points.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/release.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkg.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkgmgr.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/setup.cfg +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_progress.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_release.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/tests/test_snapshot.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import print_function
|
|
2
2
|
"""CLI entrypoint scaffold for the pkg manager."""
|
|
3
3
|
|
|
4
|
+
import os
|
|
4
5
|
import sys
|
|
5
6
|
|
|
6
7
|
try:
|
|
@@ -186,12 +187,25 @@ def build_parser():
|
|
|
186
187
|
|
|
187
188
|
|
|
188
189
|
def _handle_make_config(args):
|
|
189
|
-
config.write_template(args.output)
|
|
190
|
-
return 0
|
|
190
|
+
wrote = config.write_template(args.output)
|
|
191
|
+
return 0 if wrote else 1
|
|
191
192
|
|
|
192
193
|
|
|
193
194
|
def _handle_install(args):
|
|
194
195
|
cfg = config.load_main(args.config)
|
|
196
|
+
existing = []
|
|
197
|
+
readme_path = os.path.join(config.BASE_DIR, "README.txt")
|
|
198
|
+
baseline_path = os.path.join(snapshot.STATE_DIR, "baseline.json")
|
|
199
|
+
if os.path.exists(readme_path):
|
|
200
|
+
existing.append(readme_path)
|
|
201
|
+
if os.path.exists(baseline_path):
|
|
202
|
+
existing.append(baseline_path)
|
|
203
|
+
if existing:
|
|
204
|
+
print("[install] existing install artifacts found:")
|
|
205
|
+
for path in existing:
|
|
206
|
+
print(" - %s" % path)
|
|
207
|
+
print("[install] remove these files to re-run install")
|
|
208
|
+
return 1
|
|
195
209
|
print("[install] step 1/2: shell integration")
|
|
196
210
|
release.ensure_environment()
|
|
197
211
|
print("[install] step 2/2: baseline snapshot")
|
|
@@ -215,9 +215,12 @@ def _load_template_file(filename, fallback):
|
|
|
215
215
|
|
|
216
216
|
|
|
217
217
|
def write_template(path=None):
|
|
218
|
-
"""Write the main pkgmgr.yaml template."""
|
|
218
|
+
"""Write the main pkgmgr.yaml template. Returns True if written."""
|
|
219
219
|
path = path or DEFAULT_MAIN_CONFIG
|
|
220
220
|
target = os.path.realpath(os.path.abspath(os.path.expanduser(path)))
|
|
221
|
+
if os.path.exists(target):
|
|
222
|
+
print("[make-config] config already exists at %s; remove it and re-run" % target)
|
|
223
|
+
return False
|
|
221
224
|
parent = os.path.dirname(target)
|
|
222
225
|
if parent and not os.path.exists(parent):
|
|
223
226
|
os.makedirs(parent)
|
|
@@ -225,6 +228,7 @@ def write_template(path=None):
|
|
|
225
228
|
with open(target, "w") as f:
|
|
226
229
|
f.write(content)
|
|
227
230
|
print("[make-config] wrote template to %s" % target)
|
|
231
|
+
return True
|
|
228
232
|
|
|
229
233
|
|
|
230
234
|
def write_pkg_template(path, pkg_id=None, pkg_root=None, include_releases=None, git_cfg=None, collectors_enabled=None):
|
|
@@ -27,6 +27,12 @@ def ensure_path_and_alias(script_dir, alias_name="pkg", command="pkgmgr"):
|
|
|
27
27
|
print("[install] unknown shell '%s'; skipping rc update" % (shell_name or ""))
|
|
28
28
|
return
|
|
29
29
|
|
|
30
|
+
if not _path_contains_dir(script_dir):
|
|
31
|
+
print("[install] PATH missing: %s" % script_dir)
|
|
32
|
+
print("[install] add to PATH, for example:")
|
|
33
|
+
for line in _path_only_instructions(shell_name, script_dir):
|
|
34
|
+
print(" " + line)
|
|
35
|
+
|
|
30
36
|
header = "[install] To use pkgmgr, add these lines to your shell rc:"
|
|
31
37
|
for line in _emit_lines_with_header(header, lines):
|
|
32
38
|
print(line)
|
|
@@ -63,6 +69,37 @@ def _instructions_for_shell(shell_name, script_dir, alias_name, command):
|
|
|
63
69
|
return None
|
|
64
70
|
|
|
65
71
|
|
|
72
|
+
def _path_only_instructions(shell_name, script_dir):
|
|
73
|
+
if shell_name == "bash":
|
|
74
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
75
|
+
if shell_name == "zsh":
|
|
76
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
77
|
+
if shell_name in ("csh", "tcsh"):
|
|
78
|
+
return ["set path = (%s $path)" % script_dir]
|
|
79
|
+
if shell_name == "fish":
|
|
80
|
+
return ["set -U fish_user_paths %s $fish_user_paths" % script_dir]
|
|
81
|
+
return ['export PATH="%s:$PATH"' % script_dir]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _path_contains_dir(path):
|
|
85
|
+
if not path:
|
|
86
|
+
return False
|
|
87
|
+
try:
|
|
88
|
+
target = os.path.realpath(os.path.abspath(os.path.expanduser(path)))
|
|
89
|
+
except Exception:
|
|
90
|
+
target = path
|
|
91
|
+
for entry in os.environ.get("PATH", "").split(os.pathsep):
|
|
92
|
+
if not entry:
|
|
93
|
+
continue
|
|
94
|
+
try:
|
|
95
|
+
entry_path = os.path.realpath(os.path.abspath(os.path.expanduser(entry)))
|
|
96
|
+
except Exception:
|
|
97
|
+
entry_path = entry
|
|
98
|
+
if entry_path == target:
|
|
99
|
+
return True
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
|
|
66
103
|
def _emit_lines_with_header(header, lines):
|
|
67
104
|
out = [header]
|
|
68
105
|
out.extend(lines)
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
@@ -23,6 +23,7 @@ pkgmgr_kunrunic.egg-info/entry_points.txt
|
|
|
23
23
|
pkgmgr_kunrunic.egg-info/not-zip-safe
|
|
24
24
|
pkgmgr_kunrunic.egg-info/requires.txt
|
|
25
25
|
pkgmgr_kunrunic.egg-info/top_level.txt
|
|
26
|
+
tests/test_cli_install.py
|
|
26
27
|
tests/test_config.py
|
|
27
28
|
tests/test_progress.py
|
|
28
29
|
tests/test_release.py
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import tempfile
|
|
4
|
+
from importlib import import_module, reload
|
|
5
|
+
from types import SimpleNamespace
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
9
|
+
if str(ROOT) not in sys.path:
|
|
10
|
+
sys.path.insert(0, str(ROOT))
|
|
11
|
+
|
|
12
|
+
cli = import_module("pkgmgr.cli")
|
|
13
|
+
config = import_module("pkgmgr.config")
|
|
14
|
+
release = import_module("pkgmgr.release")
|
|
15
|
+
snapshot = import_module("pkgmgr.snapshot")
|
|
16
|
+
reload(cli)
|
|
17
|
+
reload(config)
|
|
18
|
+
reload(release)
|
|
19
|
+
reload(snapshot)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _setup_paths(monkeypatch, base):
|
|
23
|
+
monkeypatch.setattr(config, "BASE_DIR", str(base))
|
|
24
|
+
state_dir = os.path.join(str(base), "local", "state")
|
|
25
|
+
monkeypatch.setattr(config, "DEFAULT_STATE_DIR", state_dir)
|
|
26
|
+
monkeypatch.setattr(snapshot, "STATE_DIR", state_dir)
|
|
27
|
+
return state_dir
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_install_aborts_when_readme_exists(monkeypatch):
|
|
31
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
32
|
+
base = Path(tmp)
|
|
33
|
+
_setup_paths(monkeypatch, base)
|
|
34
|
+
readme = base / "README.txt"
|
|
35
|
+
readme.write_text("existing")
|
|
36
|
+
|
|
37
|
+
calls = {"env": 0, "baseline": 0}
|
|
38
|
+
monkeypatch.setattr(config, "load_main", lambda *_args, **_kwargs: {})
|
|
39
|
+
monkeypatch.setattr(release, "ensure_environment", lambda: calls.__setitem__("env", 1))
|
|
40
|
+
monkeypatch.setattr(snapshot, "create_baseline", lambda *_a, **_k: calls.__setitem__("baseline", 1))
|
|
41
|
+
|
|
42
|
+
rc = cli._handle_install(SimpleNamespace(config=None))
|
|
43
|
+
|
|
44
|
+
assert rc == 1
|
|
45
|
+
assert calls["env"] == 0
|
|
46
|
+
assert calls["baseline"] == 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_install_aborts_when_baseline_exists(monkeypatch):
|
|
50
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
51
|
+
base = Path(tmp)
|
|
52
|
+
state_dir = _setup_paths(monkeypatch, base)
|
|
53
|
+
Path(state_dir).mkdir(parents=True, exist_ok=True)
|
|
54
|
+
baseline = Path(state_dir) / "baseline.json"
|
|
55
|
+
baseline.write_text("{}")
|
|
56
|
+
|
|
57
|
+
calls = {"env": 0, "baseline": 0}
|
|
58
|
+
monkeypatch.setattr(config, "load_main", lambda *_args, **_kwargs: {})
|
|
59
|
+
monkeypatch.setattr(release, "ensure_environment", lambda: calls.__setitem__("env", 1))
|
|
60
|
+
monkeypatch.setattr(snapshot, "create_baseline", lambda *_a, **_k: calls.__setitem__("baseline", 1))
|
|
61
|
+
|
|
62
|
+
rc = cli._handle_install(SimpleNamespace(config=None))
|
|
63
|
+
|
|
64
|
+
assert rc == 1
|
|
65
|
+
assert calls["env"] == 0
|
|
66
|
+
assert calls["baseline"] == 0
|
|
@@ -73,7 +73,19 @@ def test_write_template_respects_overridden_default_path(monkeypatch):
|
|
|
73
73
|
|
|
74
74
|
assert target.exists()
|
|
75
75
|
content = target.read_text()
|
|
76
|
-
|
|
76
|
+
assert "pkg_release_root" in content
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_write_template_skips_when_existing(monkeypatch):
|
|
80
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
81
|
+
target = Path(tmp) / "pkgmgr.yaml"
|
|
82
|
+
target.write_text("keep: true\n")
|
|
83
|
+
monkeypatch.setattr(config, "DEFAULT_MAIN_CONFIG", str(target))
|
|
84
|
+
|
|
85
|
+
wrote = config.write_template()
|
|
86
|
+
|
|
87
|
+
assert wrote is False
|
|
88
|
+
assert target.read_text() == "keep: true\n"
|
|
77
89
|
|
|
78
90
|
|
|
79
91
|
def test_load_main_applies_defaults_and_validation():
|
|
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
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr/templates/pkgmgr.yaml.sample
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/requires.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev0 → pkgmgr_kunrunic-0.1.1.dev1}/pkgmgr_kunrunic.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|