Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (115 loc) · 6.63 KB
/
Copy pathMakefile
File metadata and controls
151 lines (115 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
.PHONY: help clean clean-build clean-pyc clean-test setup check-format check-types check-tests check check-tox build format coverage check-build test test-unit test-reactable test-playwright test-playwright-reactable test-playwright-coverage test-all-local coverage-ci coverage-combine coverage-html dist install pyright docs docs-preview docs-check
.DEFAULT_GOAL := help
REPO_ROOT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
PYTHON_PATHS := shinywidgets tests
PYRIGHT_PATHS := shinywidgets tests/__init__.py tests/unit/test_version_metadata.py
PYTEST_UNIT := uv run pytest -c "$(REPO_ROOT)/pytest.ini" --confcutdir "$(REPO_ROOT)"
PYTEST_PLAYWRIGHT := uv run pytest -c "$(REPO_ROOT)/tests/playwright/playwright-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/playwright" "$(REPO_ROOT)/tests/playwright"
# reactable can't join the shared test/dev groups (importing it builds a
# process-global ipyreact Module widget that order-sensitive FakeSession unit
# tests don't expect), it imports great_tables without declaring it, and it
# pins ipyreact<=0.4.1. Overlay it instead, and only for reactable's own
# tests: layering the overlay over every Playwright app shifts Jupyter's data
# directories and breaks other widgets' nbextension lookup.
REACTABLE_OVERLAY := --with reactable --with great_tables --with 'ipyreact>=0.6'
PYTEST_REACTABLE := uv run $(REACTABLE_OVERLAY) pytest -c "$(REPO_ROOT)/pytest.ini" --confcutdir "$(REPO_ROOT)" "$(REPO_ROOT)/tests/unit/test_reactable.py" "$(REPO_ROOT)/tests/unit/test_reactable_accessors.py"
PYTEST_REACTABLE_PLAYWRIGHT := uv run $(REACTABLE_OVERLAY) pytest -c "$(REPO_ROOT)/tests/playwright/playwright-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/playwright" "$(REPO_ROOT)/tests/playwright/render_reactable"
define PRINT_HELP_PYSCRIPT
import re
import sys
for line in sys.stdin:
match = re.match(r"^([a-zA-Z0-9_/-]+):.*?## (.*)$$", line)
if match:
target, help = match.groups()
print(f"{target:20} {help}")
endef
export PRINT_HELP_PYSCRIPT
help: ## show help messages for make targets
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test ## remove build, cache, and coverage artifacts
clean-build: ## remove build artifacts
rm -rf build/ dist/ .eggs/
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc: ## remove Python cache artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
clean-test: ## remove test and coverage artifacts
rm -rf .tox/ .pytest_cache/ htmlcov/
rm -f .coverage .coverage.* coverage.xml
setup: ## sync the development environment with uv
uv sync --all-groups
check-format: ## run Ruff lint and format checks
uv run ruff check $(PYTHON_PATHS) --config pyproject.toml
uv run ruff format --check $(PYTHON_PATHS) --config pyproject.toml
check-types: ## run pyright type checks
uv run pyright $(PYRIGHT_PATHS)
check-tests: ## run pytest checks
$(PYTEST_UNIT)
check: ## run format, type, and test checks
$(MAKE) check-format
$(MAKE) check-types
$(MAKE) check-tests
check-tox: ## run test and type checks across supported Python versions
uv run tox run-parallel
build: ## build the source and wheel distributions
uv build
format: ## apply Ruff fixes and formatting
uv run ruff check --fix $(PYTHON_PATHS) --config pyproject.toml
uv run ruff format $(PYTHON_PATHS) --config pyproject.toml
coverage: ## run the test suite under coverage
rm -f .coverage .coverage.*
uv run coverage run --rcfile "$(REPO_ROOT)/.coveragerc" -m pytest -c "$(REPO_ROOT)/pytest.ini" --confcutdir "$(REPO_ROOT)"
uv run coverage combine --rcfile "$(REPO_ROOT)/.coveragerc"
uv run coverage report
check-build: ## verify package build metadata is importable
uv build
uv run python -c "import shinywidgets; print(shinywidgets.__version__)"
test: check-tests ## run pytest quickly with the default environment
test-unit: ## run unit tests only (explicit config/cutoff)
$(PYTEST_UNIT)
test-playwright: ## run Playwright regression tests
uv run playwright install chromium
$(PYTEST_PLAYWRIGHT) $(PYTEST_PLAYWRIGHT_ARGS)
test-reactable: ## run reactable unit tests (needs the overlay; see REACTABLE_OVERLAY)
$(PYTEST_REACTABLE)
test-playwright-reactable: ## run reactable Playwright tests (needs the overlay)
uv run playwright install chromium
$(PYTEST_REACTABLE_PLAYWRIGHT) $(PYTEST_PLAYWRIGHT_ARGS)
test-all-local: ## run unit tests then Playwright tests (requires browsers installed)
$(MAKE) test-unit
$(MAKE) test-playwright
dist: build ## build source and wheel distributions
coverage-combine: ## combine parallel coverage data files into a single .coverage
uv run coverage combine --rcfile "$(REPO_ROOT)/.coveragerc"
test-playwright-coverage: ## run Playwright tests with subprocess coverage (best-effort; requires coverage installed)
rm -f .coverage .coverage.*
COVERAGE_PROCESS_START="$(REPO_ROOT)/.coveragerc" PYTHONPATH="$(REPO_ROOT)" $(PYTEST_PLAYWRIGHT)
$(MAKE) coverage-combine
uv run coverage report --rcfile "$(REPO_ROOT)/.coveragerc" -m
coverage-ci: ## generate a CI-friendly coverage report + coverage.xml
rm -f .coverage .coverage.*
uv run coverage run --rcfile "$(REPO_ROOT)/.coveragerc" -m pytest -c "$(REPO_ROOT)/pytest.ini" --confcutdir "$(REPO_ROOT)"
uv run coverage combine --rcfile "$(REPO_ROOT)/.coveragerc"
uv run coverage report --rcfile "$(REPO_ROOT)/.coveragerc" -m
uv run coverage xml --rcfile "$(REPO_ROOT)/.coveragerc" -o coverage.xml
coverage-html: ## generate HTML coverage output
$(MAKE) coverage-combine
uv run coverage html --rcfile "$(REPO_ROOT)/.coveragerc"
install: build ## install the built wheel into the uv environment
uv run pip uninstall -y shinywidgets || true
uv run pip install dist/shinywidgets*.whl
pyright: check-types ## run pyright type checks
DOCS_PORT ?= 8780
docs: ## build the website into website/_site (log: website/_render.log)
uv run --no-sync python website/_tools/sync_landing_counts.py
cd website && uv run --no-sync quartodoc build --config _quarto.yml > _render.log 2>&1 || { tail -40 _render.log; exit 1; }
cd website && uv run --no-sync quarto render >> _render.log 2>&1 || { tail -40 _render.log; exit 1; }
@if grep -q "Unable to resolve link target" website/_render.log; then \
grep -B1 "Unable to resolve link target" website/_render.log | head -40; \
echo "Unresolved links; see website/_render.log"; exit 1; fi
docs-preview: ## serve the built website at http://localhost:$(DOCS_PORT)/
uv run --no-sync python -m http.server $(DOCS_PORT) --bind 127.0.0.1 --directory website/_site
docs-check: ## run the website's browser checks against website/_site
uv run --no-sync python website/_tools/check_site.py