fontlab-python-instamix 1.0.1__tar.gz → 1.0.2__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.
Files changed (48) hide show
  1. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/CHANGELOG.md +6 -0
  2. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/PKG-INFO +3 -2
  3. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/README.md +2 -1
  4. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/__version__.py +2 -2
  5. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/bootstrap.py +31 -11
  6. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/extension.py +28 -1
  7. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/initscript.py +3 -0
  8. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_bootstrap_cli.py +61 -0
  9. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_parity.py +14 -0
  10. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/.gitignore +0 -0
  11. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/LICENSE +0 -0
  12. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/PLAN.md +0 -0
  13. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/build.sh +0 -0
  14. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/examples/com.example.hello.fontlabext/encoding/hello.enc +0 -0
  15. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/examples/com.example.hello.fontlabext/manifest.fontlabextj +0 -0
  16. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/examples/com.example.hello.fontlabext/scripts/Hello.py +0 -0
  17. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/install.vfpy +0 -0
  18. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/publish.sh +0 -0
  19. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/pyproject.toml +0 -0
  20. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/__init__.py +0 -0
  21. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/__main__.py +0 -0
  22. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/cli.py +0 -0
  23. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/dest.py +0 -0
  24. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/distinfo.py +0 -0
  25. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/env.py +0 -0
  26. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/gui.py +0 -0
  27. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/launch.py +0 -0
  28. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/launchers.py +0 -0
  29. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/ledger.py +0 -0
  30. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/legacy.py +0 -0
  31. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/manifest.py +0 -0
  32. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/markers.py +0 -0
  33. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/packages.py +0 -0
  34. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/platformdirs.py +0 -0
  35. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/stub.py +0 -0
  36. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/stub_install.vfpy +0 -0
  37. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/uv.py +0 -0
  38. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/vcs.py +0 -0
  39. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/venv.py +0 -0
  40. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/src/fontlab_instamix/wrap.py +0 -0
  41. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/stub/install.vfpy +0 -0
  42. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/test.sh +0 -0
  43. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/conftest.py +0 -0
  44. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_dest.py +0 -0
  45. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_env.py +0 -0
  46. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_extension.py +0 -0
  47. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_manifest.py +0 -0
  48. {fontlab_python_instamix-1.0.1 → fontlab_python_instamix-1.0.2}/tests/test_packages.py +0 -0
@@ -3,6 +3,12 @@ this_file: CHANGELOG.md
3
3
  ---
4
4
  # Changelog
5
5
 
6
+ ## 1.0.2 (2026-11-16)
7
+
8
+ - Sibling detection now follows legacy `fontlab-fly`: a neighbouring folder counts only if it has `install.vfpy` and a pyproject with a `[tool.fontlab-install]` table and valid `id`, matched by normalised table or project name. Read-only checkouts such as TypeRig no longer break installs; their specs go to uv.
9
+ - Uninstall removes empty folders that instamix created under `Scripts/` (never `Scripts/` itself) and deletes `initScript.py` when only instamix's block was in it.
10
+ - 147 offline pytest tests; an offline run installed and uninstalled all 13 workspace packages in one data folder.
11
+
6
12
  ## 1.0.1 (2026-11-16)
7
13
 
8
14
  - Legacy `install.vfpy` parity in `bootstrap.install_project`: environment markers (`markers.py`), hatch-vcs versions (`vcs.py`), dist-info (`distinfo.py`), the fontlabapp `initScript.py` block (`initscript.py`), `Scripts/Instamix` launchers (`launchers.py`, `launch.py`), plugin bundles under `Extensions/<kind>`, Scripts mapping and junk filter, hatch/project fallbacks for packages and dependencies, and migration of legacy installs (`legacy.py`).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: fontlab-python-instamix
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Stdlib-only installer for FontLab 9 extensions, scripts and Python packages
5
5
  Project-URL: Repository, https://github.com/fontlabcom/fontlab-python-instamix
6
6
  License-Expression: Apache-2.0
@@ -121,7 +121,8 @@ It matches the legacy `install.vfpy`:
121
121
  - The version comes from the static `[project].version`, then the hatch-vcs version file, `PKG-INFO`, `git describe` and the fallback version.
122
122
  - `<dist>-<version>.dist-info` (INSTALLER `fontlab-instamix`) is written so `importlib.metadata` finds the package. Uninstall removes it and never follows the editable package link.
