This commit is contained in:
Waylon Walker 2025-11-22 21:48:11 -06:00
commit d7800f4d82
12 changed files with 378 additions and 0 deletions

155
README.md Normal file
View file

@ -0,0 +1,155 @@
# Just Build System
A modular build system using Just that supports container builds, Python tooling, and more.
## Installation
There are several ways to use this build system:
### Method 1: Global Installation with Symlinks
1. Clone this repository to a permanent location:
```bash
git clone https://github.com/yourusername/wjust ~/.wjust
```
2. In your project, create the module directories and symlink the justfiles:
```bash
# Create module directories
mkdir -p container python
# Create symlinks to the global justfiles
ln -s ~/.wjust/container/justfile container/justfile
ln -s ~/.wjust/python/justfile python/justfile
```
3. Create your project's `justfile`:
```makefile
# Import modules
mod container
mod python
# Override or add project-specific recipes here
default:
@just --list
```
4. Create required files:
```bash
# For container module
echo "registry.example.com/myproject" > container/name
# Optional: Set version
echo "0.1.0" > version
# Or use __about__.py with __version__ = "0.1.0"
```
### Method 2: Local Copy (Traditional)
Copy the entire module directories to your project:
```bash
cp -r ~/.wjust/container ~/.wjust/python .
```
Then create your `justfile` as shown above.
### Method 3: Remote Import (Advanced)
For advanced users who want to pull updates directly from the repository:
```bash
# Create a script to update modules
cat > update-just-modules.sh << 'EOF'
#!/bin/bash
REPO="https://raw.githubusercontent.com/yourusername/wjust/main"
mkdir -p {container,python}
curl -o container/justfile "$REPO/container/justfile"
curl -o python/justfile "$REPO/python/justfile"
EOF
chmod +x update-just-modules.sh
```
Then run `./update-just-modules.sh` whenever you want to update the modules.
## Quick Start
1. Choose an installation method from above
2. Run `just` to see available commands:
```bash
just
Available recipes:
container ... # Container management
python ... # Python tools
```
## Container Module
The container module provides standardized container building and deployment.
### Setup
1. Create a `container/name` file with your container registry path:
```
registry.example.com/myproject
```
2. Version will be detected from (in order):
- Any `__about__.py` file containing `__version__ = "x.y.z"`
- A `version` file in the project root
- Defaults to "0.0.0" if neither exists
3. Create your `container/Containerfile`:
```dockerfile
FROM python:3.11
# Add your container configuration
```
### Usage
```bash
# Show available commands
just
# Build container
just container build
# Push container to registry
just container deploy
```
### Customization
The container module provides these recipes:
- `build`: Builds the container with version tag
- `deploy`: Pushes the container to the registry
## Python Module
The Python module provides linting with Ruff.
### Usage
```bash
# Run linter
just python lint
# Run linter with auto-fix
just python lint-fix
```
## Adding New Modules
1. Create a new directory for your module
2. Add a `justfile` in the module directory
3. Import it in your root `justfile` with `mod mymodule`
## Environment Variables
- `VERSION`: Automatically set from `__about__.py` or `version` file
- `CONTAINER_NAME`: Set from `container/name` file
## Contributing
Feel free to submit issues and pull requests for additional modules or improvements.

13
container/Containerfile Normal file
View file

@ -0,0 +1,13 @@
FROM ubuntu:noble
ENV PATH="/root/.local/bin:$PATH"
ENV VIRTUAL_ENV="/opt/venv"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get update && apt-get install -y git curl
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
RUN uv python install 3.13
RUN uv venv $VIRTUAL_ENV
RUN uv pip install hatch
RUN curl https://i.wayl.one/casey/just | bash && mv just /usr/local/bin

68
container/justfile Normal file
View file

