fontlab-python-instamix 1.0.0__tar.gz → 1.0.1__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.
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/CHANGELOG.md +10 -1
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/PKG-INFO +24 -23
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/README.md +23 -22
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/pyproject.toml +1 -1
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/__version__.py +2 -2
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/bootstrap.py +401 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/cli.py +12 -1
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/dest.py +5 -1
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/distinfo.py +79 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/extension.py +38 -1
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/initscript.py +68 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/launch.py +29 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/launchers.py +63 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/legacy.py +228 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/markers.py +174 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/stub.py +26 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/stub_install.vfpy +39 -0
- fontlab_python_instamix-1.0.1/src/fontlab_instamix/vcs.py +80 -0
- fontlab_python_instamix-1.0.1/stub/install.vfpy +39 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_bootstrap_cli.py +2 -2
- fontlab_python_instamix-1.0.1/tests/test_parity.py +677 -0
- fontlab_python_instamix-1.0.0/src/fontlab_instamix/bootstrap.py +0 -187
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/.gitignore +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/LICENSE +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/PLAN.md +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/build.sh +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/examples/com.example.hello.fontlabext/encoding/hello.enc +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/examples/com.example.hello.fontlabext/manifest.fontlabextj +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/examples/com.example.hello.fontlabext/scripts/Hello.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/install.vfpy +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/publish.sh +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/__init__.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/__main__.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/env.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/gui.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/ledger.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/manifest.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/packages.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/platformdirs.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/uv.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/venv.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/wrap.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/test.sh +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/conftest.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_dest.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_env.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_extension.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_manifest.py +0 -0
- {fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/tests/test_packages.py +0 -0
|
@@ -3,7 +3,16 @@ this_file: CHANGELOG.md
|
|
|
3
3
|
---
|
|
4
4
|
# Changelog
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## 1.0.1 (2026-11-16)
|
|
7
|
+
|
|
8
|
+
- 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`).
|
|
9
|
+
- `fontlab-instamix stub DIR [--force]` writes the standard 40-line `install.vfpy` (`stub/install.vfpy`). It finds instamix installed, in a sibling checkout or as a sha256-checked PyPI wheel.
|
|
10
|
+
- Breaking: top-level `Scripts/` now installs into FontLab's `Scripts/` (not `Scripts/<id>/`), as the legacy installers did.
|
|
11
|
+
- Top-level README, LICENSE, CHANGELOG and `.md` files in `Scripts/` are not installed into FontLab's Scripts root.
|
|
12
|
+
- The stub uses an installed instamix only if it has `fontlab_instamix.legacy`; otherwise it falls back to a sibling checkout or PyPI.
|
|
13
|
+
- 140 offline pytest tests; not yet tested inside FontLab.
|
|
14
|
+
|
|
15
|
+
## 1.0.0 (2026-11-16)
|
|
7
16
|
|
|
8
17
|
- New package `fontlab-python-instamix` (import `fontlab_instamix`), stdlib only, Python 3.11+.
|
|
9
18
|
- Data folder resolution (`--data-dir`, `FONTLAB_DATA_DIR`, `flPreferences().dataPathDefault`, platform fallback) with a vendored platformdirs subset.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fontlab-python-instamix
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
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
|
|
@@ -91,25 +91,14 @@ Unknown manifest keys are errors, except `this_file`.
|
|
|
91
91
|
|
|
92
92
|
See `examples/com.example.hello.fontlabext`.
|
|
93
93
|
|
|
94
|
-
##
|
|
94
|
+
## Stub install.vfpy for other projects
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
If instamix is not installed yet, FontLab raises `ModuleNotFoundError:
|
|
103
|
-
fontlab_instamix`. Get it by opening `fontlab-python-instamix/install.vfpy` in
|
|
104
|
-
FontLab once. To also work from a sibling checkout, replace the first line with:
|
|
105
|
-
|
|
106
|
-
```python
|
|
107
|
-
try: import fontlab_instamix.bootstrap as b
|
|
108
|
-
except ImportError:
|
|
109
|
-
import sys, pathlib; sys.path.append(str(pathlib.Path(__file__).resolve().parents[1] / "fontlab-python-instamix" / "src"))
|
|
110
|
-
try: import fontlab_instamix.bootstrap as b
|
|
111
|
-
except ImportError: raise SystemExit("fontlab-instamix missing: open fontlab-python-instamix/install.vfpy in FontLab first")
|
|
112
|
-
```
|
|
96
|
+
`fontlab-instamix stub DIR` writes the standard 40-line `install.vfpy` into a
|
|
97
|
+
project folder (`--force` replaces an existing one; the template is
|
|
98
|
+
`stub/install.vfpy`). When opened in FontLab it gets instamix in this order:
|
|
99
|
+
an installed copy, a sibling `../fontlab-python-instamix` checkout copied into
|
|
100
|
+
site-packages, or the PyPI wheel (sha256 checked, only `fontlab_instamix/`
|
|
101
|
+
extracted). Then it calls `bootstrap.install_project(__file__)`.
|
|
113
102
|
|
|
114
103
|
`install_project` reads `[tool.fontlab-install]`:
|
|
115
104
|
|
|
@@ -117,12 +106,24 @@ except ImportError:
|
|
|
117
106
|
[tool.fontlab-install]
|
|
118
107
|
id = "com.example.tool" # required, reverse-DNS
|
|
119
108
|
name = "Tool"
|
|
120
|
-
packages = ["src/tool"] #
|
|
121
|
-
scripts = ["
|
|
122
|
-
extensions = "Extensions" # .fontlabext folders
|
|
123
|
-
dependencies = ["fontlab-fly>=1"] #
|
|
109
|
+
packages = ["src/tool"] # default: [tool.hatch.build.targets.wheel] packages
|
|
110
|
+
scripts = ["tools/Extra"] # top-level Scripts/ is always included
|
|
111
|
+
extensions = "Extensions" # .fontlabext folders and <kind>/<Name>.fontlab<Kind> bundles
|
|
112
|
+
dependencies = ["fontlab-fly>=1"] # default: [project] dependencies
|
|
113
|
+
init-script = false # default: true only for com.fontlab.fontlabapp
|
|
124
114
|
```
|
|
125
115
|
|
|
116
|
+
It matches the legacy `install.vfpy`:
|
|
117
|
+
|
|
118
|
+
- Top-level `Scripts/` maps onto FontLab's `Scripts/`; other listed folders map to `Scripts/<path>`. `__pycache__`, `*.pyc`, `*.vfpyc` and `.DS_Store` are skipped.
|
|
119
|
+
- Bundles go to `Extensions/<kind>/<Name>.fontlab<Kind>`.
|
|
120
|
+
- Dependency markers are evaluated for FontLab's Python 3.11 on the host OS. Specs that do not apply are skipped; `METADATA` keeps all of them.
|
|
121
|
+
- The version comes from the static `[project].version`, then the hatch-vcs version file, `PKG-INFO`, `git describe` and the fallback version.
|
|
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
|
+
- `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.
|
|
125
|
+
- 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
|
+
|
|
126
127
|
## Development
|
|
127
128
|
|
|
128
129
|
```sh
|
|
@@ -79,25 +79,14 @@ Unknown manifest keys are errors, except `this_file`.
|
|
|
79
79
|
|
|
80
80
|
See `examples/com.example.hello.fontlabext`.
|
|
81
81
|
|
|
82
|
-
##
|
|
82
|
+
## Stub install.vfpy for other projects
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
If instamix is not installed yet, FontLab raises `ModuleNotFoundError:
|
|
91
|
-
fontlab_instamix`. Get it by opening `fontlab-python-instamix/install.vfpy` in
|
|
92
|
-
FontLab once. To also work from a sibling checkout, replace the first line with:
|
|
93
|
-
|
|
94
|
-
```python
|
|
95
|
-
try: import fontlab_instamix.bootstrap as b
|
|
96
|
-
except ImportError:
|
|
97
|
-
import sys, pathlib; sys.path.append(str(pathlib.Path(__file__).resolve().parents[1] / "fontlab-python-instamix" / "src"))
|
|
98
|
-
try: import fontlab_instamix.bootstrap as b
|
|
99
|
-
except ImportError: raise SystemExit("fontlab-instamix missing: open fontlab-python-instamix/install.vfpy in FontLab first")
|
|
100
|
-
```
|
|
84
|
+
`fontlab-instamix stub DIR` writes the standard 40-line `install.vfpy` into a
|
|
85
|
+
project folder (`--force` replaces an existing one; the template is
|
|
86
|
+
`stub/install.vfpy`). When opened in FontLab it gets instamix in this order:
|
|
87
|
+
an installed copy, a sibling `../fontlab-python-instamix` checkout copied into
|
|
88
|
+
site-packages, or the PyPI wheel (sha256 checked, only `fontlab_instamix/`
|
|
89
|
+
extracted). Then it calls `bootstrap.install_project(__file__)`.
|
|
101
90
|
|
|
102
91
|
`install_project` reads `[tool.fontlab-install]`:
|
|
103
92
|
|
|
@@ -105,12 +94,24 @@ except ImportError:
|
|
|
105
94
|
[tool.fontlab-install]
|
|
106
95
|
id = "com.example.tool" # required, reverse-DNS
|
|
107
96
|
name = "Tool"
|
|
108
|
-
packages = ["src/tool"] #
|
|
109
|
-
scripts = ["
|
|
110
|
-
extensions = "Extensions" # .fontlabext folders
|
|
111
|
-
dependencies = ["fontlab-fly>=1"] #
|
|
97
|
+
packages = ["src/tool"] # default: [tool.hatch.build.targets.wheel] packages
|
|
98
|
+
scripts = ["tools/Extra"] # top-level Scripts/ is always included
|
|
99
|
+
extensions = "Extensions" # .fontlabext folders and <kind>/<Name>.fontlab<Kind> bundles
|
|
100
|
+
dependencies = ["fontlab-fly>=1"] # default: [project] dependencies
|
|
101
|
+
init-script = false # default: true only for com.fontlab.fontlabapp
|
|
112
102
|
```
|
|
113
103
|
|
|
104
|
+
It matches the legacy `install.vfpy`:
|
|
105
|
+
|
|
106
|
+
- Top-level `Scripts/` maps onto FontLab's `Scripts/`; other listed folders map to `Scripts/<path>`. `__pycache__`, `*.pyc`, `*.vfpyc` and `.DS_Store` are skipped.
|
|
107
|
+
- Bundles go to `Extensions/<kind>/<Name>.fontlab<Kind>`.
|
|
108
|
+
- Dependency markers are evaluated for FontLab's Python 3.11 on the host OS. Specs that do not apply are skipped; `METADATA` keeps all of them.
|
|
109
|
+
- The version comes from the static `[project].version`, then the hatch-vcs version file, `PKG-INFO`, `git describe` and the fallback version.
|
|
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
|
+
- `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.
|
|
113
|
+
- 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
|
+
|
|
114
115
|
## Development
|
|
115
116
|
|
|
116
117
|
```sh
|
|
@@ -26,7 +26,7 @@ version-file = "src/fontlab_instamix/__version__.py"
|
|
|
26
26
|
[tool.hatch.build.targets.wheel]
|
|
27
27
|
packages = ["src/fontlab_instamix"]
|
|
28
28
|
[tool.hatch.build.targets.sdist]
|
|
29
|
-
only-include = ["src", "tests", "examples", "install.vfpy", "pyproject.toml", "README.md", "PLAN.md", "LICENSE", "CHANGELOG.md", "test.sh", "build.sh", "publish.sh"]
|
|
29
|
+
only-include = ["src", "tests", "examples", "install.vfpy", "stub", "pyproject.toml", "README.md", "PLAN.md", "LICENSE", "CHANGELOG.md", "test.sh", "build.sh", "publish.sh"]
|
|
30
30
|
[tool.pytest.ini_options]
|
|
31
31
|
testpaths = ["tests"]
|
|
32
32
|
pythonpath = ["src"]
|
{fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/__version__.py
RENAMED
|
@@ -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.
|
|
22
|
-
__version_tuple__ = version_tuple = (1, 0,
|
|
21
|
+
__version__ = version = '1.0.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 0, 1)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# this_file: src/fontlab_instamix/bootstrap.py
|
|
2
|
+
"""Install a project checkout into FontLab from its ``install.vfpy``.
|
|
3
|
+
|
|
4
|
+
A project's ``install.vfpy`` needs two lines::
|
|
5
|
+
|
|
6
|
+
import fontlab_instamix.bootstrap as b
|
|
7
|
+
b.install_project(__file__)
|
|
8
|
+
|
|
9
|
+
It reads ``[tool.fontlab-install]`` from the project's ``pyproject.toml``
|
|
10
|
+
(keys: ``id``, ``name``, ``packages``, ``scripts``, ``extensions``,
|
|
11
|
+
``dependencies``, ``init-script``) and turns it into a ``.fontlabext``
|
|
12
|
+
installed by :mod:`fontlab_instamix.extension`, so the ledger and uninstall
|
|
13
|
+
are shared. Like the legacy ``install.vfpy`` it replaces, it removes an
|
|
14
|
+
earlier legacy install first, writes a ``.dist-info``, maps the top-level
|
|
15
|
+
``Scripts/`` onto FontLab's Scripts and ``Extensions/<kind>/`` bundles onto
|
|
16
|
+
FontLab's Extensions, and adds the FontApp startup block when asked.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
import shutil
|
|
24
|
+
import tempfile
|
|
25
|
+
import tomllib
|
|
26
|
+
from dataclasses import dataclass, field
|
|
27
|
+
from pathlib import Path, PurePosixPath
|
|
28
|
+
|
|
29
|
+
from . import (
|
|
30
|
+
distinfo,
|
|
31
|
+
env,
|
|
32
|
+
extension,
|
|
33
|
+
initscript,
|
|
34
|
+
launchers,
|
|
35
|
+
ledger,
|
|
36
|
+
legacy,
|
|
37
|
+
manifest,
|
|
38
|
+
markers,
|
|
39
|
+
vcs,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
DEFAULT_SCRIPTS = "Scripts"
|
|
43
|
+
DOCS_PREFIXES = (
|
|
44
|
+
"readme",
|
|
45
|
+
"license",
|
|
46
|
+
"licence",
|
|
47
|
+
"changelog",
|
|
48
|
+
) # top-level Scripts docs stay out
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class BootstrapError(RuntimeError):
|
|
52
|
+
"""The project has no usable ``[tool.fontlab-install]`` table."""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class Project:
|
|
57
|
+
root: Path
|
|
58
|
+
id: str
|
|
59
|
+
name: str
|
|
60
|
+
version: str
|
|
61
|
+
packages: tuple[str, ...] = ()
|
|
62
|
+
scripts: tuple[str, ...] = ()
|
|
63
|
+
extensions: str = ""
|
|
64
|
+
dependencies: tuple[str, ...] = ()
|
|
65
|
+
extras: dict = field(default_factory=dict)
|
|
66
|
+
init_script: bool = False
|
|
67
|
+
extra: dict = field(default_factory=dict)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _list(value, key: str) -> tuple[str, ...]:
|
|
71
|
+
if value is None:
|
|
72
|
+
return ()
|
|
73
|
+
if isinstance(value, str):
|
|
74
|
+
return (value,)
|
|
75
|
+
if isinstance(value, list) and all(isinstance(v, str) for v in value):
|
|
76
|
+
return tuple(value)
|
|
77
|
+
raise BootstrapError(
|
|
78
|
+
f"[tool.fontlab-install] {key} must be a string or list of strings"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def find_root(start: Path) -> Path:
|
|
83
|
+
"""Folder holding ``pyproject.toml`` at or above ``start``."""
|
|
84
|
+
start = Path(start).resolve()
|
|
85
|
+
for folder in (start, *start.parents) if start.is_dir() else start.parents:
|
|
86
|
+
if (folder / "pyproject.toml").is_file():
|
|
87
|
+
return folder
|
|
88
|
+
raise BootstrapError(f"no pyproject.toml at or above {start}")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def read_project(start: Path) -> Project:
|
|
92
|
+
"""Parse ``[tool.fontlab-install]`` from the nearest ``pyproject.toml``."""
|
|
93
|
+
root = find_root(start)
|
|
94
|
+
data = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
|
|
95
|
+
table = data.get("tool", {}).get("fontlab-install")
|
|
96
|
+
if not isinstance(table, dict):
|
|
97
|
+
raise BootstrapError(
|
|
98
|
+
f"{root / 'pyproject.toml'} has no [tool.fontlab-install] table"
|
|
99
|
+
)
|
|
100
|
+
ext_id = table.get("id")
|
|
101
|
+
if not isinstance(ext_id, str) or not manifest.ID_PATTERN.match(ext_id):
|
|
102
|
+
raise BootstrapError(
|
|
103
|
+
"[tool.fontlab-install] id must be a reverse-DNS id like com.example.tool"
|
|
104
|
+
)
|
|
105
|
+
project = data.get("project", {})
|
|
106
|
+
extensions = table.get("extensions", "")
|
|
107
|
+
if not isinstance(extensions, str):
|
|
108
|
+
raise BootstrapError("[tool.fontlab-install] extensions must be a folder name")
|
|
109
|
+
init = table.get("init-script", ext_id == initscript.APP_ID)
|
|
110
|
+
if not isinstance(init, bool):
|
|
111
|
+
raise BootstrapError("[tool.fontlab-install] init-script must be true or false")
|
|
112
|
+
known = {
|
|
113
|
+
"id",
|
|
114
|
+
"name",
|
|
115
|
+
"packages",
|
|
116
|
+
"scripts",
|
|
117
|
+
"extensions",
|
|
118
|
+
"dependencies",
|
|
119
|
+
"init-script",
|
|
120
|
+
}
|
|
121
|
+
return Project(
|
|
122
|
+
root=root,
|
|
123
|
+
id=ext_id,
|
|
124
|
+
name=str(table.get("name") or project.get("name") or ext_id),
|
|
125
|
+
version=vcs.project_version(root, data),
|
|
126
|
+
packages=_packages(table, data),
|
|
127
|
+
scripts=_scripts(root, table),
|
|
128
|
+
extensions=extensions,
|
|
129
|
+
dependencies=_list(
|
|
130
|
+
table.get("dependencies", project.get("dependencies")), "dependencies"
|
|
131
|
+
),
|
|
132
|
+
extras=_extras(project),
|
|
133
|
+
init_script=init,
|
|
134
|
+
extra={k: v for k, v in table.items() if k not in known},
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _packages(table: dict, data: dict) -> tuple[str, ...]:
|
|
139
|
+
"""Listed packages, else the hatch wheel packages (as the legacy installer did)."""
|
|
140
|
+
if "packages" in table:
|
|
141
|
+
return _list(table["packages"], "packages")
|
|
142
|
+
wheel = (
|
|
143
|
+
data.get("tool", {})
|
|
144
|
+
.get("hatch", {})
|
|
145
|
+
.get("build", {})
|
|
146
|
+
.get("targets", {})
|
|
147
|
+
.get("wheel", {})
|
|
148
|
+
)
|
|
149
|
+
return _list(wheel.get("packages"), "packages")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _scripts(root: Path, table: dict) -> tuple[str, ...]:
|
|
153
|
+
"""The top-level ``Scripts`` folder (exact case) plus the listed folders."""
|
|
154
|
+
listed = [
|
|
155
|
+
s.replace("\\", "/").strip("/") for s in _list(table.get("scripts"), "scripts")
|
|
156
|
+
]
|
|
157
|
+
top = (
|
|
158
|
+
[DEFAULT_SCRIPTS]
|
|
159
|
+
if DEFAULT_SCRIPTS in os.listdir(root) and (root / DEFAULT_SCRIPTS).is_dir()
|
|
160
|
+
else []
|
|
161
|
+
)
|
|
162
|
+
return tuple(dict.fromkeys(top + listed))
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _extras(project: dict) -> dict[str, list[str]]:
|
|
166
|
+
extras = project.get("optional-dependencies", {})
|
|
167
|
+
if not isinstance(extras, dict):
|
|
168
|
+
raise BootstrapError("[project.optional-dependencies] must be a table")
|
|
169
|
+
return {
|
|
170
|
+
key: list(_list(value, f"optional-dependencies.{key}"))
|
|
171
|
+
for key, value in extras.items()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _script_rules(root: Path, folder: str) -> list[dict]:
|
|
176
|
+
"""Rules for one Scripts folder. The top-level ``Scripts`` maps child by
|
|
177
|
+
child, skipping README/LICENSE/Markdown docs that would collide in
|
|
178
|
+
FontLab's shared Scripts root; their subfolders still install whole."""
|
|
179
|
+
if folder != DEFAULT_SCRIPTS:
|
|
180
|
+
return [{"from": folder, "to": f"Scripts/{folder}"}]
|
|
181
|
+
rules = []
|
|
182
|
+
for child in sorted((root / folder).iterdir()):
|
|
183
|
+
lowered = child.name.lower()
|
|
184
|
+
if extension._junk(Path(child.name)) or (
|
|
185
|
+
child.is_file() and lowered.startswith(DOCS_PREFIXES)
|
|
186
|
+
):
|
|
187
|
+
continue
|
|
188
|
+
if child.is_file() and lowered.endswith(".md"):
|
|
189
|
+
continue
|
|
190
|
+
to = f"Scripts/{child.name}" if child.is_dir() else "Scripts"
|
|
191
|
+
rules.append({"from": f"{folder}/{child.name}", "to": to})
|
|
192
|
+
return rules
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def manifest_data(project: Project) -> dict:
|
|
196
|
+
"""Manifest describing the project checkout as an extension.
|
|
197
|
+
|
|
198
|
+
The top-level ``Scripts`` folder maps onto FontLab's Scripts; any other
|
|
199
|
+
listed folder maps onto ``Scripts/<folder>``. Plugin bundles below
|
|
200
|
+
``<extensions>/<kind>/`` map onto FontLab's ``Extensions/<kind>/``.
|
|
201
|
+
"""
|
|
202
|
+
rules = [rule for f in project.scripts for rule in _script_rules(project.root, f)]
|
|
203
|
+
rules += [
|
|
204
|
+
{"from": rel, "to": "Extensions/" + "/".join(PurePosixPath(rel).parts[-2:])}
|
|
205
|
+
for rel in bundles(project)
|
|
206
|
+
]
|
|
207
|
+
for package in project.packages:
|
|
208
|
+
if not (project.root / package).is_dir():
|
|
209
|
+
raise BootstrapError(
|
|
210
|
+
f"package folder {package!r} not found in {project.root}"
|
|
211
|
+
)
|
|
212
|
+
data = {
|
|
213
|
+
"id": project.id,
|
|
214
|
+
"name": project.name,
|
|
215
|
+
"version": project.version,
|
|
216
|
+
"python": {"packages": list(project.packages), "requires": []},
|
|
217
|
+
"install": rules,
|
|
218
|
+
}
|
|
219
|
+
manifest.parse(data)
|
|
220
|
+
return data
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def bundles(project: Project) -> list[str]:
|
|
224
|
+
"""``<extensions>/<kind>/<Name>.fontlab<Kind>`` folders that hold a ``plugin.json``."""
|
|
225
|
+
if not project.extensions or not (project.root / project.extensions).is_dir():
|
|
226
|
+
return []
|
|
227
|
+
found = []
|
|
228
|
+
for kind in sorted((project.root / project.extensions).iterdir()):
|
|
229
|
+
for bundle in sorted(kind.iterdir()) if kind.is_dir() else []:
|
|
230
|
+
if (
|
|
231
|
+
bundle.is_dir()
|
|
232
|
+
and ".fontlab" in bundle.suffix
|
|
233
|
+
and (bundle / "plugin.json").is_file()
|
|
234
|
+
):
|
|
235
|
+
found.append(bundle.relative_to(project.root).as_posix())
|
|
236
|
+
return found
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def sibling_dependencies(project: Project) -> tuple[list[Path], list[str]]:
|
|
240
|
+
"""Split dependencies into sibling checkouts (with install.vfpy) and uv specs.
|
|
241
|
+
|
|
242
|
+
Dependencies whose environment marker does not apply to FontLab's
|
|
243
|
+
Python are skipped.
|
|
244
|
+
"""
|
|
245
|
+
siblings, specs = [], []
|
|
246
|
+
for spec in project.dependencies:
|
|
247
|
+
if not markers.applies(spec):
|
|
248
|
+
continue
|
|
249
|
+
name = markers.split(spec)[0]
|
|
250
|
+
for sep in "<>=!~[ (@":
|
|
251
|
+
name = name.split(sep)[0]
|
|
252
|
+
sibling = _sibling(project.root.parent, name.strip())
|
|
253
|
+
if sibling:
|
|
254
|
+
siblings.append(sibling)
|
|
255
|
+
else:
|
|
256
|
+
specs.append(spec)
|
|
257
|
+
return siblings, specs
|
|
258
|
+
|
|
259
|
+
|
|
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
|
+
):
|
|
270
|
+
return folder
|
|
271
|
+
return None
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def install_project(
|
|
275
|
+
start,
|
|
276
|
+
data: Path | None = None,
|
|
277
|
+
*,
|
|
278
|
+
copy: bool | None = None,
|
|
279
|
+
requirements=None,
|
|
280
|
+
_seen: set | None = None,
|
|
281
|
+
) -> list[dict]:
|
|
282
|
+
"""Install the project around ``start`` (usually ``__file__``).
|
|
283
|
+
|
|
284
|
+
Packages are linked from the checkout (an editable install), scripts are
|
|
285
|
+
linked into FontLab's Scripts, sibling dependency checkouts are installed
|
|
286
|
+
first, other dependencies go through uv. A legacy ``install.vfpy``
|
|
287
|
+
install of the same id is removed first. Returns the ledger records.
|
|
288
|
+
"""
|
|
289
|
+
data = env.data_dir(data)
|
|
290
|
+
project = read_project(Path(start))
|
|
291
|
+
seen = _seen if _seen is not None else set()
|
|
292
|
+
if project.root in seen:
|
|
293
|
+
return []
|
|
294
|
+
seen.add(project.root)
|
|
295
|
+
records: list[dict] = []
|
|
296
|
+
siblings, specs = sibling_dependencies(project)
|
|
297
|
+
for sibling in siblings:
|
|
298
|
+
records += install_project(
|
|
299
|
+
sibling, data, copy=copy, requirements=requirements, _seen=seen
|
|
300
|
+
)
|
|
301
|
+
data_manifest = manifest_data(project)
|
|
302
|
+
data_manifest["python"]["requires"] = specs
|
|
303
|
+
records.append(_install_checkout(project, data_manifest, data, copy, requirements))
|
|
304
|
+
launchers.write_list(data)
|
|
305
|
+
if project.extensions and (project.root / project.extensions).is_dir():
|
|
306
|
+
for folder in sorted((project.root / project.extensions).rglob("*")):
|
|
307
|
+
nested = any(
|
|
308
|
+
extension.is_ext(part)
|
|
309
|
+
for part in folder.relative_to(project.root).parts[:-1]
|
|
310
|
+
)
|
|
311
|
+
if folder.is_dir() and extension.is_ext(folder.name) and not nested:
|
|
312
|
+
records += extension.install(
|
|
313
|
+
folder, data, copy=copy, requirements=requirements
|
|
314
|
+
)
|
|
315
|
+
return records
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _install_checkout(
|
|
319
|
+
project: Project, data_manifest: dict, data: Path, copy, requirements
|
|
320
|
+
) -> dict:
|
|
321
|
+
"""Install the checkout through a tiny generated ``.fontlabext`` of links."""
|
|
322
|
+
with tempfile.TemporaryDirectory(prefix="instamix-project-") as temp:
|
|
323
|
+
folder = Path(temp) / f"{project.id}.fontlabext"
|
|
324
|
+
folder.mkdir()
|
|
325
|
+
copied = False
|
|
326
|
+
for rel in [r["from"] for r in data_manifest["install"]] + data_manifest[
|
|
327
|
+
"python"
|
|
328
|
+
]["packages"]:
|
|
329
|
+
copied = _mirror(project.root / rel, folder / rel) or copied
|
|
330
|
+
(folder / manifest.MANIFEST).write_text(
|
|
331
|
+
json.dumps(data_manifest), encoding="utf-8"
|
|
332
|
+
)
|
|
333
|
+
migrated = migrate_legacy(project, folder, data)
|
|
334
|
+
# Files copied into the temp folder vanish afterwards, so never link to them.
|
|
335
|
+
copy = True if copied else copy
|
|
336
|
+
record = _install_after_migration(
|
|
337
|
+
migrated,
|
|
338
|
+
project.id,
|
|
339
|
+
lambda: extension.install_folder(
|
|
340
|
+
folder,
|
|
341
|
+
data,
|
|
342
|
+
copy=copy,
|
|
343
|
+
requirements=requirements,
|
|
344
|
+
editable=True,
|
|
345
|
+
finish=lambda target: _finish(project, data_manifest, target),
|
|
346
|
+
fields={"init_script": True} if project.init_script else None,
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
if project.init_script:
|
|
350
|
+
initscript.update(data)
|
|
351
|
+
return record
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _install_after_migration(migrated, ext_id: str, install):
|
|
355
|
+
"""Run *install*; after a legacy migration, say how to recover from a failure."""
|
|
356
|
+
try:
|
|
357
|
+
return install()
|
|
358
|
+
except Exception as exc:
|
|
359
|
+
if not migrated:
|
|
360
|
+
raise
|
|
361
|
+
raise BootstrapError(
|
|
362
|
+
f"The legacy install of {ext_id} was removed, but the new install failed: {exc}. Fix the cause and run install.vfpy again."
|
|
363
|
+
) from exc
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def _mirror(source: Path, target: Path) -> bool:
|
|
367
|
+
"""Link *source* at *target*; copy when links fail. Return True if copied."""
|
|
368
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
369
|
+
try:
|
|
370
|
+
target.symlink_to(source, target_is_directory=source.is_dir())
|
|
371
|
+
return False
|
|
372
|
+
except OSError: # Windows without symlink rights: copy (not live)
|
|
373
|
+
if source.is_dir():
|
|
374
|
+
shutil.copytree(source, target)
|
|
375
|
+
else:
|
|
376
|
+
shutil.copy2(source, target)
|
|
377
|
+
return True
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def migrate_legacy(project: Project, folder: Path, data: Path) -> dict | None:
|
|
381
|
+
"""Remove a legacy ``install.vfpy`` install of this project, if one is active."""
|
|
382
|
+
info = manifest.load(folder)
|
|
383
|
+
pairs = extension.plan(folder, info, extension.basename(folder), data)
|
|
384
|
+
files = [source for source, _ in pairs if source.is_file()]
|
|
385
|
+
known = {ledger.sha256(source.resolve()) for source in files}
|
|
386
|
+
targets = {target.relative_to(data).as_posix() for _, target in pairs}
|
|
387
|
+
site = env.site_packages(data).relative_to(data).as_posix()
|
|
388
|
+
targets |= {f"{site}/{distinfo.folder_name(project.name, project.version)}"}
|
|
389
|
+
return legacy.migrate(data, project.id, known, targets)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _finish(project: Project, data_manifest: dict, data: Path) -> list[Path]:
|
|
393
|
+
"""Write the dist-info and the uninstall launcher; return them, folders first."""
|
|
394
|
+
for old in distinfo.stale(data, project.name):
|
|
395
|
+
shutil.rmtree(old)
|
|
396
|
+
requires = list(project.dependencies)
|
|
397
|
+
packages = [Path(package).name for package in project.packages]
|
|
398
|
+
written = distinfo.write(
|
|
399
|
+
data, project.name, project.version, requires, project.extras, packages
|
|
400
|
+
)
|
|
401
|
+
return [written[0].parent, *written, *launchers.write_uninstaller(data, project.id)]
|
|
@@ -8,7 +8,7 @@ import json
|
|
|
8
8
|
import sys
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
-
from . import __version__, bootstrap, env, extension, packages, uv, venv, wrap
|
|
11
|
+
from . import __version__, bootstrap, env, extension, packages, stub, uv, venv, wrap
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _data(args) -> Path:
|
|
@@ -93,6 +93,12 @@ def cmd_venv(args) -> int:
|
|
|
93
93
|
return 0
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
def cmd_stub(args) -> int:
|
|
97
|
+
for folder in args.folders:
|
|
98
|
+
print(f"wrote {stub.write(Path(folder), force=args.force)}")
|
|
99
|
+
return 0
|
|
100
|
+
|
|
101
|
+
|
|
96
102
|
def parser() -> argparse.ArgumentParser:
|
|
97
103
|
p = argparse.ArgumentParser(prog="fontlab-instamix", description="Install extensions and packages into FontLab 9.")
|
|
98
104
|
p.add_argument("--version", action="version", version=__version__)
|
|
@@ -145,6 +151,11 @@ def parser() -> argparse.ArgumentParser:
|
|
|
145
151
|
s.set_defaults(func=cmd_uv_fetch)
|
|
146
152
|
|
|
147
153
|
sub.add_parser("venv", help="create <data>/.venv for Python 3.11").set_defaults(func=cmd_venv)
|
|
154
|
+
|
|
155
|
+
s = sub.add_parser("stub", help="write the instamix install.vfpy stub into repo folders")
|
|
156
|
+
s.add_argument("folders", nargs="+")
|
|
157
|
+
s.add_argument("--force", action="store_true", help="replace an existing install.vfpy")
|
|
158
|
+
s.set_defaults(func=cmd_stub)
|
|
148
159
|
return p
|
|
149
160
|
|
|
150
161
|
|
{fontlab_python_instamix-1.0.0 → fontlab_python_instamix-1.0.1}/src/fontlab_instamix/dest.py
RENAMED
|
@@ -13,7 +13,8 @@ from __future__ import annotations
|
|
|
13
13
|
import re
|
|
14
14
|
from pathlib import PurePosixPath
|
|
15
15
|
|
|
16
|
-
TARGETS = ("Scripts", "Actions", "Codepage", "Data", "Encoding", "site-packages")
|
|
16
|
+
TARGETS = ("Scripts", "Actions", "Codepage", "Data", "Encoding", "Extensions", "site-packages")
|
|
17
|
+
RESERVED = {"extensions": {".instamix", "library"}} # instamix's own folders
|
|
17
18
|
SITE_PACKAGES = "python/3.11/site-packages"
|
|
18
19
|
_VAR = re.compile(r"\{([^{}]*)\}")
|
|
19
20
|
|
|
@@ -68,4 +69,7 @@ def resolve(rule: str, basename: str, variables: dict[str, str] | None = None) -
|
|
|
68
69
|
if any("\\" in p or ":" in p for p in parts): # Windows separators or drives
|
|
69
70
|
raise DestError(f"destination parts may not contain '\\' or ':': {expanded!r}")
|
|
70
71
|
root = target_root(target_name(parts[0]))
|
|
72
|
+
reserved = RESERVED.get(root.lower())
|
|
73
|
+
if reserved is not None and (len(parts) < 2 or parts[1].lower() in reserved):
|
|
74
|
+
raise DestError(f"{root} needs a subfolder other than {', '.join(sorted(reserved))}: {rule!r}")
|
|
71
75
|
return str(PurePosixPath(root, *parts[1:]))
|