Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (81 loc) · 4.24 KB
/
Copy pathMakefile
File metadata and controls
102 lines (81 loc) · 4.24 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
SHELL := /bin/bash
VENV = .venv
VENVBIN = ${VENV}/bin
PYTHON = python3
PIP = ${PYTHON} -m pip
# Detect windows - works on both 32 & 64-bit windows
ifeq ($(OS),Windows_NT)
VENVBIN = ${VENV}/Scripts
# A venv on Windows has python.exe, but no python3.exe; "python3 -m venv" fails as it expects python3.exe in the venv
PYTHON = python
endif
export PATH := $(abspath ${VENVBIN}):${PATH}
.PHONY: init test test-fast-flatbuffers-builder test-flatbuffers-codegen build benchmark publish venv-init
# Default target executed when no arguments are given to make.
default_target: build test
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
################################
all: depend build test ## Get dependencies, clean, build and test
build: ${VENV} clean ## Clean and build: objectbox-clib wheels, objectbox-api and the objectbox metapackage
set -e ; \
${PYTHON} setup-clib.py all ; \
${PYTHON} setup.py bdist_wheel ; \
${PYTHON} setup-meta.py bdist_wheel ; \
ls -lh dist
build-sync: ${VENV} ## Build objectbox-sync-clib wheels and the objectbox-sync metapackage (requires depend-sync; adds to dist, e.g. after build)
set -e ; \
${PYTHON} setup-clib.py --sync all ; \
${PYTHON} setup-meta.py --sync bdist_wheel ; \
ls -lh dist
${VENV}: ${VENVBIN}/activate
venv-init:
@# venv is part of Python; pip/setuptools/wheel come from requirements.txt (e.g. venv has no setuptools since 3.12)
${PYTHON} -m venv ${VENV} || { echo "Creating ${VENV} failed; on Debian/Ubuntu, install python3-venv" ; exit 1 ; }
# remove packages not in the requirements.txt
# install and upgrade based on the requirements.txt
# let make know this is the last time requirements changed
${VENVBIN}/activate: requirements.txt
set -e ; \
if [ ! -d "${VENV}" ] ; then make venv-init ; fi ; \
${PIP} freeze | grep -v -f requirements.txt - | grep -v '^#' | grep -v '^-e ' | xargs ${PIP} uninstall -y || echo "never mind" ; \
${PIP} install --upgrade -r requirements.txt ; \
touch ${VENVBIN}/activate
depend: ${VENV} ## Prepare dependencies
set -e ; \
${PYTHON} download-c-lib.py
depend-sync: ${VENV} ## Prepare dependencies: Sync variant of the C library (used instead if available)
set -e ; \
${PYTHON} download-c-lib.py --sync
test: ${VENV} ## Test all targets
set -e ; \
${PYTHON} -m pytest --capture=no --verbose -rs
test-fast-flatbuffers-builder: ${VENV} ## Test with the experimental fast FlatBuffers builder (each object verified)
set -e ; \
${PYTHON} -m pytest --capture=no --verbose -rs --fast-flatbuffers-builder
test-flatbuffers-codegen: ${VENV} ## Test with the experimental FlatBuffers codegen (each object verified)
set -e ; \
${PYTHON} -m pytest --capture=no --verbose -rs --flatbuffers-codegen
benchmark: ${VENV} ## Run CRUD benchmarks (experimental: BENCHMARK_ARGS=--fast-flatbuffers-builder or --flatbuffers-codegen)
set -e ; \
${PYTHON} -m benchmark ${BENCHMARK_ARGS}
clean: ## Clean build artifacts
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
publish: ## Publish the packages built by `make build` (and `make build-sync`)
set -e
@echo "****************************************************************"
@echo ">>> Please enter the API token when asked for a password. <<<"
@echo ">>> The API token starts with the prefix 'pypi-'. <<<"
@echo ">>> See https://pypi.org/help/#apitoken for details. <<<"
@echo "****************************************************************"
# C libraries first, then objectbox-api, then the metapackages depending on them
${PYTHON} -m twine upload -u "__token__" --verbose dist/objectbox_clib-*.whl
# objectbox-sync-clib, if built (make build-sync)
if ls dist/objectbox_sync_clib-*.whl > /dev/null 2>&1 ; then ${PYTHON} -m twine upload -u "__token__" --verbose dist/objectbox_sync_clib-*.whl ; fi
${PYTHON} -m twine upload -u "__token__" --verbose dist/objectbox_api-*.whl
# Metapackages: objectbox (note: wheel file names use "_", so objectbox-*.whl matches only this one) and
# objectbox-sync, if built
${PYTHON} -m twine upload -u "__token__" --verbose dist/objectbox-*.whl
if ls dist/objectbox_sync-*.whl > /dev/null 2>&1 ; then ${PYTHON} -m twine upload -u "__token__" --verbose dist/objectbox_sync-*.whl ; fi