diff --git a/README.md b/README.md index 1854378b..217533da 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ The `release` container is special and is set up to run `build` commands, includ **Using:** 1. Build the images, so the source code in the image is up to date: `docker compose build` 2. Get a shell: `docker compose run --rm -ti release bash` -3. Run your command: `uv run build release create etc. etc. etc.` +3. Run your command: `uv run scripts/release.py create` etc. etc. etc. 4. If you've done things that involve Git, make sure you `git pull` when you leave the session. ### Navigating this repository @@ -89,7 +89,7 @@ Run `uv run pytest`. This should run all the tests. If you want to run a specifi We maintain changelogs in `changelog.d/` directories with each app. To create a new changelog for your changes, run: -- `uv run build changelog create --app APPNAME` +- `uv run scripts/changelog.py create --app APPNAME` - `APPNAME`: the name of an application directory Note warning above about `PYTHONPATH`. You will need to adjust permissions/ownership on the new file if you're using the Compose setup. @@ -102,7 +102,7 @@ Changelogs are maintained according to [Keep a Changelog](https://keepachangelog Versioning uses a date-based versioning scheme with incremental builds on the same day. Version tags follow `{package-name}/v{version}` To perform a release, run: -- `uv run build release create --app APPNAME --push`: +- `uv run scripts/release.py create --app APPNAME --push`: - `APPNAME`: the name of an application directory `release` expects to be run on the `main` branch and it expects you to not have changes pending. diff --git a/build-support/bin/mitol/build_support/cli.py b/build-support/bin/mitol/build_support/cli.py deleted file mode 100644 index 003b811f..00000000 --- a/build-support/bin/mitol/build_support/cli.py +++ /dev/null @@ -1,21 +0,0 @@ -from cloup import Context, group, pass_context - -from mitol.build_support.commands.changelog import changelog -from mitol.build_support.commands.release import release -from mitol.build_support.commands.version import version -from mitol.build_support.project import Project - - -@group() -@pass_context -def cli(ctx: Context): - """CLI for build tools""" - ctx.ensure_object(Project) - - -cli.add_command(changelog) -cli.add_command(release) -cli.add_command(version) - -if __name__ == "__main__": - cli() diff --git a/build-support/bin/mitol/build_support/commands/version.py b/build-support/bin/mitol/build_support/commands/version.py deleted file mode 100644 index 50c9b41e..00000000 --- a/build-support/bin/mitol/build_support/commands/version.py +++ /dev/null @@ -1,12 +0,0 @@ -from bumpver import cli - -from mitol.build_support.decorators import app_option - -version = cli.cli -version.name = "version" - -grep = app_option(cli.grep) -init = app_option(cli.init) -show = app_option(cli.show) -test = cli.test # this doesn't require config so doesn't require --app -update = app_option(cli.update) diff --git a/pyproject.toml b/pyproject.toml index aa8ed5f3..2da673cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,9 +28,6 @@ requires-python = ">= 3.8" requires = ["hatchling"] build-backend = "hatchling.build" -[project.scripts] -build = "mitol.build_support.cli:cli" - [tool.uv] managed = true dev-dependencies = [ diff --git a/build-support/bin/mitol/__init__.py b/scripts/__init__.py similarity index 100% rename from build-support/bin/mitol/__init__.py rename to scripts/__init__.py diff --git a/build-support/bin/mitol/build_support/apps.py b/scripts/apps.py similarity index 96% rename from build-support/bin/mitol/build_support/apps.py rename to scripts/apps.py index 1855b39d..ed31586e 100644 --- a/build-support/bin/mitol/build_support/apps.py +++ b/scripts/apps.py @@ -7,7 +7,7 @@ import toml -from mitol.build_support.contextlib import chdir +from scripts.contextlibs import chdir SOURCE_PATH = "src/" diff --git a/build-support/bin/mitol/build_support/commands/changelog.py b/scripts/changelog.py similarity index 94% rename from build-support/bin/mitol/build_support/commands/changelog.py rename to scripts/changelog.py index 105d73b8..57678a47 100644 --- a/build-support/bin/mitol/build_support/commands/changelog.py +++ b/scripts/changelog.py @@ -10,16 +10,17 @@ from scriv.create import create from scriv.scriv import Scriv -from mitol.build_support.apps import App, list_apps -from mitol.build_support.contextlib import chdir -from mitol.build_support.decorators import app_option, pass_app, pass_project -from mitol.build_support.project import Project +from scripts.apps import App, list_apps +from scripts.contextlibs import chdir +from scripts.decorators import app_option, pass_app, pass_project +from scripts.project import Project @group("changelog") @pass_context -def changelog(ctx): # noqa: ARG001 +def changelog(ctx): """Manage application changelogs""" + ctx.ensure_object(Project) makedirs("changelog.d", exist_ok=True) # noqa: PTH103 @@ -146,3 +147,7 @@ def _is_excluded(path): if is_error: ctx.exit(1) + + +if __name__ == "__main__": + changelog() diff --git a/build-support/bin/mitol/build_support/contextlib.py b/scripts/contextlibs.py similarity index 100% rename from build-support/bin/mitol/build_support/contextlib.py rename to scripts/contextlibs.py diff --git a/build-support/bin/mitol/build_support/decorators.py b/scripts/decorators.py similarity index 95% rename from build-support/bin/mitol/build_support/decorators.py rename to scripts/decorators.py index 472bc25a..cbd5f7f2 100644 --- a/build-support/bin/mitol/build_support/decorators.py +++ b/scripts/decorators.py @@ -3,8 +3,8 @@ from click import Choice, Command, make_pass_decorator, option from cloup import Context, pass_context -from mitol.build_support.apps import App, list_app_names -from mitol.build_support.project import Project +from scripts.apps import App, list_app_names +from scripts.project import Project pass_project = make_pass_decorator(Project) pass_app = make_pass_decorator(App) diff --git a/build-support/bin/mitol/build_support/__init__.py b/scripts/mitol/__init__.py similarity index 100% rename from build-support/bin/mitol/build_support/__init__.py rename to scripts/mitol/__init__.py diff --git a/build-support/bin/mitol/build_support/commands/__init__.py b/scripts/mitol/build_support/__init__.py similarity index 100% rename from build-support/bin/mitol/build_support/commands/__init__.py rename to scripts/mitol/build_support/__init__.py diff --git a/build-support/bin/mitol/build_support/project.py b/scripts/project.py similarity index 100% rename from build-support/bin/mitol/build_support/project.py rename to scripts/project.py diff --git a/build-support/bin/mitol/build_support/commands/release.py b/scripts/release.py similarity index 87% rename from build-support/bin/mitol/build_support/commands/release.py rename to scripts/release.py index 4acd9868..7ec0f7f4 100644 --- a/build-support/bin/mitol/build_support/commands/release.py +++ b/scripts/release.py @@ -1,20 +1,21 @@ from click import echo, pass_context from cloup import Context, group, option -from mitol.build_support.apps import App -from mitol.build_support.commands import changelog, version -from mitol.build_support.decorators import ( +from scripts.apps import App +from scripts.commands import changelog, version +from scripts.decorators import ( app_option, no_require_main, pass_app, pass_project, ) -from mitol.build_support.project import Project +from scripts.project import Project @group() -def release(): - pass +@pass_context +def release(ctx: Context): + ctx.ensure_object(Project) @release.command() @@ -88,3 +89,7 @@ def push_to_remote(project: Project, app: App): [app.version_git_tag, "HEAD"], follow_tags=True, ) + + +if __name__ == "__main__": + release() diff --git a/build-support/scriv/entry_title.md.j2 b/scripts/scriv/entry_title.md.j2 similarity index 100% rename from build-support/scriv/entry_title.md.j2 rename to scripts/scriv/entry_title.md.j2 diff --git a/scripts/version.py b/scripts/version.py new file mode 100644 index 00000000..295a3a94 --- /dev/null +++ b/scripts/version.py @@ -0,0 +1,23 @@ +from bumpver import cli +from cloup import Context, pass_context + +from scripts.decorators import app_option +from scripts.project import Project + + +@pass_context +def version(ctx: Context): + """CLI for build tools""" + ctx.ensure_object(Project) + ctx.invoke(cli.cli, **ctx.params) + + +grep = app_option(cli.grep) +init = app_option(cli.init) +show = app_option(cli.show) +test = cli.test # this doesn't require config so doesn't require --app +update = app_option(cli.update) + + +if __name__ == "__main__": + version() diff --git a/uv.lock b/uv.lock index a6066c2e..93971ecf 100644 --- a/uv.lock +++ b/uv.lock @@ -1457,7 +1457,7 @@ requires-dist = [ [[package]] name = "mitol-django-mail" -version = "2023.12.19" +version = "2024.11.5" source = { editable = "src/mail" } dependencies = [ { name = "beautifulsoup4" }, @@ -1906,6 +1906,7 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ce/ac/5b1ea50fc08a9df82de7e1771537557f07c2632231bbab652c7e22597908/psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:bb89f0a835bcfc1d42ccd5f41f04870c1b936d8507c6df12b7737febc40f0909", size = 2822712 }, { url = "https://files.pythonhosted.org/packages/c4/fc/504d4503b2abc4570fac3ca56eb8fed5e437bf9c9ef13f36b6621db8ef00/psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f0c2d907a1e102526dd2986df638343388b94c33860ff3bbe1384130828714b1", size = 2920155 }, { url = "https://files.pythonhosted.org/packages/b2/d1/323581e9273ad2c0dbd1902f3fb50c441da86e894b6e25a73c3fda32c57e/psycopg2_binary-2.9.10-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f8157bed2f51db683f31306aa497311b560f2265998122abe1dce6428bd86567", size = 2959356 }, + { url = "https://files.pythonhosted.org/packages/08/50/d13ea0a054189ae1bc21af1d85b6f8bb9bbc5572991055d70ad9006fe2d6/psycopg2_binary-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:27422aa5f11fbcd9b18da48373eb67081243662f9b46e6fd07c3eb46e4535142", size = 2569224 }, { url = "https://files.pythonhosted.org/packages/03/a7/7aa45bea9c790da0ec4765902d714ee7c43b73ccff34916261090849b715/psycopg2_binary-2.9.10-cp38-cp38-macosx_12_0_x86_64.whl", hash = "sha256:eb09aa7f9cecb45027683bb55aebaaf45a0df8bf6de68801a6afdc7947bb09d4", size = 3043405 }, { url = "https://files.pythonhosted.org/packages/0e/ea/e0197035d74cc1065e94f2ebf7cdd9fa4aa00bb06b1850091568345441cd/psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b73d6d7f0ccdad7bc43e6d34273f70d587ef62f824d7261c4ae9b8b1b6af90e8", size = 2851210 }, { url = "https://files.pythonhosted.org/packages/23/bf/9be0b2dd105299860e6b001ad7519e36208944609c8382d5aa2dfc58294c/psycopg2_binary-2.9.10-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ce5ab4bf46a211a8e924d307c1b1fcda82368586a19d0a24f8ae166f5c784864", size = 3080972 },