123
123
  - `Scripts/Instamix/` holds `List Extensions.py` and `Uninstall <id>.py`.
124
- - For fontlabapp, the `fontlabapp.plugins` block is added to `initScript.py`, and removed again on uninstall.
124
+ - For fontlabapp, the `fontlabapp.plugins` block is added to `initScript.py`, and removed again on uninstall; `initScript.py` is deleted if nothing else is in it. Empty folders under `Scripts/` that instamix created are pruned too (never `Scripts/` itself, never a folder that existed before install).
125
+ - Dependencies uv installed from PyPI (for example fonttools) stay after uninstall: other extensions may share them, and the legacy installer also kept them. Sibling checkouts are detected only if their pyproject has a `[tool.fontlab-install]` table with a valid `id`; anything else (such as TypeRig) goes to uv.
125
126
  - A legacy `install.vfpy` install of the same id is migrated first. Files it logged are removed; changed files are kept. If a kept file would collide with the new install, the install stops before it changes anything. Shared legacy tools (`fontlab_install.py`, `Scripts/Extensions/`) are removed once no legacy install remains.
126
127
 
127
128
  ## Development
@@ -109,7 +109,8 @@ It matches the legacy `install.vfpy`:
109
109
  - The version comes from the static `[project].version`, then the hatch-vcs version file, `PKG-INFO`, `git describe` and the fallback version.
110
110
  - `<dist>-<version>.dist-info` (INSTALLER `fontlab-instamix`) is written so `importlib.metadata` finds the package. Uninstall removes it and never follows the editable package link.
111
111
  - `Scripts/Instamix/` holds `List Extensions.py` and `Uninstall <id>.py`.
112
- - For fontlabapp, the `fontlabapp.plugins` block is added to `initScript.py`, and removed again on uninstall.
112
+ - For fontlabapp, the `fontlabapp.plugins` block is added to `initScript.py`, and removed again on uninstall; `initScript.py` is deleted if nothing else is in it. Empty folders under `Scripts/` that instamix created are pruned too (never `Scripts/` itself, never a folder that existed before install).
113
+ - Dependencies uv installed from PyPI (for example fonttools) stay after uninstall: other extensions may share them, and the legacy installer also kept them. Sibling checkouts are detected only if their pyproject has a `[tool.fontlab-install]` table with a valid `id`; anything else (such as TypeRig) goes to uv.
113
114
  - A legacy `install.vfpy` install of the same id is migrated first. Files it logged are removed; changed files are kept. If a kept file would collide with the new install, the install stops before it changes anything. Shared legacy tools (`fontlab_install.py`, `Scripts/Extensions/`) are removed once no legacy install remains.
114
115
 
115
116
  ## Development
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.0.1'
22
- __version_tuple__ = version_tuple = (1, 0, 1)
21
+ __version__ = version = '1.0.2'
22
+ __version_tuple__ = version_tuple = (1, 0, 2)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -20,6 +20,7 @@ from __future__ import annotations
20
20
 
21
21
  import json
22
22
  import os
23
+ import re
23
24
  import shutil
24
25
  import tempfile
25
26
  import tomllib
@@ -249,7 +250,7 @@ def sibling_dependencies(project: Project) -> tuple[list[Path], list[str]]:
249
250
  name = markers.split(spec)[0]
250
251
  for sep in "<>=!~[ (@":
251
252
  name = name.split(sep)[0]
252
- sibling = _sibling(project.root.parent, name.strip())
253
+ sibling = _sibling(project.root.parent, name.strip(), skip=project.root)
253
254
  if sibling:
254
255
  siblings.append(sibling)
255
256
  else:
@@ -257,16 +258,35 @@ def sibling_dependencies(project: Project) -> tuple[list[Path], list[str]]:
257
258
  return siblings, specs
258
259
 
259
260
 
