forked from gdsfactory/gdsfactory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (102 loc) · 3.58 KB
/
Copy pathMakefile
File metadata and controls
127 lines (102 loc) · 3.58 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
UV_INSTALLED := $(shell command -v uv)
.PHONY: \
uv \
install \
dev \
install-kfactory-dev \
update-pre \
test-data \
test \
test-force \
cov \
dev-cov \
test-samples \
docker-debug \
docker-build \
docker-run \
build \
upload-devpi \
upload-twine \
lint \
docs \
git-rm-merged \
notebooks \
clean \
help
uv: ## install uv if not installed
ifndef UV_INSTALLED
curl -LsSf https://astral.sh/uv/install.sh | sh
endif
install: uv ## Install all dependencies using uv
uv sync --all-extras --no-extra full
dev: uv ## Set up dev environment and install pre-commit
uv venv -p 3.12
uv sync --all-extras --no-extra full
uv run pre-commit install
uv run gf install-klayout-genericpdk
uv run gf install-git-diff
install-kfactory-dev: ## Force-reinstall kfactory from GitHub
uv pip install git+https://github.com/gdsfactory/kfactory --force-reinstall
update-pre: ## Update pre-commit hooks
pre-commit autoupdate
test-data: ## Clone test data from GitHub (HTTPS)
git clone https://github.com/gdsfactory/gdsfactory-test-data.git -b test_klayout test-data-gds
test-data-gds: ## Clone test data from GitHub (SSH)
git clone git@github.com:gdsfactory/gdsfactory-test-data.git -b test_klayout test-data-gds
test: test-data-gds ## Run tests
uv run pytest -s -n logical
test-force: ## Run tests with force-regen
uv run pytest -n logical --force-regen -s
cov: ## Run tests with coverage
uv run pytest --cov=gdsfactory --cov-report=xml:coverage.xml --cov-report=term-missing:skip-covered
dev-cov: ## Run tests in parallel with coverage
uv run pytest -s -n logical --cov=gdsfactory --cov-report=term-missing:skip-covered --durations=10
test-samples: ## Test that samples run without error
uv run pytest tests/test_samples.py
docker-debug: ## Start a debug shell in Docker
docker run -it joamatab/gdsfactory sh
docker-build: ## Build Docker image
docker build -t joamatab/gdsfactory .
docker-run: ## Run Docker container
docker run \
-p 8888:8888 \
-p 8082:8082 \
-e JUPYTER_ENABLE_LAB=yes \
joamatab/gdsfactory:latest
build: ## Build python package
rm -rf dist
uv build
upload-devpi: ## Upload package to devpi
uv tool run devpi-client upload --format=bdist_wheel,sdist.tgz
upload-twine: build ## Upload package to PyPI using twine
uv tool run twine upload dist/*
lint: ## Run linting and formatting checks
uv run pre-commit run --all-files
docs: ## Build documentation
uv run python docs/write_cells.py
uv run jb build docs
git-rm-merged: ## Delete merged git branches
git fetch --prune
git branch --merged origin/main | grep -v '^\*' | grep -v 'main' | xargs -n 1 git branch -d
notebooks: ## Convert python scripts to Jupyter notebooks
jupytext docs/notebooks/*.py --to ipynb
clean: ## Remove build, cache and temporary files
rm -rf .venv
find src -name "*.c" | xargs rm -rf
find src -name "*.pyc" | xargs rm -rf
find src -name "*.so" | xargs rm -rf
find src -name "*.pyd" | xargs rm -rf
find . -name "*.egg_info" | xargs rm -rf
find . -name ".ipynb_checkpoints" | xargs rm -rf
find . -name ".mypy_cache" | xargs rm -rf
find . -name ".pytest_cache" | xargs rm -rf
find . -name ".ruff_cache" | xargs rm -rf
find . -name "__pycache__" | xargs rm -rf
find . -name "build" | xargs rm -rf
find . -name "builds" | xargs rm -rf
find . -name "dist" -not -path "*node_modules*" | xargs rm -rf
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.DEFAULT_GOAL := help
help: ## this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'