Skip to content

Commit 3099136

Browse files
committed
move lib code from main to binding
1 parent 10d027b commit 3099136

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sgl-router/Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# Python bindings directory
55
PYTHON_DIR := bindings/python
66

7+
# Auto-detect CPU cores and cap at reasonable limit to avoid thread exhaustion
8+
# Can be overridden: make python-dev JOBS=4
9+
NPROC := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 8)
10+
JOBS ?= $(shell echo $$(($(NPROC) > 16 ? 16 : $(NPROC))))
11+
712
# Check if sccache is available and set RUSTC_WRAPPER accordingly
813
SCCACHE := $(shell which sccache 2>/dev/null)
914
ifdef SCCACHE
@@ -88,12 +93,12 @@ sccache-stop: ## Stop the sccache server
8893

8994
# Python bindings (maturin) targets
9095
python-dev: ## Build Python bindings in development mode (fast, debug build)
91-
@echo "Building Python bindings in development mode..."
92-
@cd $(PYTHON_DIR) && maturin develop
96+
@echo "Building Python bindings in development mode (using $(JOBS) parallel jobs with sccache)..."
97+
@cd $(PYTHON_DIR) && CARGO_BUILD_JOBS=$(JOBS) maturin develop
9398

9499
python-build: ## Build Python wheel (release mode with vendored OpenSSL)
95-
@echo "Building Python wheel (release, vendored OpenSSL)..."
96-
@cd $(PYTHON_DIR) && maturin build --release --out dist --features vendored-openssl
100+
@echo "Building Python wheel (release, vendored OpenSSL, using $(JOBS) parallel jobs with sccache)..."
101+
@cd $(PYTHON_DIR) && CARGO_BUILD_JOBS=$(JOBS) maturin build --release --out dist --features vendored-openssl
97102

98103
python-build-release: python-build ## Alias for python-build
99104

@@ -118,7 +123,7 @@ python-test: ## Run Python tests
118123

119124
python-check: ## Check Python package with twine
120125
@echo "Checking Python package..."
121-
@cd $(PYTHON_DIR) && maturin build --release --out dist --features vendored-openssl
126+
@cd $(PYTHON_DIR) && CARGO_BUILD_JOBS=$(JOBS) maturin build --release --out dist --features vendored-openssl
122127
@pip install twine 2>/dev/null || true
123128
@twine check $(PYTHON_DIR)/dist/*
124129
@echo "Python package check passed!"

0 commit comments

Comments
 (0)