Skip to content

Commit

Permalink
build: Update pyo3 dependency to version 0.20.0 and add coitrees depe…
Browse files Browse the repository at this point in the history
…ndency
  • Loading branch information
cauliyang committed Oct 26, 2023
1 parent ce29ce1 commit d286e9a
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py-coitrees/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "py-coitrees"
version = "0.1.0"
version = "0.3.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -9,4 +9,5 @@ name = "coitrees"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.20.0", features = ["extension-module"] }
pyo3 = { version = "0.20.0", features = ["abi3-py38", "extension-module"] }
coitrees = { path = "../" }
70 changes: 70 additions & 0 deletions py-coitrees/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
SHELL := /bin/bash

ts := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

.PHONY: help
help: ## This help message
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"

.PHONY: build
build: nightly dev-packages ## Builds Rust code and rscannls Python modules
maturin build

.PHONY: build-release
build-release: nightly dev-packages ## Build rscannls module in release mode
maturin build --release

.PHONY: nightly
nightly: ## Set rust compiler to nightly version
rustup override set nightly

.PHONY: install
install: nightly dev-packages ## Install scannls module into current virtualenv
maturin develop --release

.PHONY: publish
publish: ## Publish crate on Pypi
poetry run maturin publish

.PHONY: clean
clean: ## Clean up build artifacts
cargo clean
find . \( -type f -name "*.py[co]" -o -type d -name "__pycache__" \) -delete && echo "Removed pycs and __pycache__"
rm -f data/*log

.PHONY: dev-packages
dev-packages: ## Install Python development packages for project
poetry install

.PHONY: cargo-test
cargo-test: ## Run cargo tests only
cargo test

.PHONY: test
test: cargo-test dev-packages install quicktest ## Intall rscannls module and run tests

.PHONY: quicktest
quicktest: ## Run tests on already installed hyperjson module
poetry run pytest tests

.PHONY: bench
bench: ## Run benchmarks
poetry run pytest benchmarks

.PHONY: bench-compare
bench-compare: nightly dev-packages install ## Run benchmarks and compare results with other JSON encoders
poetry run pytest benchmarks --compare

.PHONY: build-profile
build-profile: ## Builds binary for profiling
cd profiling && poetry run cargo build --release

# Setup instructions here:
# https://gist.github.com/dlaehnemann/df31787c41bd50c0fe223df07cf6eb89
.PHONY: profile
profile: OUTPUT_PATH = measurements/flame-$(ts).svg
profile: FLAGS=booleans --iterations 10000
profile: nightly build-profile ## Run perf-based profiling (only works on Linux!)
perf record --call-graph dwarf,16384 -e cpu-clock -F 997 target/release/profiling $(FLAGS)
time perf script | stackcollapse-perf.pl | c++filt | flamegraph.pl > $(OUTPUT_PATH)
@echo "$(OUTPUT_PATH)"

0 comments on commit d286e9a

Please sign in to comment.