@@ -6,75 +6,123 @@ PATH := /snap/bin:$(PATH)
6
6
DEBUG_GRAPHINA = 1
7
7
RUST_LOG = info
8
8
RUST_BACKTRACE = full
9
+ WHEEL_DIR = dist
10
+ PYGRAPHINA_DIR = pygraphina
11
+
12
+ # Find the built Python wheel file (the latest one)
13
+ WHEEL_FILE = $(shell ls $(PYGRAPHINA_DIR ) /$(WHEEL_DIR ) /pygraphina-* .whl | head -n 1)
9
14
10
15
# Default target
11
16
.DEFAULT_GOAL := help
12
17
13
18
.PHONY : help
14
- help : # # Show this help message
19
+ help : # # Show the list of available targets with their descriptions
15
20
@grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
16
21
22
+ # #######################################################################################
23
+ # # Rust targets
24
+ # #######################################################################################
25
+
17
26
.PHONY : format
18
27
format : # # Format Rust files
19
28
@echo " Formatting Rust files..."
20
- cargo fmt
29
+ @ cargo fmt
21
30
22
31
.PHONY : test
23
32
test : format # # Run tests
24
33
@echo " Running tests..."
25
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) RUST_LOG=debug RUST_BACKTRACE=$(RUST_BACKTRACE ) cargo test -- --nocapture
34
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) RUST_LOG=debug RUST_BACKTRACE=$(RUST_BACKTRACE ) cargo test -- --nocapture
26
35
27
36
.PHONY : coverage
28
37
coverage : format # # Generate test coverage report
29
38
@echo " Generating test coverage report..."
30
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo tarpaulin --out Xml --out Html
39
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo tarpaulin --out Xml --out Html
31
40
32
41
.PHONY : build
33
42
build : format # # Build the binary for the current platform
34
43
@echo " Building the project..."
35
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo build --release
44
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo build --release
36
45
37
46
.PHONY : run
38
47
run : build # # Build and run the binary
39
48
@echo " Running the $( BINARY) binary..."
40
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) ./$(BINARY )
49
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) ./$(BINARY )
41
50
42
51
.PHONY : clean
43
52
clean : # # Remove generated and temporary files
44
53
@echo " Cleaning up..."
45
- cargo clean
54
+ @cargo clean
55
+ @rm -rf dist/
56
+ @rm -rf $(PYGRAPHINA_DIR ) /$(WHEEL_DIR )
57
+ @rm -f $(PYGRAPHINA_DIR ) /* .so
46
58
47
59
.PHONY : install-snap
48
60
install-snap : # # Install a few dependencies using Snapcraft
49
61
@echo " Installing the snap package..."
50
- sudo apt-get update
51
- sudo apt-get install -y snapd
52
- sudo snap refresh
53
- sudo snap install rustup --classic
62
+ @ sudo apt-get update
63
+ @ sudo apt-get install -y snapd
64
+ @ sudo snap refresh
65
+ @ sudo snap install rustup --classic
54
66
55
67
.PHONY : install-deps
56
68
install-deps : install-snap # # Install development dependencies
57
69
@echo " Installing dependencies..."
58
- rustup component add rustfmt clippy
59
- cargo install cargo-tarpaulin
60
- cargo install cargo-audit
70
+ @ rustup component add rustfmt clippy
71
+ @ cargo install cargo-tarpaulin
72
+ @ cargo install cargo-audit
61
73
62
74
.PHONY : lint
63
75
lint : format # # Run linters on Rust files
64
76
@echo " Linting Rust files..."
65
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo clippy -- -D warnings
77
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo clippy -- -D warnings
66
78
67
79
.PHONY : publish
68
- publish : # # Publish the package to crates.io (requires CARGO_REGISTRY_TOKEN to be set)
80
+ publish : # # Publish the package to crates.io (needs CARGO_REGISTRY_TOKEN to be set)
69
81
@echo " Publishing the package to Cargo registry..."
70
- cargo publish --token $(CARGO_REGISTRY_TOKEN )
82
+ @ cargo publish --token $(CARGO_REGISTRY_TOKEN )
71
83
72
84
.PHONY : bench
73
85
bench : # # Run benchmarks
74
86
@echo " Running benchmarks..."
75
- DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo bench
87
+ @ DEBUG_GRAPHINA=$(DEBUG_GRAPHINA ) cargo bench
76
88
77
89
.PHONY : audit
78
90
audit : # # Run security audit on Rust dependencies
79
91
@echo " Running security audit..."
80
- cargo audit
92
+ @cargo audit
93
+
94
+ # #######################################################################################
95
+ # # Python targets
96
+ # #######################################################################################
97
+
98
+ .PHONY : develop_py
99
+ develop_py : # # Build and install PyGraphina in current Python environment
100
+ @echo " Building and installing PyGraphina in current Python environment..."
101
+ @unset CONDA_PREFIX && cd $(PYGRAPHINA_DIR ) && maturin develop && cd ..
102
+
103
+ .PHONY : wheel
104
+ wheel : # # Build the wheel file for PyGraphina
105
+ @echo " Make the Python wheel file..."
106
+ @cd $(PYGRAPHINA_DIR ) && maturin build --release --out $(WHEEL_DIR ) --auditwheel check && cd ..
107
+
108
+ .PHONY : wheel-manylinux
109
+ wheel-manylinux : # # Build the wheel file for PyGraphina (manylinux version using Zig)
110
+ @echo " Make the Python wheel file..."
111
+ @cd $(PYGRAPHINA_DIR ) && maturin build --release --out $(WHEEL_DIR ) --auditwheel check --zig && cd ..
112
+
113
+ .PHONY : test_py
114
+ test_py : develop_py # # Run Python tests
115
+ @echo " Running Python tests..."
116
+ @poetry run pytest $(PYGRAPHINA_DIR ) /tests
117
+
118
+ .PHONY : publish_py
119
+ publish_py : wheel # # Publish the PyGraphina wheel to PyPI (needs PYPI_TOKEN to be set)
120
+ @echo " Publishing the PyGraphina wheel to PyPI..."
121
+ @echo " Found wheel file: $( WHEEL_FILE) "
122
+ @twine upload -u __token__ -p $(PYPI_TOKEN ) $(WHEEL_FILE )
123
+
124
+ .PHONY : generat_ci
125
+ generate_ci : # # Generate CI configuration files (GitHub Actions workflow)
126
+ @echo " Generating CI configuration files..."
127
+ @cd $(PYGRAPHINA_DIR ) && maturin generate-ci --zig --pytest --platform all \
128
+ -o ../.github/workflows/ci.yml github && cd ..
0 commit comments