From d416d842bc65c952344c6d890f0158b2da20195f Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 21 Jan 2025 15:59:30 -0700 Subject: [PATCH 1/4] feat: add dependencies for audio and PDF processing when building python - Integrate `ffmpeg-headless` for handling audio dependencies when using `pydub` or `pymovie`. - Include `poppler_utils` to support PDF processing for `pdf2image`. --- src/providers/python.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/providers/python.rs b/src/providers/python.rs index 585e3f9fc..fbfda0091 100644 --- a/src/providers/python.rs +++ b/src/providers/python.rs @@ -187,6 +187,16 @@ impl PythonProvider { setup.add_pkgs_libs(vec!["cairo".to_string()]); } + // both of these packages shell out to the ffmpeg binary + if PythonProvider::uses_dep(app, "pydub")? || PythonProvider::uses_dep(app, "pymovie")? { + setup.add_nix_pkgs(&[Pkg::new("ffmpeg-headless")]); + } + + // shells out to the pdfinfo binary + if PythonProvider::uses_dep(app, "pdf2image")? { + setup.add_nix_pkgs(&[Pkg::new("poppler_utils")]); + } + // 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()]); @@ -551,6 +561,7 @@ impl PythonProvider { )) } + // TODO contains on the contents of a toml is not great, could trigger based on comments, etc fn uses_dep(app: &App, dep: &str) -> Result { let is_used = ["requirements.txt", "pyproject.toml", "Pipfile"] .iter() From 81aae5bb5c5de4687e99201df03c0ffd4c4efa27 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 21 Jan 2025 16:14:40 -0700 Subject: [PATCH 2/4] style: lint fix --- src/providers/python.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/python.rs b/src/providers/python.rs index fbfda0091..4b280678d 100644 --- a/src/providers/python.rs +++ b/src/providers/python.rs @@ -191,9 +191,9 @@ impl PythonProvider { if PythonProvider::uses_dep(app, "pydub")? || PythonProvider::uses_dep(app, "pymovie")? { setup.add_nix_pkgs(&[Pkg::new("ffmpeg-headless")]); } - + // shells out to the pdfinfo binary - if PythonProvider::uses_dep(app, "pdf2image")? { + if PythonProvider::uses_dep(app, "pdf2image")? { setup.add_nix_pkgs(&[Pkg::new("poppler_utils")]); } From e34610e2c24060e5e68f3b567b7777a9214865f3 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 21 Jan 2025 16:14:48 -0700 Subject: [PATCH 3/4] docs: add guidance on selecting Nix packages for builds Generated-by: aiautocommit --- docs/pages/docs/guides/configuring-builds.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/pages/docs/guides/configuring-builds.md b/docs/pages/docs/guides/configuring-builds.md index 09d74f75e..d13ee4587 100644 --- a/docs/pages/docs/guides/configuring-builds.md +++ b/docs/pages/docs/guides/configuring-builds.md @@ -40,6 +40,11 @@ provider (e.g. Node, Cargo, Python) will also installed. It is recommended to install packages from Nix rather than Apt if they are available. You can search for Nix packages [here](https://search.nixos.org/packages?channel=unstable). +It's common for these to be many packages with a similar name and it can be hard to determine which one to pick. Here are some tips: + +* If your application is shelling out to a command (i.e. your application expects a specific binary to be available on `$PATH`) look for a package that the binary you need in the `Programs provided` and add it as a `nixPkgs` entry. +* If your application needs a shared library, look for a package that contains a `dev` output. You can target just that `dev` (shared library) output by adding the suffix `.dev` to the `nixLibs` definition. + ## Custom build command You can override the build command with From 637d8815ceba8fba7ffa51546353692835cf48bb Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 21 Jan 2025 16:19:09 -0700 Subject: [PATCH 4/4] docs: fix lists in configuring builds guide Generated-by: aiautocommit --- docs/pages/docs/guides/configuring-builds.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/docs/guides/configuring-builds.md b/docs/pages/docs/guides/configuring-builds.md index d13ee4587..db35b9954 100644 --- a/docs/pages/docs/guides/configuring-builds.md +++ b/docs/pages/docs/guides/configuring-builds.md @@ -42,8 +42,8 @@ It is recommended to install packages from Nix rather than Apt if they are avail It's common for these to be many packages with a similar name and it can be hard to determine which one to pick. Here are some tips: -* If your application is shelling out to a command (i.e. your application expects a specific binary to be available on `$PATH`) look for a package that the binary you need in the `Programs provided` and add it as a `nixPkgs` entry. -* If your application needs a shared library, look for a package that contains a `dev` output. You can target just that `dev` (shared library) output by adding the suffix `.dev` to the `nixLibs` definition. +- If your application is shelling out to a command (i.e. your application expects a specific binary to be available on `$PATH`) look for a package that the binary you need in the `Programs provided` and add it as a `nixPkgs` entry. +- If your application needs a shared library, look for a package that contains a `dev` output. You can target just that `dev` (shared library) output by adding the suffix `.dev` to the `nixLibs` definition. ## Custom build command