Skip to content

Commit

Permalink
Add a justfile recipe for running cog
Browse files Browse the repository at this point in the history
Closes #405
  • Loading branch information
brettcannon committed Jun 30, 2024
1 parent 077da0f commit 80fe531
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<!-- [[[cog
import cog
download_template = """
1. [Download `python_launcher-{version}-{platform}.tar.xz`](https://github.com/brettcannon/python-launcher/releases/download/{tag}/python_launcher-{version}-{platform}.tar.xz):
Expand All @@ -19,7 +21,7 @@ tar --extract --strip-components 1 --directory /usr/local --file python_launcher
def platform_download(platform):
instructions = download_template.format(tag=TAG, version=VERSION,
platform=platform)
print(instructions)
cog.outl(instructions)
]]] -->

Expand Down
11 changes: 9 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MAN_MD := join(ROOT, "man-page", "py.1.md")
MAN_FILE := join(ROOT, "man-page", "py.1")
CARGO_TOML := join(ROOT, "Cargo.toml")
VENV := join(ROOT, ".venv")
INSTALL_DOCS := join(ROOT, "docs", "install.md")

# Set default recipes
_default: lint test man docs
Expand Down Expand Up @@ -35,7 +36,6 @@ man: _man-md
import re
import tomllib

VERSION_REGEX = re.compile(r'version\s*=\s*"(?P<version>[\d.]+)"')

with open("{{ CARGO_TOML }}", "rb") as file:
cargo_data = tomllib.load(file)
Expand All @@ -60,6 +60,13 @@ man: _man-md
docs-lock:
pipx run --spec pip-tools pip-compile --generate-hashes --allow-unsafe -o docs/requirements.txt docs/requirements.in

# Update insfall instructions for a specific version
docs-install:
#!/usr/bin/env bash
set -euxo pipefail
version=`cargo run -- -m release version`
pipx run cogapp -D VERSION=${version} -D TAG=v${version} -r {{ INSTALL_DOCS }}
# Create a virtual environment for building the docs
docs-venv:
#!/usr/bin/env bash
Expand All @@ -75,5 +82,5 @@ docs-dev: docs-venv
cargo run -- -m mkdocs serve

# Build the documentation
docs: docs-venv
docs: docs-venv docs-install
cargo run -- -m mkdocs build
1 change: 0 additions & 1 deletion release/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
black
cogapp
tomli
2 changes: 1 addition & 1 deletion release/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def get_version():
"""Read the version from Cargo.toml."""
with CARGO_FILE.open("r", encoding="utf-8") as file:
with CARGO_FILE.open("rb") as file:
cargo_toml = tomllib.load(file)

return cargo_toml["package"]["version"]
Expand Down

0 comments on commit 80fe531

Please sign in to comment.