Skip to content

Commit

Permalink
Fix scripts to run under uv correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysyngsun committed Jan 8, 2025
1 parent de18dd0 commit 981cdae
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 54 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions build-support/bin/mitol/build_support/cli.py

This file was deleted.

12 changes: 0 additions & 12 deletions build-support/bin/mitol/build_support/commands/version.py

This file was deleted.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import toml

from mitol.build_support.contextlib import chdir
from scripts.contextlibs import chdir

SOURCE_PATH = "src/"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -146,3 +147,7 @@ def _is_excluded(path):

if is_error:
ctx.exit(1)


if __name__ == "__main__":
changelog()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -88,3 +89,7 @@ def push_to_remote(project: Project, app: App):
[app.version_git_tag, "HEAD"],
follow_tags=True,
)


if __name__ == "__main__":
release()
File renamed without changes.
23 changes: 23 additions & 0 deletions scripts/version.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 981cdae

Please sign in to comment.