Skip to content

Commit

Permalink
Install gcc and clibs for python provider by default (#468)
Browse files Browse the repository at this point in the history
* install gcc for python provider by default

* update tests and clippy

* remove printlnt
  • Loading branch information
coffee-cup authored Aug 30, 2022
1 parent 333ce56 commit dc4c77c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/providers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ impl PythonProvider {

if PythonProvider::is_django(app, env)? && PythonProvider::is_using_postgres(app, env)? {
// Django with Postgres requires postgresql and gcc on top of the original python packages
pkgs.append(&mut vec![Pkg::new("postgresql"), Pkg::new("gcc")]);
pkgs.append(&mut vec![Pkg::new("postgresql")]);
}

let mut setup_phase = Phase::setup(Some(pkgs));

// Numpy needs some C headers to be available
// 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
if PythonProvider::uses_dep(app, "numpy")? || PythonProvider::uses_dep(app, "pandas")? {
setup_phase.add_pkgs_libs(vec!["zlib".to_string(), "stdenv.cc.cc.lib".to_string()]);
}
setup_phase.add_pkgs_libs(vec!["zlib".to_string(), "stdenv.cc.cc.lib".to_string()]);
setup_phase.add_nix_pkgs(vec![Pkg::new("gcc")]);

Ok(Some(setup_phase))
}
Expand Down Expand Up @@ -323,6 +322,7 @@ impl PythonProvider {
))
}

#[allow(dead_code)]
fn uses_dep(app: &App, dep: &str) -> Result<bool> {
let requirements_usage = app.includes_file("requirements.txt")
&& app
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ expression: plan
"nixPackages": [
{
"name": "python38"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python_2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ expression: plan
"nixPackages": [
{
"name": "python27"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python_2_runtime.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ expression: plan
"nixPackages": [
{
"name": "python27"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions tests/snapshots/generate_plan_tests__python_django.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ expression: plan
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions tests/snapshots/generate_plan_tests__python_numpy.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ expression: plan
"nixPackages": [
{
"name": "python38"
},
{
"name": "gcc"
}
],
"nixLibraries": [
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python_poetry.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ expression: plan
"nixPackages": [
{
"name": "python38"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python_procfile.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ expression: plan
"nixPackages": [
{
"name": "python38"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions tests/snapshots/generate_plan_tests__python_setuptools.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ expression: plan
"nixPackages": [
{
"name": "python38"
},
{
"name": "gcc"
}
],
"nixLibraries": [
"zlib",
"stdenv.cc.cc.lib"
]
},
{
Expand Down

0 comments on commit dc4c77c

Please sign in to comment.