Skip to content

Commit 3a46543

Browse files
feat(python): add installable shared tooling commands (#18)
1 parent da06f7f commit 3a46543

5 files changed

Lines changed: 127 additions & 6 deletions

File tree

.github/workflows/localize.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ jobs:
5858
run: |
5959
uv sync --project .lizardbyte-common --frozen --only-group locale \
6060
--python "${PYTHON_VERSION}" \
61-
--no-python-downloads \
62-
--no-install-project
61+
--no-python-downloads
6362
6463
- name: Set up xgettext
6564
run: |
@@ -87,7 +86,7 @@ jobs:
8786
echo "NEW_FILE=${new_file}" >> "${GITHUB_ENV}"
8887
8988
uv run --project .lizardbyte-common --frozen --only-group locale --no-sync \
90-
python .lizardbyte-common/scripts/localize.py --root-dir "${GITHUB_WORKSPACE}" --extract
89+
lb-localize --root-dir "${GITHUB_WORKSPACE}" --extract
9190
9291
- name: git diff
9392
if: env.NEW_FILE == 'false'

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,51 @@ uv sync --locked
2929
Run the clang-format helper:
3030

3131
```bash
32-
uv run --locked python scripts/update_clang_format.py
32+
uv run --locked --only-group c lb-update-clang-format
3333
```
3434

3535
Run gettext extraction:
3636

3737
```bash
38-
uv run --locked --only-group locale python scripts/localize.py --extract
38+
uv run --locked --only-group locale lb-localize --extract
39+
```
40+
41+
## Consuming Projects
42+
43+
Projects with a `pyproject.toml` can use this repository as a local path dependency. For a submodule at
44+
`third-party/lizardbyte-common`, add the dependency and source to the consuming project's `pyproject.toml`:
45+
46+
```toml
47+
[project]
48+
dependencies = [
49+
"lizardbyte-common[c]",
50+
]
51+
52+
[tool.uv.sources]
53+
lizardbyte-common = { path = "third-party/lizardbyte-common" }
54+
```
55+
56+
Then sync and run the installed commands from the consuming project root:
57+
58+
```bash
59+
uv sync --python 3.14
60+
uv run lb-update-clang-format
61+
uv run lb-localize --extract
62+
```
63+
64+
Projects without a `pyproject.toml` can still create a `.venv` in the consuming project root and install
65+
the local checkout into it:
66+
67+
```bash
68+
uv venv --python 3.14
69+
uv pip install --editable "third-party/lizardbyte-common[c]"
70+
```
71+
72+
Then run the commands from the consuming project root:
73+
74+
```bash
75+
lb-update-clang-format
76+
lb-localize --extract
3977
```
4078

4179
## Workflows

pyproject.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@ authors = [
1313
]
1414
dependencies = []
1515

16+
[project.scripts]
17+
lb-localize = "scripts.localize:main"
18+
lb-update-clang-format = "scripts.update_clang_format:main"
19+
20+
[project.optional-dependencies]
21+
dev = [
22+
"lizardbyte-common[c]",
23+
"lizardbyte-common[lint-python]",
24+
"lizardbyte-common[test-python]",
25+
]
26+
c = [
27+
"lizardbyte-common[lint-c]",
28+
"lizardbyte-common[locale]",
29+
"lizardbyte-common[test-c]",
30+
]
31+
lint-c = [
32+
"clang-format==21.1.8",
33+
"cmakelang==0.6.13",
34+
]
35+
lint-python = [
36+
"flake8==7.3.0",
37+
]
38+
locale = [
39+
"babel==2.18.0",
40+
]
41+
test-c = [
42+
"gcovr==8.6",
43+
]
44+
test-python = [
45+
"pytest==9.0.3",
46+
"pytest-cov==7.1.0",
47+
]
48+
1649
[dependency-groups]
1750
dev = [
1851
{include-group = "c"},
@@ -48,7 +81,7 @@ Repository = "https://github.com/LizardByte/lizardbyte-common"
4881
Issues = "https://github.com/LizardByte/lizardbyte-common/issues"
4982

5083
[tool.setuptools]
51-
py-modules = []
84+
packages = ["scripts"]
5285

5386
[tool.pytest.ini_options]
5487
testpaths = ["tests"]

scripts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Shared LizardByte command modules."""

uv.lock

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)