260
- def _sibling(parent: Path, name: str) -> Path | None:
261
- for candidate in dict.fromkeys(
262
- [name, name.replace("_", "-"), name.replace("-", "_")]
263
- ):
264
- folder = parent / candidate
265
- if (
266
- candidate
267
- and (folder / "install.vfpy").is_file()
268
- and (folder / "pyproject.toml").is_file()
269
- ):
261
+ def _norm(name: str) -> str:
262
+ """PEP 503 name normalisation (``Foo_Bar.baz`` -> ``foo-bar-baz``)."""
263
+ return re.sub(r"[-_.]+", "-", name).lower()
264
+
265
+
266
+ def _sibling(parent: Path, name: str, skip: Path | None = None) -> Path | None:
267
+ """Find the checkout beside *skip* that installs the dependency *name*.
268
+
269
+ Only folders with install.vfpy and a pyproject.toml holding a
270
+ ``[tool.fontlab-install]`` table with a valid ``id`` count, matched by that
271
+ table's ``name`` or ``[project].name`` (never by folder name alone), so
272
+ unrelated checkouts such as TypeRig are left to uv. First sorted folder wins.
273
+ """
274
+ wanted = _norm(name)
275
+ if not wanted or not parent.is_dir():
276
+ return None
277
+ for folder in sorted(parent.iterdir()):
278
+ if folder == skip or not (folder / "install.vfpy").is_file():
279
+ continue
280
+ try:
281
+ doc = tomllib.loads((folder / "pyproject.toml").read_text(encoding="utf-8"))
282
+ except (OSError, ValueError):
283
+ continue
284
+ tool, project = doc.get("tool"), doc.get("project")
285
+ table = tool.get("fontlab-install") if isinstance(tool, dict) else None
286
+ if not isinstance(table, dict) or not manifest.ID_PATTERN.match(str(table.get("id", ""))):
287
+ continue
288
+ names = {table.get("name"), project.get("name") if isinstance(project, dict) else None}
289
+ if wanted in {_norm(n) for n in names if isinstance(n, str)}:
270
290
  return folder
271
291
  return None
272
292
 
@@ -373,9 +373,36 @@ def _remove_tracked(data: Path, entries: list[dict]) -> list[dict]:
373
373
  return removed
374
374
 
375
375
 
376
+ def _created_dirs(data: Path, entries: list[dict]) -> set[Path]:
377
+ """Folders instamix created: ``dir`` entries of *entries* and of every ledger record."""
378
+ owned = list(entries)
379
+ for record in ledger.records(data):
380
+ owned += record.get("entries", [])
381
+ paths = (_entry_path(data, e) for e in owned if e.get("kind") == "dir")
382
+ return {p for p in paths if p is not None}
383
+
384
+
385
+ def _prune_empty(data: Path, path: Path | None, created: set[Path]) -> None:
386
+ """Remove now-empty folders above *path* that instamix created, never ``Scripts/``."""
387
+ scripts = Path(data) / "Scripts"
388
+ if path is None:
389
+ return
390
+ folder = path.parent
391
+ while folder != scripts and scripts in folder.parents and folder in created:
392
+ try:
393
+ folder.rmdir()
394
+ except OSError:
395
+ return
396
+ folder = folder.parent
397
+
398
+
376
399
  def remove_entries(data: Path, entries: list[dict]) -> list[str]:
377
400
  """Remove recorded paths that are still ours; return the ones left behind."""
378
- removed = {id(e) for e in _remove_tracked(data, entries)}
401
+ done = _remove_tracked(data, entries)
402
+ created = _created_dirs(data, entries) if done else set()
403
+ for entry in done:
404
+ _prune_empty(data, _entry_path(data, entry), created)
405
+ removed = {id(e) for e in done}
379
406
  kept = []
380
407
  for entry in entries:
381
408
  path = _entry_path(data, entry)
@@ -55,6 +55,9 @@ def update(data: Path, *, remove: bool = False) -> bool:
55
55
  new = updated(contents, remove)
56
56
  if new == contents:
57
57
  return False
58
+ if remove and not new.strip():
59
+ path.unlink() # nothing but our block was in it
60
+ return True
58
61
  handle, temp = tempfile.mkstemp(prefix=".initScript-", dir=str(path.parent))
59
62
  try:
60
63
  with os.fdopen(handle, "wb") as stream:
@@ -99,3 +99,64 @@ def test_gui_when_no_pythonqt_then_console(capsys):
99
99
 
100
100
  gui.message("hi")
101
101
  assert "hi" in capsys.readouterr().out
