Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
. venv/bin/activate
. .venv/bin/activate
10 changes: 6 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ jobs:
steps:
- name: "Clone project repository"
uses: actions/checkout@v3
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name : "Run flake8"
uses: py-actions/flake8@v2
- name: "Install dependencies"
run: uv sync
- name: "Run flake8"
run: uv run flake8 --config tox.ini
8 changes: 2 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ jobs:
run: |
build_tag=$(./scripts/create_build_tag_file.sh)
echo "build-tag=v${build_tag}" >> $GITHUB_OUTPUT
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name: "Print Python version"
run: python3 --version
- name: "Install shiv"
run: pip install shiv
- name: "Build local shiv package"
id: build
run: |
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-deploy-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ jobs:
steps:
- name: "Clone project repository"
uses: actions/checkout@v3
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name: "Print Python version"
run: python3 --version
- name: "Print kind version"
run: kind version
- name: "Install shiv"
run: pip install shiv
- name: "Generate build version file"
run: ./scripts/create_build_tag_file.sh
- name: "Build local shiv package"
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ jobs:
steps:
- name: "Clone project repository"
uses: actions/checkout@v3
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name: "Print Python version"
run: python3 --version
- name: "Install shiv"
run: pip install shiv
- name: "Generate build version file"
run: ./scripts/create_build_tag_file.sh
- name: "Build local shiv package"
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ jobs:
steps:
- name: "Clone project repository"
uses: actions/checkout@v3
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name: "Print Python version"
run: python3 --version
- name: "Install shiv"
run: pip install shiv
- name: "Generate build version file"
run: ./scripts/create_build_tag_file.sh
- name: "Build local shiv package"
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ jobs:
steps:
- name: "Clone project repository"
uses: actions/checkout@v3
- name: "Install Python"
uses: actions/setup-python@v4
- name: "Install uv"
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'
- name: "Print Python version"
run: python3 --version
- name: "Install shiv"
run: pip install shiv
- name: "Generate build version file"
run: ./scripts/create_build_tag_file.sh
- name: "Build local shiv package"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
venv
.venv
.vscode
stack.egg-info
__pycache__
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ To get started quickly on a fresh Ubuntu 24.04 instance (e.g, a Digital Ocean dr

**WARNING:** Always review downloaded scripts prior to running them so that you know what going to happen to your machine.

### Lazy Mode
Stack is written in Python and so needs a recent Python 3 on the machine. It also needs either docker or podman installed, and these utilities: git, jq. The [full installation instructions](./docs/install.md) show how to get these but if you're allready set up, proceed:
### Install with uv
If you have [uv](https://docs.astral.sh/uv/getting-started/installation/) installed:
```bash
uv tool install --from git+https://github.com/bozemanpass/stack stack
```

### Download a release
Stack is written in Python and so needs a recent Python 3 on the machine. It also needs either docker or podman installed, and these utilities: git, jq. The [full installation instructions](./docs/install.md) show how to get these but if you're already set up, proceed:

Stack is distributed as a single-file self-extracting script. The latest release can be downloaded like this:
```bash
Expand Down
27 changes: 9 additions & 18 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@ Suitable for developers either modifying or debugging the orchestrator Python co

In addition to the pre-requisites listed in the [README](/README.md), the following are required:

1. Python venv package
This may or may not be already installed depending on the host OS and version. Check by running:
```
$ python3 -m venv
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip] [--prompt PROMPT] ENV_DIR [ENV_DIR ...]
venv: error: the following arguments are required: ENV_DIR
```
If the venv package is missing you should see a message indicating how to install it, for example with:
```
$ apt install python3.10-venv
```
1. [uv](https://docs.astral.sh/uv/getting-started/installation/) — used for dependency management and virtual environments.

### Install

Expand All @@ -29,19 +19,20 @@ In addition to the pre-requisites listed in the [README](/README.md), the follow
$ git clone https://github.com/bozemanpass/stack.git
```

2. Enter the project directory:
2. Enter the project directory:
```
$ cd stack
```

3. Setup the virtualenv:
3. Install dependencies:
```
$ source ./scripts/developer-mode-setup.sh
$ ./scripts/developer-mode-setup.sh
```
This runs `uv sync`, which creates a `.venv` virtual environment and installs all dependencies.

4. Verify installation:
4. Verify installation:
```
$ (venv) stack
$ uv run stack
Usage: stack [OPTIONS] COMMAND [ARGS]...

BPI stack
Expand All @@ -68,11 +59,11 @@ In addition to the pre-requisites listed in the [README](/README.md), the follow

## Build a zipapp (single file distributable script)

Use shiv to build a single file Python executable zip archive of stack:
Use shiv (via `uvx`) to build a single file Python executable zip archive of stack:

1. Run shiv to create a zipapp file:
```
$ (venv) ./scripts/build_shiv_package.sh
$ ./scripts/build_shiv_package.sh
```
This creates a file under `./package/` that is executable outside of any venv, and on other machines and OSes and architectures, and requiring only the system Python3:

Expand Down
18 changes: 17 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ curl -SL https://github.com/docker/compose/releases/download/v2.11.2/docker-comp
chmod +x ~/.docker/cli-plugins/docker-compose
```

Next decide on a directory where you would like to put the stack program. Typically, this would be
### Install with uv (recommended)

If you have [uv](https://docs.astral.sh/uv/getting-started/installation/) installed, you can install stack directly from the git repository:

```bash
uv tool install --from git+https://github.com/bozemanpass/stack stack
```

This installs `stack` into an isolated environment and adds it to your PATH. To update to the latest version:

```bash
uv tool upgrade stack
```

### Install from a downloaded release

Decide on a directory where you would like to put the stack program. Typically, this would be
a "user" binary directory such as `~/bin` or perhaps `/usr/local/bin/stack` or possibly just the current working directory.

Now, having selected that directory, download the latest release from [this page](https://github.com/bozemanpass/stack/releses) into it (we're using `~/bin` below for concreteness but edit to suit if you selected a different directory). Also be sure that the destination directory exists and is writable:
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=75.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["uv_build>=0.10.6,<0.11.0"]
build-backend = "uv_build"

[project]
name = "stack"
Expand All @@ -25,16 +25,14 @@ dependencies = [
"mergedeep",
"mermaid-builder",
"termcolor",
"flake8",
"black"
]
requires-python = ">=3.10"

[project.scripts]
stack = "stack:main.cli"

[tool.setuptools.package-data]
stack = ['data/**']
[dependency-groups]
dev = ["flake8", "black"]

[project.urls]
"Homepage" = "https://github.com/bozemanpass/stack"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_shiv_package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Builds the shiv "package" for distribution
mkdir -p ./package
version_string=$( ./scripts/create_build_tag_file.sh )
shiv -c stack -o package/stack-${version_string} .
uvx shiv -c stack -o package/stack-${version_string} .
9 changes: 1 addition & 8 deletions scripts/developer-mode-setup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env bash
# Script to automate the steps needed to make a cloned project repo runnable on the path
# (beware of PATH having some other file with the same name ahead of ours)
if [[ -n "$STACK_SCRIPT_DEBUG" ]]; then
set -x
echo PATH is $PATH
fi
python3 -m venv venv
source ./venv/bin/activate
python3 -m pip install --upgrade pip setuptools wheel
pip install shiv
pip install --editable .
uv sync
4 changes: 2 additions & 2 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [[ "$1" == "--fix" ]]; then
LINE_LENGTH=$(cat tox.ini | grep 'max-line-length' | cut -d'=' -f2 | awk '{ print $1 }')
black -l ${LINE_LENGTH:-132} src/stack/
uv run black -l ${LINE_LENGTH:-132} src/stack/
fi

flake8 --config tox.ini
uv run flake8 --config tox.ini
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
extend-ignore = E203
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv,.venv
max-complexity = 25
max-line-length = 132
per-file-ignores =
Expand Down
Loading