Skip to content

Commit 38ed608

Browse files
committed
chore: make tar building less hacky
1 parent 707d18c commit 38ed608

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

guests/python/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
downloads/
2-
python-lib.tar

guests/python/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ fn configure_linker() {
3535

3636
fn bundle_python_lib() {
3737
println!("cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR");
38+
let tar_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("python-lib.tar");
3839
let Ok(lib_dir) = std::env::var("PYO3_CROSS_LIB_DIR") else {
39-
std::fs::write("python-lib.tar", b"").unwrap();
40+
std::fs::write(&tar_path, b"").unwrap();
4041
return;
4142
};
4243
let lib_dir = PathBuf::from(lib_dir);
4344

44-
// TODO: use build-dir once it is stable, see https://github.com/rust-lang/cargo/issues/14125
45-
let file = File::create("python-lib.tar").unwrap();
45+
let file = File::create(&tar_path).unwrap();
4646
let mut archive = tar::Builder::new(file);
4747
for entry in walkdir::WalkDir::new(&lib_dir) {
4848
let entry = entry.unwrap();

guests/python/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ impl ScalarUDFImpl for Test {
7373
}
7474

7575
fn root() -> Option<Vec<u8>> {
76-
Some(std::include_bytes!("../python-lib.tar").to_vec())
76+
const ROOT_TAR: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/python-lib.tar"));
77+
Some(ROOT_TAR.to_vec())
7778
}
7879

7980
fn udfs() -> Vec<Arc<dyn ScalarUDFImpl>> {

0 commit comments

Comments
 (0)