From 3f82a6ffb61f4ca3bdfee4951c764d0730599b6d Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 1 Mar 2022 18:37:59 -0500 Subject: [PATCH 1/4] python3Packages.lark: 1.0.0 -> 1.1.2 python3Packages.lark: disable nearley test Requires unpackaged Js2Py library, which has other unpackaged subdependencies... --- .../development/python-modules/lark/default.nix | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkgs/development/python-modules/lark/default.nix b/pkgs/development/python-modules/lark/default.nix index 6c29a662524c..8fc32539d69d 100644 --- a/pkgs/development/python-modules/lark/default.nix +++ b/pkgs/development/python-modules/lark/default.nix @@ -3,17 +3,18 @@ , fetchFromGitHub , python , regex +, pytestCheckHook }: buildPythonPackage rec { pname = "lark"; - version = "1.0.0"; + version = "1.1.2"; src = fetchFromGitHub { owner = "lark-parser"; repo = "lark"; rev = version; - sha256 = "0pfvjh4ydc49gs6m8b3ip85c8nd4da2bhz9714fwcyl3hdp33q7n"; + sha256 = "sha256-Y1bDSiFnqAKTlIcd8aAgtc+I3TLnWF8hhQK2ez96TQs="; }; # Optional import, but fixes some re known bugs & allows advanced regex features @@ -26,15 +27,11 @@ buildPythonPackage rec { "lark.grammars" ]; - checkPhase = '' - runHook preCheck + checkInputs = [ pytestCheckHook ]; - # Official way to run the tests. Runs unittest internally. - # pytest produces issues with some test resource paths (relies on __main__) - ${python.interpreter} -m tests - - runHook postCheck - ''; + disabledTestPaths = [ + "tests/test_nearley/test_nearley.py" # requires unpackaged Js2Py library + ]; meta = with lib; { description = "A modern parsing library for Python, implementing Earley & LALR(1) and an easy interface"; From 66ad56106dd061e475a265922b315bf3f23423bc Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 1 Mar 2022 21:07:03 -0500 Subject: [PATCH 2/4] pdm: fix error due to wrong pdm-pep517 version --- pkgs/tools/package-management/pdm/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/package-management/pdm/default.nix b/pkgs/tools/package-management/pdm/default.nix index e9db7f63fba6..4e59333ed79b 100644 --- a/pkgs/tools/package-management/pdm/default.nix +++ b/pkgs/tools/package-management/pdm/default.nix @@ -47,6 +47,9 @@ buildPythonApplication rec { hash = "sha256:1dizf9j3z7zk4lxvnszwx63xzd9r68f2iva5sszzf8s8na831dvd"; }) ]; + postPatch = '' + substituteInPlace pyproject.toml --replace "pdm-pep517>=0.9,<0.10" "pdm-pep517" + ''; propagatedBuildInputs = [ blinker From 92faf51e39bce8aae6e19d83c28c07f16cf1a833 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 1 Mar 2022 21:07:40 -0500 Subject: [PATCH 3/4] python3Packages.hypothesmith: compatibility with lark Expected old name 'lark-parser', so updated the requirement to 'lark' --- pkgs/development/python-modules/hypothesmith/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/python-modules/hypothesmith/default.nix b/pkgs/development/python-modules/hypothesmith/default.nix index 3ce0f068fec9..ee8b897154bd 100644 --- a/pkgs/development/python-modules/hypothesmith/default.nix +++ b/pkgs/development/python-modules/hypothesmith/default.nix @@ -9,10 +9,15 @@ buildPythonPackage rec { sha256 = "0fb7b3fd03d76eddd4474b0561e1c2662457593a74cc300fd27e5409cd4d7922"; }; + postPatch = '' + substituteInPlace setup.py --replace "lark-parser" "lark" + ''; + propagatedBuildInputs = [ hypothesis lark libcst ]; checkInputs = [ black parso pytestCheckHook pytest-cov pytest-xdist ]; + pytestFlagsArray = [ "-v" ]; # tests are fairly slow, prevents timeout due to no stdout printing pythonImportsCheck = [ "hypothesmith" ]; meta = with lib; { From 17e776eeb5150b6b24f03cef56f7f24dde4cd7e1 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Wed, 2 Mar 2022 08:42:27 -0500 Subject: [PATCH 4/4] python3Packages.kaldi-active-grammar: fix build Update patches --- .../kaldi-active-grammar/0001-stub.patch | 26 ++++++++++--------- .../kaldi-active-grammar/0002-exec-path.patch | 8 +++--- .../kaldi-active-grammar/default.nix | 2 ++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pkgs/development/python-modules/kaldi-active-grammar/0001-stub.patch b/pkgs/development/python-modules/kaldi-active-grammar/0001-stub.patch index 4ebe5472b44a..597907c14be6 100644 --- a/pkgs/development/python-modules/kaldi-active-grammar/0001-stub.patch +++ b/pkgs/development/python-modules/kaldi-active-grammar/0001-stub.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 66e6d49..78f7b42 100644 +index 17c7032..12ed398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,23 +1,6 @@ +@@ -1,87 +1,12 @@ cmake_minimum_required(VERSION 3.13.0) project(kaldi_binaries) @@ -24,9 +24,8 @@ index 66e6d49..78f7b42 100644 -endif() - set(BINARIES - tools/openfst/bin/fstarcsort${CMAKE_EXECUTABLE_SUFFIX} - tools/openfst/bin/fstcompile${CMAKE_EXECUTABLE_SUFFIX} -@@ -29,63 +12,6 @@ set(LIBRARIES + ) + set(LIBRARIES src/lib/libkaldi-dragonfly${CMAKE_SHARED_LIBRARY_SUFFIX} ) @@ -87,30 +86,33 @@ index 66e6d49..78f7b42 100644 - message(FATAL_ERROR "KALDI_BRANCH not set! Use 'origin/master'?") - # set(KALDI_BRANCH "origin/master") -endif() - +- message("MAKE_EXE = ${MAKE_EXE}") message("PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}") -@@ -99,63 +25,4 @@ message("CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}") + message("PYTHON_INCLUDE_DIR = ${PYTHON_INCLUDE_DIR}") +@@ -94,65 +19,4 @@ message("CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}") # CXXFLAGS are set and exported in kaldi-configure-wrapper.sh -if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - set(STRIP_LIBS_COMMAND find src/lib tools/openfst/lib -name *${CMAKE_SHARED_LIBRARY_SUFFIX} | xargs strip) -- set(STRIP_DST_COMMAND find ${DST} | xargs strip) +- # set(STRIP_DST_COMMAND find ${DST} [[[other specifiers]]] | xargs strip) - if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin") - list(APPEND STRIP_LIBS_COMMAND -x) -- list(APPEND STRIP_DST_COMMAND -x) +- # list(APPEND STRIP_DST_COMMAND -x) - endif() +- # set(STRIP_LIBS_COMMAND true) +- set(STRIP_DST_COMMAND true) - ExternalProject_Add(kaldi - GIT_CONFIG advice.detachedHead=false - GIT_REPOSITORY https://github.com/daanzu/kaldi-fork-active-grammar.git - GIT_TAG ${KALDI_BRANCH} - GIT_SHALLOW TRUE -- CONFIGURE_COMMAND sed -i.bak -e "s/status=0/exit 0/g" tools/extras/check_dependencies.sh && cp ${PROJECT_SOURCE_DIR}/building/kaldi-configure-wrapper.sh src/ +- CONFIGURE_COMMAND sed -i.bak -e "s/status=0/exit 0/g" tools/extras/check_dependencies.sh && sed -i.bak -e "s/openfst_add_CXXFLAGS = -g -O2/openfst_add_CXXFLAGS = -g0 -O3/g" tools/Makefile && cp ${PROJECT_SOURCE_DIR}/building/kaldi-configure-wrapper.sh src/ - BUILD_IN_SOURCE TRUE -- BUILD_COMMAND ${MATHLIB_BUILD_COMMAND} && cd tools && ${MAKE_EXE} ${MAKE_FLAGS} && cd openfst && autoreconf && cd ../../src && bash ./kaldi-configure-wrapper.sh ./configure ${KALDI_CONFIG_FLAGS} && ${MAKE_EXE} ${MAKE_FLAGS} depend && ${MAKE_EXE} ${MAKE_FLAGS} dragonfly dragonflybin bin fstbin lmbin +- BUILD_COMMAND ${MATHLIB_BUILD_COMMAND} && cd tools && ${MAKE_EXE} ${MAKE_FLAGS} && cd openfst && autoreconf && cd ../../src && bash ./kaldi-configure-wrapper.sh ./configure ${KALDI_CONFIG_FLAGS} && ${MAKE_EXE} ${MAKE_FLAGS} depend && ${MAKE_EXE} ${MAKE_FLAGS} dragonfly - LIST_SEPARATOR " " -- INSTALL_COMMAND ${STRIP_LIBS_COMMAND} && mkdir -p ${DST} && cp ${BINARIES} ${LIBRARIES} ${DST} +- INSTALL_COMMAND ${STRIP_LIBS_COMMAND} && mkdir -p ${DST} && cp ${BINARIES} ${LIBRARIES} ${DST} && ${STRIP_DST_COMMAND} - ) -endif() - diff --git a/pkgs/development/python-modules/kaldi-active-grammar/0002-exec-path.patch b/pkgs/development/python-modules/kaldi-active-grammar/0002-exec-path.patch index 60f50d707db0..3a45ea7e104d 100644 --- a/pkgs/development/python-modules/kaldi-active-grammar/0002-exec-path.patch +++ b/pkgs/development/python-modules/kaldi-active-grammar/0002-exec-path.patch @@ -1,5 +1,5 @@ diff --git a/kaldi_active_grammar/utils.py b/kaldi_active_grammar/utils.py -index 0b70c7f..21e1d62 100644 +index 823f997..3850336 100644 --- a/kaldi_active_grammar/utils.py +++ b/kaldi_active_grammar/utils.py @@ -79,7 +79,7 @@ elif sys.platform.startswith('linux'): platform = 'linux' @@ -8,10 +8,10 @@ index 0b70c7f..21e1d62 100644 -exec_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'exec', platform) +exec_dir = '/' - library_extension = dict(windows='.dll', linux='.so', macos='.dylib')[platform] - subprocess_seperator = '^&' if platform == 'windows' else ';' -@@ -89,13 +89,13 @@ class ExternalProcess(object): + import ush + +@@ -87,13 +87,13 @@ class ExternalProcess(object): shell = ush.Shell(raise_on_error=True) diff --git a/pkgs/development/python-modules/kaldi-active-grammar/default.nix b/pkgs/development/python-modules/kaldi-active-grammar/default.nix index d5a906dd733b..46fc619b4cb3 100644 --- a/pkgs/development/python-modules/kaldi-active-grammar/default.nix +++ b/pkgs/development/python-modules/kaldi-active-grammar/default.nix @@ -50,6 +50,8 @@ buildPythonPackage rec { nativeBuildInputs = [ scikit-build cmake ]; propagatedBuildInputs = [ ush requests numpy cffi ]; + doCheck = false; # no tests exist + meta = with lib; { description = "Python Kaldi speech recognition"; homepage = "https://github.com/daanzu/kaldi-active-grammar";