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

feat: more py deps for audio and image processing #1271

Open
wants to merge 5 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
5 changes: 5 additions & 0 deletions docs/pages/docs/guides/configuring-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/providers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
Expand Down Expand Up @@ -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<bool> {
let is_used = ["requirements.txt", "pyproject.toml", "Pipfile"]
.iter()
Expand Down
Loading