Package ttx-diff as a standalone PyPI package#1717
Conversation
Moved from resources/scripts/ttx_diff.py to ttx_diff/src/ttx_diff/core.py using 'git mv' to preserve commit history.
40900c1 to
64cff79
Compare
but keep building rust from source if within the fontc repo
- only runs when changes happen in ttx_diff/ directory - we only test Linux and Mac for now, 3.10 (min), 3.13 and 3.14. Those in between help themselves.
…ls pinned so we don't duplicate deps in both requirements.in and ttx_diff/pyproject.toml
64cff79 to
cf722dc
Compare
| }; | ||
| let mut cmd = format!( | ||
| "python3 resources/scripts/ttx_diff.py '{repo_url}{sha_part}#{}'", | ||
| "python3 -m ttx_diff '{repo_url}{sha_part}#{}'", |
There was a problem hiding this comment.
why not just ttx-diff, people should install it?
There was a problem hiding this comment.
i wanted to avoid fontc_crater falling into a trap of invoking a random ttx-diff on PATH. The previous code was calling python3 with the script path. This is the equivalent, to ensure it runs the ttx_diff installed within the same environment as python3 itself.
| cd fontc/ttx_diff | ||
| pip install -e . |
There was a problem hiding this comment.
nit: pip install -e ./fontc/ttx_diff/ saves a line?
There was a problem hiding this comment.
well usually one cd into a git repository they have just cloned. They may as well cd into the ttx_diff directory and do the canonical -e . for clarity's sake
|
amazing.. we haven't even merged this and pygit2 already broke us 🤣 |
34265eb to
989b0d2
Compare
This migrates ttx_diff.py from resources/scripts/ into a standalone Python package under ttx_diff/ that can be published to PyPI.
Making ttx-diff available as a standalone package enables easier installation for external users (pip install ttx-diff), better dependency management and reusability outside the fontc repository, e.g. to aid projects transitioning from fontmake to fontc.
The
ttx_diff/src/ttx_diff/core.pymodule is the same oldresources/scripts/ttx_diff.py(moved viagit mvto preserve git history), with additional logic to be able to run from anywhere (not just fontc repo root as it was currently). It also accepts pre-compilefontcandotl-normalizerbinaries via CLI flags, or falls back to searching in$PATHfor globally installed binaries.When running
ttx-diffscript from inside the fontc workspace, it will continue to automatically build fontc and otl-normalizer from source like it currently does, unless provided with explicit binary paths.The ttx-diff dependencies are now stored in its pyproject.toml but the old
requirements.inandrequirements.txtare kept, so fontc_crater runs use pinned versions and are reproducible.We can finally add tests to ttx-diff, no more excuses...
I added a new
python.ymlworkflow (to mimic the existingrust.ymlone) that tests ttx-diff on linux and mac (no windows 🤷 ) and on Python 3.10 (the minimum nowadays) up to 3.14 (but skipped a few in between because if it works on 3.10 and 3.14, really ought to work on 3.11...)The version is determined dynamically from git tags formatted as
ttx-diff-v*(it's a monorepo and we have other tags likefontc-v*). It works.