forked from ludopulles/BLASter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (69 loc) · 3.08 KB
/
Makefile
File metadata and controls
93 lines (69 loc) · 3.08 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
# BLASter Makefile - supports both legacy and modern PEP 517 build systems
.POSIX:
.PHONY: all build install install-dev cython cython-gdb clean venv-clean eigen3-clean test
# if virtualenv directory venv exists then prefer venv/bin/python3 over system python3
VENV := venv
PYTHONV := python3
PYTHON = $(or $(wildcard $(VENV)/bin/$(PYTHONV)), $(shell command -v $(PYTHONV)), $(PYTHONV))
# Default target - build the package
all: build
# Modern PEP 517 build (recommended)
build:
$(PYTHON) -m pip install --upgrade build
$(PYTHON) -m build
# Install in development mode (editable install)
install-dev:
$(PYTHON) -m pip install -e .
# Standard installation
install:
$(PYTHON) -m pip install .
# Legacy build method (backward compatibility)
cython:
$(PYTHON) setup.py build_ext --inplace
# Debug build (legacy method)
# The LD_PRELOAD trick is from https://github.com/grpc/grpc/issues/25819
cython-gdb:
$(PYTHON) setup.py build_ext --cython-gdb --inplace
# Clean build artifacts
clean:
rm -rf build/ dist/ *.egg-info/ cysignals_crash_logs/
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "*.so" -delete
find . -name "*.c" -path "*/core/*" -delete
# Test the package (if tests exist)
test:
$(PYTHON) -m pytest tests/ || echo "No tests found or pytest not installed"
### Rules to install Eigen C++ template library for linear algebra locally
# Default version of Eigen C++ template library for linear algebra
EIGEN_VERSION := 3.4.0
eigen3:
$(MAKE) eigen-$(EIGEN_VERSION)
if [ -d eigen3 ]; then rm eigen3; fi
ln -s eigen-$(EIGEN_VERSION) eigen3
eigen-%: eigen-%.tar.gz
tar -xzvf $< >/dev/null
eigen-%.tar.gz:
wget -nv "https://gitlab.com/libeigen/eigen/-/archive/$*/$@" -O "$@"
eigen3-clean:
rm -rf eigen3 eigen-$(EIGEN_VERSION) eigen-$(EIGEN_VERSION).tar.gz
### Rules to create a virtual environment with up-to-date numpy and cython
# Default requirements for modern PEP 517 development
PIP_REQUIREMENTS := pip build wheel cython cysignals numpy setuptools matplotlib pytest
venv:
@if [ "$(VIRTUAL_ENV)" != "" ]; then echo "Active virtual environment detected. Please run 'deactivate' first!"; false; fi
$(PYTHON) -m pip install --upgrade pip 2> /dev/null || echo "ERROR: Upgrading pip failed!"
$(PYTHON) -m pip install virtualenv 2> /dev/null || echo "ERROR: Installing pip package virtualenv failed!"
$(PYTHON) -m virtualenv $(VENV)
-@rm activate 2>/dev/null
ln -s $(VENV)/bin/activate .
printf "#!/usr/bin/env bash\nOPENBLAS_NUM_THREADS=1 $(VENV)/bin/$(PYTHONV) \$$*\n" > ./$(PYTHONV)
chmod +x ./$(PYTHONV)
$(VENV)/bin/$(PYTHONV) -m pip install --upgrade $(PIP_REQUIREMENTS)
@echo "=================================================================="
@echo "=== NOTE: Please use 'source activate' to activate environment ==="
@echo "=== Or use './python3' to use environment ==="
@echo "=================================================================="
venv-clean:
@if [ "$(VIRTUAL_ENV)" != "" ]; then echo "Active virtual environment detected. Please run 'deactivate' first!"; false; fi
rm -rf venv