Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] copy dll / so via build.rs instead of using makefile #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ test-all: ## run tests quickly with the default Python

compile-rust: ## compile new rust lib
@cd pyext-myrustlib;RUSTFLAGS="-C target-cpu=native" cargo build --release
@cp pyext-myrustlib/target/release/libmyrustlib.so myrustlib.so

compile-c: ## compile new c lib
@cd pyext-myclib;python3 setup.py build_ext -i
10 changes: 10 additions & 0 deletions pyext-myrustlib/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// build.rs
use std::fs;

fn main() {
let source_ext = if cfg!(windows) { "dll" } else { "so" };
let target_ext = if cfg!(windows) { "pyd" } else { "so" };
let _ = fs::copy(format!("target/release/myrustlib.{ext}", ext= source_ext),
format!("../myrustlib.{}", target_ext));
println!("created python lib");
}
2 changes: 1 addition & 1 deletion pyext-myrustlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn count_doubles_memreplace(_py: Python, val: &str) -> PyResult<u64> {
if c1 == c2 {
total += 1;
}
mem::replace(&mut c1, c2);
let _ = mem::replace(&mut c1, c2);
}
}

Expand Down