-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (43 loc) · 1.62 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
PIPENV ?= $(shell which pipenv)
ifneq ($(PIPENV),)
PYTHON ?= $(shell $(PIPENV) --py)
else
PYTHON ?= $(shell which python)
endif
SRC_DIRS ?= ./pyx_src
CYTHON_SRCS ?= $(shell find $(SRC_DIRS) -name "*.pyx")
CYTHON_CPPS ?= $(CYTHON_SRCS:.pyx=.cpp)
CYTHON_HTMLS ?= $(CYTHON_SRCS:.pyx=.html)
EXTENSION_SUFFIX ?= $(shell $(PYTHON) -c 'import importlib.machinery; print(importlib.machinery.EXTENSION_SUFFIXES[0])')
# BUILD_SUFFIX is $(OS)-$(MACHINE)-$(MAJOR_PYTHON_VERSION), e.g. linux-x86_64-3.7
BUILD_SUFFIX ?= $(shell $(PYTHON) -c 'import platform; print(platform.system().lower(), platform.machine().lower(), ".".join(platform.python_version_tuple()[0:2]), sep="-")')
LIB_DIR ?= ./build/lib.$(BUILD_SUFFIX)
EXTENSION_LIBRARY ?= apq$(EXTENSION_SUFFIX)
ifneq ($(TEST_PATTERN),)
TEST_FLAGS := -k $(TEST_PATTERN)
endif
$(CYTHON_CPPS) $(CYTHON_HTMLS): $(CYTHON_SRCS)
$(PIPENV) run python setup.py transpile_cython
$(LIB_DIR)/apq$(EXTENSION_SUFFIX): $(CYTHON_CPPS) $(SRC_DIRS)/cpp/binheap.hpp
$(PIPENV) run python setup.py build_ext
$(EXTENSION_LIBRARY): $(LIB_DIR)/$(EXTENSION_LIBRARY)
cp $< $@
build-dev: $(EXTENSION_LIBRARY)
all: $(EXTENSION_LIBRARY)
test: $(EXTENSION_LIBRARY)
ifeq ($(NO_MYPY),)
$(PIPENV) run mypy tests
endif
$(PIPENV) run pytest tests $(TEST_FLAGS)
bench-basic: $(EXTENSION_LIBRARY)
ifeq ($(NO_MYPY),)
$(PIPENV) run mypy bench
endif
$(PIPENV) run python -m bench.basic
build-dist:
$(PIPENV) run python setup.py transpile_cython sdist bdist_wheel
clean:
$(RM) -f $(CYTHON_CPPS) $(CYTHON_HTMLS)
$(RM) -rf build py_src/apq.egg-info cython_debug
$(RM) -f apq.*.so
.PHONY: test build-dev bench-basic build-dist clean