-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (115 loc) · 5.12 KB
/
Copy pathMakefile
File metadata and controls
137 lines (115 loc) · 5.12 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
help: ## Show this help
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST) | column -t -s :
.PHONY : setup pip_setup_headless test coverage check clean docs cleandocs preview pull_containers
setup: ## Setup a virtual environment and install all development dependencies
if command -v uv > /dev/null 2>&1; then \
uv sync --extra pinned --extra dev --extra test --extra docs; \
uv run pre-commit install; \
else \
python -m venv .venv --upgrade-deps; \
.venv/bin/pip install -e .[pinned]; \
.venv/bin/pre-commit install; \
fi
@echo
@echo ATTENTION: You need to activate the virtual environment in every shell with:
@echo source .venv/bin/activate
# Variables
REPO_URL := https://gitlab.opengeosys.org/ogs/ogs.git
TARGET_DIR := .ogs
COMMIT_HASH ?= master
# Clone the repository and checkout the specific commit
clone:
@if [ ! -d "$(TARGET_DIR)" ]; then \
echo "Cloning repository..."; \
git clone "$(REPO_URL)" "$(TARGET_DIR)"; \
else \
echo "Repository already cloned."; \
fi; \
if [ -n "$(COMMIT_HASH)" ]; then \
echo "Checking out specific commit: $(COMMIT_HASH)"; \
cd "$(TARGET_DIR)" && git fetch origin && git checkout "$(COMMIT_HASH)"; \
else \
echo "Pulling latest changes from master..."; \
cd "$(TARGET_DIR)" && git pull origin master; \
fi
# All latest versions (including latest OGS). Should be installed into a fresh virtual environment
# Hint for custom ogs: .venv/bin/pip install -v ./.ogs --config-settings=cmake.define.OGS_BUILD_PROCESSES="HeatConduction;ThermoRichardsMechanics;SmallDeformation;SteadyStateDiffusion"
pip_setup_latest:
python -m venv .venv --upgrade-deps
.venv/bin/pip install -e .[dev,test,docs,monitor]
.venv/bin/pip uninstall ogs -y
.venv/bin/pip install ogs --index-url https://gitlab.opengeosys.org/api/v4/projects/120/packages/pypi/simple --pre
@echo
@echo "ATTENTION: You need to activate the virtual environment in every shell with:"
@echo "source .venv/bin/activate"
# Assumes ogstools is already installed
pip_setup_headless: ## Install gmsh without X11 dependencies
.venv/bin/pip uninstall gmsh -y
.venv/bin/pip install -i https://gmsh.info/python-packages-dev-nox gmsh
# gmsh same version as pinned for gallery_check, otherwise meshes might
# change slightly, causing the hash check to fail.
setup_devcontainer: ## Internal usage [CI]
rm -rf .venv-devcontainer
python -m venv .venv-devcontainer --upgrade-deps
.venv-devcontainer/bin/pip install -e .[feflow,pinned]
.venv-devcontainer/bin/pip uninstall gmsh -y
.venv-devcontainer/bin/pip install -i https://gmsh.info/python-packages-dev-nox gmsh==4.13.1.dev1
test: ## Runs the unit tests
python scripts/pull_containers.py
pytest --mpl --mpl-baseline-path=tests/baseline --mpl-generate-summary=html -n auto
test_figures: ## Create the reference figures for the plot tests
rm -rf tests/baseline
pytest --mpl-generate-path=tests/baseline -k "TestPlotting or test_plot" -n auto
gallery_hashes:
python docs/gallery_hashes.py write --exclude *thumb.png
gallery_check:
python docs/gallery_hashes.py compare --exclude *feflowlib* *thumb.png
coverage: ## Runs the unit tests generating code coverage reports
coverage run -m pytest --hypothesis-profile ci
coverage report --no-skip-covered
coverage html
coverage xml
check: ## Runs various checks with pre-commit
pre-commit run --all-files
link_check: ## Runs lychee to check if external weblinks are functioning
lychee docs/examples docs/user-guide --extensions md,py --exclude rst \
--exclude reference\/ogstools --cache --max-cache-age 2d -vv
clean: ## Cleans up temporary files
rm -r .coverage htmlcov
docs: ## Builds the documentation
make html -C docs
cleandocs: ## Cleans up temporary documentation files
rm -r docs/_build
rm -r docs/auto_examples
rm -r docs/auto_user-guide
rm -r docs/reference/*.rst
indexdocs: ## Creates the pagefind index
python3 -m pagefind --site "docs/_build/html"
preview: ## Runs an auto-updating web server for the documentation
make docs
python docs/server.py
.PHONY: requirement
requirement:
## conda init zsh
## conda create --prefix /tmp/ogstools-test-env-py312 python=3.12
## conda activate /tmp/ogstools-test-env-py312
@version_output=$$(python --version 2>&1); \
version=$$(echo "$$version_output" | awk '{print $$2}' | awk -F'.' '{print $$1 "_" $$2}'); \
venv_dir=".venv_py$$version"; \
if [ -d "$$venv_dir" ]; then \
read -p "Virtual environment '$$venv_dir' already exists. Do you want to continue and recreate it? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "Aborting."; \
exit 1; \
fi; \
echo "Continuing to recreate virtual environment."; \
rm -r "$$venv_dir"; \
fi; \
echo "Creating virtual environment in $$venv_dir"; \
python -m venv $$venv_dir; \
echo "Activating virtual environment and installing packages"; \
. $$venv_dir/bin/activate && pip install .[ogs] && pip freeze -l > requirements/requirements_py$$version.txt && \
echo "Activating virtual environment and installing packages"; \
. $$venv_dir/bin/activate && pip install .[all,dev,docs,test] && pip freeze -l > requirements/requirements_allextras_py$$version.txt && \
echo "Deleting virtual environment"; \
rm -r $$venv_dir