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

test: ensure apt *and* python c extensions work properly #1222

Open
wants to merge 2 commits into
base: main
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
9 changes: 9 additions & 0 deletions examples/python-numpy/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
import numpy as np
import pandas as pd
import subprocess

print(np)
print(pd)
Expand All @@ -8,3 +10,10 @@
print(arr)

print("Hello from Python numpy and pandas")

# with the wrong LD_LIBRARY_PATH, this will fail with a GLIBC version mismatch
result = subprocess.run(["apt", "--version"], capture_output=True, text=True)
print(result.stdout)

# fail if subprocess fails!
sys.exit(result.returncode)
11 changes: 9 additions & 2 deletions src/providers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ impl PythonProvider {
}

// Many Python packages need some C headers to be available
// stdenv.cc.cc.lib -> https://discourse.nixos.org/t/nixos-with-poetry-installed-pandas-libstdc-so-6-cannot-open-shared-object-file/8442/3
setup.add_pkgs_libs(vec!["zlib".to_string(), "stdenv.cc.cc.lib".to_string()]);
//
// - https://discourse.nixos.org/t/nixos-with-poetry-installed-pandas-libstdc-so-6-cannot-open-shared-object-file/8442/3
// - https://github.com/mcdonc/.nixconfig/blob/e7885ad18b7980f221e59a21c91b8eb02795b541/videos/pydev/script.rst
//
// Some packages (like stdenv.cc.cc.lib) may conflict with other system commands and cause libc version conflicts
// since LD_LIBRARY_PATH is mutated by `add_pkgs_libs`
//

setup.add_pkgs_libs(vec!["zlib".to_string()]);
setup.add_nix_pkgs(&[Pkg::new("gcc")]);

Ok(Some(setup))
Expand Down
3 changes: 3 additions & 0 deletions tests/docker_run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ async fn run_image(name: &str, cfg: Option<Config>) -> String {
}
};

assert!(_status_code == Some(0), "Failed to run image successfully");

let reader = BufReader::new(child.stdout.unwrap());
reader
.lines()
Expand Down Expand Up @@ -1051,6 +1053,7 @@ async fn test_python_numpy() {
let name = simple_build("./examples/python-numpy").await.unwrap();
let output = run_image(&name, None).await;
assert!(output.contains("Hello from Python numpy and pandas"));
assert!(output.contains("apt is a commandline package manager"));
}

#[tokio::test]
Expand Down
Loading