102
+
103
+
104
+ def test_install_project_when_neighbour_has_no_install_table_then_left_to_uv(data, tmp_path):
105
+ other = tmp_path / "typerig"
106
+ other.mkdir()
107
+ (other / "install.vfpy").write_text("")
108
+ (other / "pyproject.toml").write_text('[project]\nname = "typerig"\nversion = "1"\n')
109
+ bad = tmp_path / "broken"
110
+ bad.mkdir()
111
+ (bad / "install.vfpy").write_text("")
112
+ (bad / "pyproject.toml").write_text("not [valid toml")
113
+ root = _project(tmp_path / "proj-a", "proj-a", "com.example.proja", ["typerig>=1", "broken"])
114
+ calls = []
115
+ records = bootstrap.install_project(
116
+ root / "install.vfpy", data, requirements=lambda d, specs: calls.append(list(specs))
117
+ )
118
+ assert [r["id"] for r in records] == ["com.example.proja"]
119
+ assert calls == [["typerig>=1", "broken"]]
120
+ assert sorted(p.name for p in other.iterdir()) == ["install.vfpy", "pyproject.toml"]
121
+
122
+
123
+ def test_sibling_when_folder_name_differs_then_matches_project_name(tmp_path):
124
+ _project(tmp_path / "checkout-x", "Proj_X.lib", "com.example.projx")
125
+ assert bootstrap._sibling(tmp_path, "proj-x-lib", skip=tmp_path / "proj-a") == tmp_path / "checkout-x"
126
+
127
+
128
+ def test_uninstall_when_scripts_subfolders_emptied_then_pruned(data, tmp_path):
129
+ root = _project(tmp_path / "proj-a", "proj-a", "com.example.proja")
130
+ (root / "Scripts" / "Features").mkdir()
131
+ (root / "Scripts" / "Features" / "x.py").write_text("")
132
+ bootstrap.install_project(root / "install.vfpy", data, requirements=lambda d, s: None)
133
+ (data / "Scripts" / "Mine").mkdir()
134
+ assert (data / "Scripts" / "Features").is_dir()
135
+ extension.uninstall("com.example.proja", data)
136
+ assert not (data / "Scripts" / "Features").exists()
137
+ assert (data / "Scripts" / "Mine").is_dir() and (data / "Scripts").is_dir()
138
+
139
+
140
+ def test_uninstall_when_user_folder_preexisted_then_kept(data, tmp_path):
141
+ root = _project(tmp_path / "proj-a", "proj-a", "com.example.proja")
142
+ (root / "Scripts" / "Mine").mkdir()
143
+ (root / "Scripts" / "Mine" / "x.py").write_text("")
144
+ mine = data / "Scripts" / "Mine"
145
+ mine.mkdir(parents=True) # user's own empty folder, before install
146
+ bootstrap.install_project(root / "install.vfpy", data, requirements=lambda d, s: None)
147
+ assert (mine / "x.py").exists()
148
+ extension.uninstall("com.example.proja", data)
149
+ assert mine.is_dir() and not (mine / "x.py").exists()
150
+
151
+
152
+ def test_sibling_when_tables_malformed_then_skipped(tmp_path):
153
+ bad = tmp_path / "bad"
154
+ bad.mkdir()
155
+ (bad / "install.vfpy").write_text("")
156
+ (bad / "pyproject.toml").write_text('tool = 1\nproject = "x"\n')
157
+ badid = tmp_path / "badid"
158
+ badid.mkdir()
159
+ (badid / "install.vfpy").write_text("")
160
+ (badid / "pyproject.toml").write_text('[project]\nname = "badid"\n[tool.fontlab-install]\nid = "nodots"\n')
161
+ assert bootstrap._sibling(tmp_path, "bad") is None
162
+ assert bootstrap._sibling(tmp_path, "badid") is None
@@ -675,3 +675,17 @@ def test_stub_download_when_no_wheel_then_clear_error(tmp_path, monkeypatch, dat
675
675
  )
676
676
  with pytest.raises(RuntimeError, match="no fontlab-instamix wheel"):
677
677
  ns["download"](tmp_path)
678
+
679
+
680
+ def test_initscript_when_only_block_removed_then_file_deleted(tmp_path):
681
+ initscript.update(tmp_path)
682
+ assert (tmp_path / "initScript.py").is_file()
683
+ assert initscript.update(tmp_path, remove=True)
684
+ assert not (tmp_path / "initScript.py").exists()
685
+
686
+
687
+ def test_initscript_when_user_content_then_file_kept(tmp_path):
688
+ (tmp_path / "initScript.py").write_text("print('mine')\n")
689
+ initscript.update(tmp_path)
690
+ initscript.update(tmp_path, remove=True)
691
+ assert "mine" in (tmp_path / "initScript.py").read_text()