Skip to content

Commit 04e5679

Browse files
authored
Rewrite Makefile to support older versions (#48)
* Rewrite Makefile to support older versions `make` 3.82 is when `ONESHELL` was introduced, but the default version installed in macos (as of Tahoe 26) is 3.81. As a result the ONESHELL directives are ignored, and the `venv/bin/activate` inclusion is ineffective. There are 2 ways to work around that: 1. single shell, using `. venv/bin/activate && cmd1 && cmd2`, with backslashes for line continuation 2. keep shell commands separate, and invoke venv/bin/___ directly Both approaches work (verified locally), but the venv/bin approach looks better, and removes an easy foot-gun * Add scripts to ruff includes
1 parent e4e77a1 commit 04e5679

3 files changed

Lines changed: 18 additions & 31 deletions

File tree

Makefile

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
1-
SHELL = /bin/bash
1+
SHELL = /bin/bash -xe
22

33
# Create the venv with the interpreter pinned in .python-version and install
44
# the dev/test/publish toolchain from the [dev] extra.
55
.PHONY: deps
6-
.ONESHELL:
76
deps:
8-
set -e
97
@echo "Setting up the Python environment..."
108
python3 -m venv venv
11-
. venv/bin/activate
12-
pip install -U pip
13-
pip install -e '.[dev]'
9+
venv/bin/pip install -U pip
10+
venv/bin/pip install -e '.[dev]'
1411
@echo "Dependencies installed."
1512

1613
# Auto-fix formatting and lint issues.
1714
.PHONY: format
18-
.ONESHELL:
1915
format:
20-
set -e
21-
. venv/bin/activate
22-
ruff format
23-
ruff check --fix
16+
venv/bin/ruff format
17+
venv/bin/ruff check --fix
2418

2519
# Full gate: format check, lint, type check, and the entire test suite.
2620
.PHONY: test
27-
.ONESHELL:
2821
test:
2922
@echo "Running format check, lint, type check, and tests..."
30-
set -e
31-
. venv/bin/activate
32-
ruff check
33-
ruff format --check --diff
23+
venv/bin/ruff check
24+
venv/bin/ruff format --check --diff
3425
npx -y markdownlint-cli2 "*.md"
35-
pyright --venvpath . --warnings
36-
python -m pytest
26+
venv/bin/pyright --warnings
27+
venv/bin/pytest tests/
3728
@echo "All checks passed."
3829

3930
# Alias for `make test`.
@@ -42,29 +33,20 @@ check: test
4233

4334
# Refresh the committed GraphQL schema fixture from the live API.
4435
.PHONY: schema
45-
.ONESHELL:
4636
schema:
47-
set -e
48-
. venv/bin/activate
49-
python scripts/dump_schema.py
37+
venv/bin/python scripts/dump_schema.py
5038

5139
# Build the sdist + wheel into dist/.
5240
.PHONY: build
53-
.ONESHELL:
5441
build:
55-
set -e
56-
. venv/bin/activate
5742
rm -rf dist
58-
python -m build
43+
venv/bin/python -m build
5944

6045
# Build then upload to PyPI (requires credentials/token).
6146
.PHONY: publish
62-
.ONESHELL:
6347
publish: build
64-
set -e
65-
. venv/bin/activate
66-
twine check dist/*
67-
twine upload dist/*
48+
venv/bin/twine check dist/*
49+
venv/bin/twine upload dist/*
6850

6951
.PHONY: clean
7052
clean:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ birdbuddy = ["py.typed"]
4747
# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
4848
line-length = 88
4949
target-version = "py310"
50+
include = ["birdbuddy/**/*.py", "tests/**/*.py", "scripts/**/*.py"]
5051

5152
# https://docs.astral.sh/ruff/rules/
5253
[tool.ruff.lint]
@@ -127,6 +128,7 @@ addopts = [
127128
"--cov-report=html",
128129
"--junit-xml=junit.xml",
129130
]
131+
testpaths = ["tests"]
130132

131133
[tool.coverage.run]
132134
source = ["birdbuddy"]

pyrightconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"pythonVersion": "3.10",
3+
"venvPath": ".",
4+
"venv": "venv",
35
"exclude": ["**/__pycache__", "**/.*", "build", "dist", "venv"],
6+
"include": ["birdbuddy", "tests", "scripts"],
47
"reportIncompatibleVariableOverride": false,
58
"executionEnvironments": [
69
{

0 commit comments

Comments
 (0)