@ -0,0 +1,68 @@
# container management
set working-directory := '.'
set shell := ["bash", "-c"]
set quiet
# Read container name and version
container_name := `
cd $JUST_WORKING_DIRECTORY
if [[ -f container/name ]]; then cat container/name; else echo "NONAME"; fi
`
version := `
cd $JUST_WORKING_DIRECTORY
ABOUT_FILE=$(rg -l "__version__" --glob "**/__about__.py" 2>/dev/null | head -n 1) || true
if [[ -n "$ABOUT_FILE" ]] && [[ -f "$ABOUT_FILE" ]]; then
rg -oP "(?<=__version__ = ['\"])[^'\"]+" "$ABOUT_FILE"
elif [[ -f "version" ]]; then
cat version
else
echo "0.0.0"
fi
`
[group('container')]
[private]
@default: check
#!/usr/bin/env bash
cd $JUST_WORKING_DIRECTORY
echo $PWD
echo
echo {{BOLD}}just container{{NORMAL}}
echo {{MAGENTA}}{{container_name}}{{WHITE}}:{{GREEN}}{{version}}{{NORMAL}}
[group('container')]
[private]
check:
#!/usr/bin/env bash
cd $JUST_WORKING_DIRECTORY
[[ -f container/Containerfile ]] || echo "{{RED}}WARNING: {{NORMAL}}Containerfile not found"
# build the container
[group('container')]
build:
@echo "Building {{container_name}}:{{version}}"
@# @podman build \
@# -t {{container_name}}:{{version}} \
@# -f container/Containerfile .
# push the container
[group('container')]
@deploy:
@podman push {{container_name}}
@podman push {{container_name}}:{{version}}
# init container workflow
[no-cd]
[group('container')]
init:
#!/usr/bin/env bash
[[ -d container ]] || mkdir container
export project_name=$(basename $(pwd))
[[ -f version ]] || echo "version = '0.0.0'" > version
[[ -f container/name ]] || echo $project_name > container/name
[[ -f container/Containerfile ]] || echo "FROM ubuntu" > container/Containerfile

1
container/name Normal file
View file

@ -0,0 +1 @@
registry.wayl.one/wjust

1
container/repository Normal file
View file

@ -0,0 +1 @@
registry.wayl.one

62
justfile Normal file
View file

@ -0,0 +1,62 @@
# Main justfile
set shell := ["bash", "-uc"]
set quiet
set allow-duplicate-recipes := true
# wjust-dir := "~/.wjust"
wjust-dir := "~/git/wjust"
# container management commands, run `just container` to see all subcommands
mod container
# mod python
# mod container "{{wjust-dir}}/container/justfile"
# mod container "~/git/wjust/container/justfile"
# include "https://raw.githubusercontent.com/casey/just/refs/heads/master/justfile"
# include {{wjust-dir}}/container/justfile
[group('just')]
[private]
@default:
echo $PWD
@echo
@echo {{BOLD}}just{{NORMAL}}
@just --list
# @just container
# fuzzy picker
[group('just')]
f:
just --list | fzf | xargs just
pwd:
pwd
get-version:
#!/usr/bin/env bash
if [[ -f "version" ]]; then \
export PROJECT_VERSION=$(cat version); \
elif ABOUT_FILE=$(rg -l "__version__" --glob "**/__about__.py" | head -n 1); then \
export PROJECT_VERSION=$(rg -oP "(?<=__version__ = ['\"])[^'\"]+" "$ABOUT_FILE"); \
else \
echo "Version information not found!" >&2; \
exit 1; \
fi; \
export VERSION=$PROJECT_VERSION
version: get-version
#!/usr/bin/env bash
echo version is passed as $PROJECT_VERSION
# Run Ruff linter on Python files
[group('python')]
lint:
uv run ruff check .
# Run Ruff with auto-fix
[group('python')]
lint-fix:
uv run ruff check --fix .

4
py_project/.__about__.py Normal file
View file

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com>
#
# SPDX-License-Identifier: MIT
__version__ = "0.2.1"

42
pyproject.toml Normal file
View file

@ -0,0 +1,42 @@
[tool.ruff]
# Enable pycodestyle (`E`), Pyflakes (`F`), and import sorting (`I`)
select = ["E", "F", "I"]
ignore = []
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
unfixable = []
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
# Same as Black.
line-length = 88
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.11
target-version = "py311"

30
python/justfile Normal file
View file

@ -0,0 +1,30 @@
set working-directory := '..'
set export
set shell := ["bash", "-uc"]
venv:
#!/usr/bin/env bash
[ -d .venv ] || uv venv
[ -f requirements.txt ] && uv pip install -r requirements.txt
source .venv/bin/activate
clean:
rm -rf .venv
rm -rf **/*/__pycache__
rm -rf **/*/*.pyc
rm -rf **/*/*.pyo
install: venv
#!/usr/bin/env bash
uv pip install .
check: venv
#!/usr/bin/env bash
which python
ipython: venv
uv run ipython
install-uv:
curl -LsSf https://astral.sh/uv/install.sh | sh

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
pandas

0
vars/justfile Normal file
View file

1
version Normal file
View file

@ -0,0 +1 @@
0.0.1