This is also posted on Discord.
This is something of a continuation of this support post.
First off, I’m trying to build a different package (Chapterize-Audiobooks) than the one at hand here. That has a python dependency: vosk. Vosk is not already part of nixpkgs (no
pkgs.python3Packages.vosk) so I am trying to build it as a package:{ lib, pkgs, buildPythonPackage, fetchFromGitHub, ... }: buildPythonPackage rec { pname = "vosk"; version = "0.3.50"; src = fetchFromGitHub { owner = "alphacep"; repo = "vosk-api"; rev = "v${version}"; # The easiest way to get the sha256 is to build it and let it fail # the error message should include the correct sha256 sha256 = "sha256-E0Xl+TbI06ArHSk1t6DsXLUlfMQZGKQMTp7smGxgp2Y="; }; doCheck = false; pyproject = true; buildsystem = with pkgs.python3Packages; [ setuptools ]; meta = { description = ''[this is long]''; homepage = "https://github.com/alphacep/vosk-api"; license = lib.licenses.asl20; platforms = lib.platforms.all; badPlatforms = [ ]; }; }But it isn’t working. I get
ERROR Source /nix/var/nix/builds/nix-50774-401767848/source does not appear to be a Python project: no pyproject.toml or setup.py. However, Vosk does have asetup.upjust atpython/setup.pyinstead of top-level. In fact, it’s even in PyPi to install viapip. (This isn’t working. Trying... src = fetchPyPi { inherit pname, version; sha-256 = ""; }; ...just gives a bunch of HTTP 404 errors and
error: cannot download vosk-0.3.45.tar.gz from any mirror.)Is there a way I can tell the package to check python/setup.py? Or better yet, an already packaged Vosk I can use in the main build?
I found this forum post that talks about packaging Vosk, but doesn’t really report success: https://discourse.nixos.org/t/vosk-a-python-package-not-in-nixpkgs/71858/3
That was resolved with a neat sourceRoot = "${src.name}/python";
I’m trying to build Vosk for python:
{
lib,
pkgs,
buildPythonPackage,
fetchFromGitHub,
...
}:
buildPythonPackage rec {
pname = "vosk";
version = "0.3.50";
src = fetchFromGitHub {
owner = "alphacep";
repo = "vosk-api";
rev = "v${version}";
sha256 = "sha256-E0Xl+TbI06ArHSk1t6DsXLUlfMQZGKQMTp7smGxgp2Y=";
};
sourceRoot = "${src.name}/python";
doCheck = false;
pyproject = true;
buildsystem = with pkgs.python3Packages; [
setuptools
wheel
];
meta = {
description = "Offline open source speech recognition API based on Kaldi and Vosk";
homepage = "https://github.com/alphacep/vosk-api";
license = lib.licenses.asl20;
platforms = lib.platforms.all;
badPlatforms = [ ];
};
}
But I am getting an error that I have no idea what to do with:
> Traceback (most recent call last):
> File "/nix/store/ggihaikni67b0p8wmw74skjia305lmxb-python3.13-pyproject-hooks-1.2.0/lib/python3.13/site-packages/pyproject_hooks/_impl.py", line 402, in _call_hook
> raise BackendUnavailable(
> ...<4 lines>...
> )
> pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'
>
> ERROR Backend 'setuptools.build_meta:__legacy__' is not available.
uh, how can I fix this?