mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-06 09:41:39 -05:00

The pytesseract package needs to have the `tesseract` executable available at runtime to work. By default, the Python package looks for the `tesseract` executable in the PATH. This doesn't work here, so we need to override the `tesseract_cmd` with the path to the `tesseract` executable we pulled in from Nix. I did this with a patch [based on how pytesseract is set up in Nixpkgs][1]. The patching code feels a bit fiddly. I don't know the idiomatic way to do this sort of thing. I included a test that will fail if pytesseract cannot find the `tesseract` executable. The test passed for me with both `preferWheels = true` and `preferWheels = false`, but I only included one in the test suite here, not sure if it makes sense to have both—the actual patching code had to be a bit different depending on whether the source was a wheel or not. [1]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/pytesseract/tesseract-binary.patch
13 lines
349 B
Nix
13 lines
349 B
Nix
{ poetry2nix, runCommand, python3 }:
|
|
let
|
|
env = poetry2nix.mkPoetryEnv {
|
|
python = python3;
|
|
pyproject = ./pyproject.toml;
|
|
poetrylock = ./poetry.lock;
|
|
preferWheels = true;
|
|
};
|
|
py = env.python;
|
|
in
|
|
runCommand "pytesseract-test" { } ''
|
|
${env}/bin/python -c 'import pytesseract; print(pytesseract.get_tesseract_version())' > $out
|
|
''
|