From eba3f6034610d2f676ce5b6a02b6ebadb2d21dee Mon Sep 17 00:00:00 2001 From: Nicolas Brousse Date: Mon, 3 Jan 2022 05:50:19 -0800 Subject: [PATCH] Fix build issues due to maturin & py03 versions (#37) * bump maturin and pyo3 versions * update to support MacOS dylib extentions * update package config to use a build.rs and fix linking issue on macOS see https://pyo3.rs/master/building_and_distribution.html#macos --- Cargo.toml | 5 ++++- Makefile | 16 +++++++++++----- Pipfile | 2 +- build.rs | 3 +++ 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 75501b5..ac0b6a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,9 @@ license = "MIT" name = "tantivy" crate-type = ["cdylib"] +[build-dependencies] +pyo3-build-config = "0.15.1" + [dependencies] chrono = "0.4.19" tantivy = "0.13.2" @@ -17,7 +20,7 @@ itertools = "0.9.0" futures = "0.3.5" [dependencies.pyo3] -version = "0.13.2" +version = "0.14.5" features = ["extension-module"] [package.metadata.maturin] diff --git a/Makefile b/Makefile index e2bd18f..ce7bf0a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,23 @@ +ifeq ($(shell UNAME),Darwin) + EXT := dylib +else + EXT := so +endif + source_files := $(wildcard src/*.rs) -all: tantivy/tantivy.so +all: tantivy/tantivy.$(EXT) PHONY: test format -test: tantivy/tantivy.so +test: tantivy/tantivy.$(EXT) python3 -m pytest format: rustfmt src/*.rs -tantivy/tantivy.so: target/debug/libtantivy.so - cp target/debug/libtantivy.so tantivy/tantivy.so +tantivy/tantivy.$(EXT): target/debug/libtantivy.$(EXT) + cp target/debug/libtantivy.$(EXT) tantivy/tantivy.so -target/debug/libtantivy.so: $(source_files) +target/debug/libtantivy.$(EXT): $(source_files) cargo build diff --git a/Pipfile b/Pipfile index e11d515..fb9a298 100644 --- a/Pipfile +++ b/Pipfile @@ -4,7 +4,7 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] -maturin = ">=0.7.7" +maturin = ">=0.12.0" pytest = ">=4.0" e1839a8 = {path = "."} diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..a781ce1 --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + pyo3_build_config::add_extension_module_link_args(); +}