diff --git a/.github/workflows/localize.yml b/.github/workflows/localize.yml index fbb96f1..7fe31a7 100644 --- a/.github/workflows/localize.yml +++ b/.github/workflows/localize.yml @@ -58,8 +58,7 @@ jobs: run: | uv sync --project .lizardbyte-common --frozen --only-group locale \ --python "${PYTHON_VERSION}" \ - --no-python-downloads \ - --no-install-project + --no-python-downloads - name: Set up xgettext run: | @@ -87,7 +86,7 @@ jobs: echo "NEW_FILE=${new_file}" >> "${GITHUB_ENV}" uv run --project .lizardbyte-common --frozen --only-group locale --no-sync \ - python .lizardbyte-common/scripts/localize.py --root-dir "${GITHUB_WORKSPACE}" --extract + lb-localize --root-dir "${GITHUB_WORKSPACE}" --extract - name: git diff if: env.NEW_FILE == 'false' diff --git a/README.md b/README.md index a07fe43..728bc0b 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,51 @@ uv sync --locked Run the clang-format helper: ```bash -uv run --locked python scripts/update_clang_format.py +uv run --locked --only-group c lb-update-clang-format ``` Run gettext extraction: ```bash -uv run --locked --only-group locale python scripts/localize.py --extract +uv run --locked --only-group locale lb-localize --extract +``` + +## Consuming Projects + +Projects with a `pyproject.toml` can use this repository as a local path dependency. For a submodule at +`third-party/lizardbyte-common`, add the dependency and source to the consuming project's `pyproject.toml`: + +```toml +[project] +dependencies = [ + "lizardbyte-common[c]", +] + +[tool.uv.sources] +lizardbyte-common = { path = "third-party/lizardbyte-common" } +``` + +Then sync and run the installed commands from the consuming project root: + +```bash +uv sync --python 3.14 +uv run lb-update-clang-format +uv run lb-localize --extract +``` + +Projects without a `pyproject.toml` can still create a `.venv` in the consuming project root and install +the local checkout into it: + +```bash +uv venv --python 3.14 +uv pip install --editable "third-party/lizardbyte-common[c]" +``` + +Then run the commands from the consuming project root: + +```bash +lb-update-clang-format +lb-localize --extract ``` ## Workflows diff --git a/pyproject.toml b/pyproject.toml index c1e084b..6b74937 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,39 @@ authors = [ ] dependencies = [] +[project.scripts] +lb-localize = "scripts.localize:main" +lb-update-clang-format = "scripts.update_clang_format:main" + +[project.optional-dependencies] +dev = [ + "lizardbyte-common[c]", + "lizardbyte-common[lint-python]", + "lizardbyte-common[test-python]", +] +c = [ + "lizardbyte-common[lint-c]", + "lizardbyte-common[locale]", + "lizardbyte-common[test-c]", +] +lint-c = [ + "clang-format==21.1.8", + "cmakelang==0.6.13", +] +lint-python = [ + "flake8==7.3.0", +] +locale = [ + "babel==2.18.0", +] +test-c = [ + "gcovr==8.6", +] +test-python = [ + "pytest==9.0.3", + "pytest-cov==7.1.0", +] + [dependency-groups] dev = [ {include-group = "c"}, @@ -48,7 +81,7 @@ Repository = "https://github.com/LizardByte/lizardbyte-common" Issues = "https://github.com/LizardByte/lizardbyte-common/issues" [tool.setuptools] -py-modules = [] +packages = ["scripts"] [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..4f558a7 --- /dev/null +++ b/scripts/__init__.py @@ -0,0 +1 @@ +"""Shared LizardByte command modules.""" diff --git a/uv.lock b/uv.lock index 229aa6d..acea930 100644 --- a/uv.lock +++ b/uv.lock @@ -163,6 +163,40 @@ name = "lizardbyte-common" version = "0.0.0" source = { editable = "." } +[package.optional-dependencies] +c = [ + { name = "babel" }, + { name = "clang-format" }, + { name = "cmakelang" }, + { name = "gcovr" }, +] +dev = [ + { name = "babel" }, + { name = "clang-format" }, + { name = "cmakelang" }, + { name = "flake8" }, + { name = "gcovr" }, + { name = "pytest" }, + { name = "pytest-cov" }, +] +lint-c = [ + { name = "clang-format" }, + { name = "cmakelang" }, +] +lint-python = [ + { name = "flake8" }, +] +locale = [ + { name = "babel" }, +] +test-c = [ + { name = "gcovr" }, +] +test-python = [ + { name = "pytest" }, + { name = "pytest-cov" }, +] + [package.dev-dependencies] c = [ { name = "babel" }, @@ -198,6 +232,22 @@ test-python = [ ] [package.metadata] +requires-dist = [ + { name = "babel", marker = "extra == 'locale'", specifier = "==2.18.0" }, + { name = "clang-format", marker = "extra == 'lint-c'", specifier = "==21.1.8" }, + { name = "cmakelang", marker = "extra == 'lint-c'", specifier = "==0.6.13" }, + { name = "flake8", marker = "extra == 'lint-python'", specifier = "==7.3.0" }, + { name = "gcovr", marker = "extra == 'test-c'", specifier = "==8.6" }, + { name = "lizardbyte-common", extras = ["c"], marker = "extra == 'dev'" }, + { name = "lizardbyte-common", extras = ["lint-c"], marker = "extra == 'c'" }, + { name = "lizardbyte-common", extras = ["lint-python"], marker = "extra == 'dev'" }, + { name = "lizardbyte-common", extras = ["locale"], marker = "extra == 'c'" }, + { name = "lizardbyte-common", extras = ["test-c"], marker = "extra == 'c'" }, + { name = "lizardbyte-common", extras = ["test-python"], marker = "extra == 'dev'" }, + { name = "pytest", marker = "extra == 'test-python'", specifier = "==9.0.3" }, + { name = "pytest-cov", marker = "extra == 'test-python'", specifier = "==7.1.0" }, +] +provides-extras = ["dev", "c", "lint-c", "lint-python", "locale", "test-c", "test-python"] [package.metadata.requires-dev] c = [