Skip to content

Commit 5633abb

Browse files
whummerclaude
andcommitted
add Makefile and update README for utils package
- Add Makefile with build, publish, format, and lint targets - Update README: rename Installation to Usage, show pyproject.toml dependency format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 14ecf97 commit 5633abb

2 files changed

Lines changed: 56 additions & 23 deletions

File tree

utils/Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
VENV_BIN = python3 -m venv
2+
VENV_DIR ?= .venv
3+
VENV_ACTIVATE = $(VENV_DIR)/bin/activate
4+
VENV_RUN = . $(VENV_ACTIVATE)
5+
6+
usage: ## Show usage for this Makefile
7+
@cat Makefile | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
8+
9+
venv: $(VENV_ACTIVATE)
10+
11+
$(VENV_ACTIVATE): pyproject.toml
12+
test -d .venv || $(VENV_BIN) .venv
13+
$(VENV_RUN); pip install --upgrade pip setuptools wheel build
14+
$(VENV_RUN); pip install -e .[dev]
15+
touch $(VENV_DIR)/bin/activate
16+
17+
clean: ## Clean up build artifacts and virtual environment
18+
rm -rf .venv/
19+
rm -rf build/
20+
rm -rf .eggs/
21+
rm -rf *.egg-info/
22+
23+
install: venv ## Install the package in development mode
24+
25+
dist: venv ## Create distribution package
26+
$(VENV_RUN); python -m build
27+
28+
publish: clean-dist venv dist ## Publish package to PyPI
29+
$(VENV_RUN); pip install --upgrade twine; twine upload dist/*
30+
31+
format: venv ## Run ruff to format the code
32+
$(VENV_RUN); python -m ruff format .; make lint
33+
34+
lint: venv ## Run ruff to lint the code
35+
$(VENV_RUN); python -m ruff check --output-format=full .
36+
37+
clean-dist: clean
38+
rm -rf dist/
39+
40+
.PHONY: clean clean-dist dist install publish usage venv format lint

utils/README.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,32 @@ LocalStack Extensions Utils
33

44
A utility library providing common functionality for building [LocalStack Extensions](https://github.com/localstack/localstack-extensions).
55

6-
## Installation
6+
## Usage
7+
8+
To use this library in your LocalStack extension, add it to the `dependencies` in your extension's `pyproject.toml`:
79

8-
```bash
9-
pip install localstack-extensions-utils
10+
```toml
11+
[project]
12+
dependencies = [
13+
"localstack-extensions-utils",
14+
]
1015
```
1116

12-
Or install directly from the GitHub repository:
17+
Or, to install directly from the GitHub repository:
1318

14-
```bash
15-
pip install "git+https://github.com/localstack/localstack-extensions.git#egg=localstack-extensions-utils&subdirectory=utils"
19+
```toml
20+
[project]
21+
dependencies = [
22+
"localstack-extensions-utils @ git+https://github.com/localstack/localstack-extensions.git#subdirectory=utils",
23+
]
1624
```
1725

18-
## Usage
19-
20-
### Creating a Docker-based Extension
26+
Then import the utilities in your extension code, for example:
2127

2228
```python
2329
from localstack_extensions.utils import ProxiedDockerContainerExtension
24-
from werkzeug.datastructures import Headers
25-
26-
class MyExtension(ProxiedDockerContainerExtension):
27-
name = "my-extension"
28-
29-
def __init__(self):
30-
super().__init__(
31-
image_name="my-docker-image:latest",
32-
container_ports=[8080],
33-
host="myext.localhost.localstack.cloud",
34-
)
3530

36-
def should_proxy_request(self, headers: Headers) -> bool:
37-
# Define your routing logic
38-
return "myext" in headers.get("Host", "")
31+
...
3932
```
4033

4134
## Dependencies

0 commit comments

Comments
 (0)