forked from automl/ConfigSpace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (88 loc) · 3.21 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
# NOTE: Used on linux, limited support outside of Linux
#
# A simple makefile to help with small tasks related to development of ConfigSpace
# These have been configured to only really run short tasks. Longer form tasks
# are usually completed in github actions.
.PHONY: help install-dev install-test install-docs pre-commit clean clean-doc clean-build build docs links publish test clean-test
help:
@echo "Makefile ConfigSpace"
@echo "* install-dev to install all dev requirements and install pre-commit"
@echo "* pre-commit to run the pre-commit check"
@echo "* docs to generate and view the html files"
@echo "* linkcheck to check the documentation links"
@echo "* publish to help publish the current branch to pypi"
@echo "* test to run the tests"
PYTHON ?= python
CYTHON ?= cython
PYTEST ?= python -m pytest
CTAGS ?= ctags
PRECOMMIT ?= pre-commit
PIP ?= python -m pip
MAKE ?= make
DIR := "${CURDIR}"
DIST := "${DIR}/dist""
DOCDIR := "${DIR}/docs"
BUILD := "${DIR}/build"
INDEX_HTML := "file://${DOCDIR}/build/html/index.html"
NUMPY_INCLUDE := $(shell python -c 'import numpy; print(numpy.get_include())')
# https://stackoverflow.com/questions/40750596/how-do-i-escape-bracket-in-makefile
CP := )
benchmark:
python scripts/benchmark_sampling.py
install-dev:
$(PIP) install -e ".[dev]"
pre-commit install
install-test:
$(PIP) install -e ".[test]"
install-docs:
$(PIP) install -e ".[docs]"
check:
$(PRECOMMIT) run --all-files
check-types:
mypy ConfigSpace
fix:
black --quiet ConfigSpace test
ruff --silent --exit-zero --no-cache --fix ConfigSpace test
build:
python -m build
test:
$(PYTEST) test
clean-build:
rm -rf ${BUILD}
clean-docs:
$(MAKE) -C ${DOCDIR} clean
clean: clean-build clean-docs
clean-test: clean-build build test
# Running build before making docs is needed all be it very slow.
# Without doing a full build, the doctests seem to use docstrings from the last compiled build
docs: clean build
$(MAKE) -C ${DOCDIR} html
@echo
@echo "View docs at:"
@echo ${INDEX_HTML}
links:
$(MAKE) -C ${DOCDIR} linkcheck
# Publish to testpypi
# Will echo the commands to actually publish to be run to publish to actual PyPi
# This is done to prevent accidental publishing but provide the same conveniences
publish:
$(PIP) install twine
$(PYTHON) -m twine upload --repository testpypi ${DIST}/*
@echo
@echo "Test with the following:"
@echo "* Create a new virtual environment to install the uplaoded distribution into"
@echo "* Run the following:"
@echo
@echo " pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ ConfigSpace"
@echo
@echo "* Run this to make sure it can import correctly, plus whatever else you'd like to test:"
@echo
@echo " python -c 'import ConfigSpace'"
@echo
@echo "Once you have decided it works, publish to actual pypi with"
@echo
@echo " python -m twine upload dist/*"
cython-annotate:
C_INCLUDE_PATH=$(NUMPY_INCLUDE) cython -3 --directive boundscheck=False,wraparound=False --annotate ConfigSpace/*.pyx
cython-html: cython-annotate
python -c "import webbrowser; from pathlib import Path; [webbrowser.open(f'file://{path}') for path in Path('ConfigSpace').absolute().glob('*.html')]"