forked from steveberardi/starplot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
121 lines (92 loc) · 3.14 KB
/
Makefile
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
PYTHON=./venv/bin/python
DE421_URL=https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/a_old_versions/de421.bsp
ifeq ($(CI), true)
DR_ARGS=
else
DR_ARGS=-it
endif
ifeq ($(PROFILE), true)
SCRATCH_ARGS=-m cProfile -o results.prof
else
SCRATCH_ARGS=
endif
DOCKER_RUN=docker run --rm $(DR_ARGS) -v $(shell pwd):/starplot starplot-dev bash -c
DOCKER_BUILDER=starplot-builder
DOCKER_BUILD_PYTHON=docker build -t starplot-$(PYTHON_VERSION) $(DOCKER_BUILD_ARGS) --build-arg="PYTHON_VERSION=$(PYTHON_VERSION)" --target dev .
DOCKER_RUN_PYTHON_TEST=docker run --rm $(DR_ARGS) -v $(shell pwd):/starplot starplot-$(PYTHON_VERSION)
export PYTHONPATH=./src/
# ------------------------------------------------------------------
build: PYTHON_VERSION=3.11.7
build: DOCKER_BUILD_ARGS=-t starplot-dev
build:
$(DOCKER_BUILD_PYTHON)
docker-multi-arch:
docker buildx inspect $(DOCKER_BUILDER) && echo "Builder already exists!" || docker buildx create --name $(DOCKER_BUILDER) --bootstrap --use
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag sberardi/starplot-base:latest --target base .
lint:
$(DOCKER_RUN) "ruff check src/ tests/ $(ARGS)"
format:
$(DOCKER_RUN) "python -m black src/ tests/ scripts/ examples/ $(ARGS)"
test:
$(DOCKER_RUN) "python -m pytest --cov=src/ --cov-report=term --cov-report=html ."
bash:
$(DOCKER_RUN) bash
shell:
$(DOCKER_RUN) ipython
scratchpad:
$(DOCKER_RUN) "python $(SCRATCH_ARGS) scripts/scratchpad.py"
examples:
$(DOCKER_RUN) "cd examples && python examples.py"
gallery:
$(DOCKER_RUN) "python scripts/gallery.py"
# ------------------------------------------------------------------
# Python version testing
# ------------------------------------------------------------------
test-3.9: PYTHON_VERSION=3.9.18
test-3.9:
$(DOCKER_BUILD_PYTHON)
$(DOCKER_RUN_PYTHON_TEST)
test-3.10: PYTHON_VERSION=3.10.13
test-3.10:
$(DOCKER_BUILD_PYTHON)
$(DOCKER_RUN_PYTHON_TEST)
test-3.11: PYTHON_VERSION=3.11.7
test-3.11:
$(DOCKER_BUILD_PYTHON)
$(DOCKER_RUN_PYTHON_TEST)
test-3.12: PYTHON_VERSION=3.12.1
test-3.12:
$(DOCKER_BUILD_PYTHON)
$(DOCKER_RUN_PYTHON_TEST)
# ------------------------------------------------------------------
# Docs
docs-serve: DR_ARGS=-it -p 8000:8000
docs-serve:
$(DOCKER_RUN) "mkdocs serve -a 0.0.0.0:8000 -q --watch src/"
docs-build:
$(DOCKER_RUN) "mkdocs build"
docs-publish:
$(DOCKER_RUN) "mkdocs gh-deploy --force"
# ------------------------------------------------------------------
# PyPi - build & publish
flit-build:
$(DOCKER_RUN) "python -m flit build"
flit-publish: DR_ARGS=-e FLIT_USERNAME -e FLIT_PASSWORD
flit-publish:
$(DOCKER_RUN) "python -m flit publish"
# ------------------------------------------------------------------
# Utils
ephemeris:
$(DOCKER_RUN) "python -m jplephem excerpt 2001/1/1 2050/1/1 $(DE421_URL) de421sub.bsp"
hip8:
$(DOCKER_RUN) "python ./scripts/hip.py ./src/starplot/data/library/hip_main.dat hip8.dat 15"
scripts:
$(DOCKER_RUN) "python ./scripts/$(SCRIPT).py"
clean:
rm -rf __pycache__
rm -rf venv
rm -rf dist
rm -rf site
rm -rf htmlcov
rm -f tests/data/*.png
.PHONY: build test shell flit-build flit-publish clean ephemeris hip8 scratchpad examples scripts