python312Packages.textnets: fix build on darwin, python312Packages.blis: fallback to generic architecure when needed (#382088)

This commit is contained in:
Nick Cao 2025-02-14 18:55:36 -05:00 committed by GitHub
commit 5553a77a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 65 additions and 32 deletions

View File

@ -1,13 +1,19 @@
{ {
lib, lib,
stdenv,
buildPythonPackage, buildPythonPackage,
fetchFromGitHub, fetchFromGitHub,
# build-system
setuptools, setuptools,
cython, cython,
hypothesis,
numpy, numpy,
# tests
hypothesis,
pytestCheckHook, pytestCheckHook,
pythonOlder,
# passthru
blis, blis,
numpy_1, numpy_1,
gitUpdater, gitUpdater,
@ -18,8 +24,6 @@ buildPythonPackage rec {
version = "1.2.1"; version = "1.2.1";
pyproject = true; pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "explosion"; owner = "explosion";
repo = "cython-blis"; repo = "cython-blis";
@ -27,25 +31,41 @@ buildPythonPackage rec {
hash = "sha256-krUqAEPxJXdlolSbV5R0ZqrWaFuXh7IxSeFTsCr6iss="; hash = "sha256-krUqAEPxJXdlolSbV5R0ZqrWaFuXh7IxSeFTsCr6iss=";
}; };
preCheck = ''
# remove src module, so tests use the installed module instead
rm -rf ./blis
'';
build-system = [ build-system = [
setuptools setuptools
cython cython
numpy numpy
]; ];
env =
# Fallback to generic architectures when necessary:
# https://github.com/explosion/cython-blis?tab=readme-ov-file#building-blis-for-alternative-architectures
lib.optionalAttrs
(
# error: [Errno 2] No such file or directory: '/build/source/blis/_src/make/linux-cortexa57.jsonl'
(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)
# clang: error: unknown argument '-mavx512pf'; did you mean '-mavx512f'?
# Patching blis/_src/config/knl/make_defs.mk to remove the said flag does not work
|| (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64)
)
{
BLIS_ARCH = "generic";
};
dependencies = [ numpy ]; dependencies = [ numpy ];
pythonImportsCheck = [ "blis" ];
nativeCheckInputs = [ nativeCheckInputs = [
hypothesis hypothesis
pytestCheckHook pytestCheckHook
]; ];
pythonImportsCheck = [ "blis" ]; # remove src module, so tests use the installed module instead
preCheck = ''
rm -rf ./blis
'';
passthru = { passthru = {
tests = { tests = {
@ -58,11 +78,11 @@ buildPythonPackage rec {
}; };
}; };
meta = with lib; { meta = {
changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${src.tag}"; changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${version}";
description = "BLAS-like linear algebra library"; description = "BLAS-like linear algebra library";
homepage = "https://github.com/explosion/cython-blis"; homepage = "https://github.com/explosion/cython-blis";
license = licenses.bsd3; license = lib.licenses.bsd3;
maintainers = with maintainers; [ nickcao ]; maintainers = with lib.maintainers; [ nickcao ];
}; };
} }

View File

@ -1,24 +1,30 @@
{ {
lib, lib,
stdenv,
buildPythonPackage, buildPythonPackage,
cairocffi,
cython,
en_core_web_sm,
fetchFromGitHub, fetchFromGitHub,
# build-system
cython,
poetry-core,
setuptools,
# dependencies
cairocffi,
igraph, igraph,
leidenalg, leidenalg,
pandas, pandas,
poetry-core,
pyarrow, pyarrow,
pytestCheckHook,
pythonOlder,
scipy, scipy,
setuptools,
spacy-lookups-data,
spacy, spacy,
spacy-lookups-data,
toolz, toolz,
tqdm, tqdm,
wasabi, wasabi,
# tests
en_core_web_sm,
pytestCheckHook,
}: }:
buildPythonPackage rec { buildPythonPackage rec {
@ -26,8 +32,6 @@ buildPythonPackage rec {
version = "0.9.5"; version = "0.9.5";
pyproject = true; pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "jboynyc"; owner = "jboynyc";
repo = "textnets"; repo = "textnets";
@ -63,8 +67,8 @@ buildPythonPackage rec {
]; ];
nativeCheckInputs = [ nativeCheckInputs = [
pytestCheckHook
en_core_web_sm en_core_web_sm
pytestCheckHook
]; ];
pythonImportsCheck = [ "textnets" ]; pythonImportsCheck = [ "textnets" ];
@ -74,16 +78,25 @@ buildPythonPackage rec {
rm -r textnets rm -r textnets
''; '';
disabledTests = [ disabledTests =
# Test fails: Throws a UserWarning asking the user to install `textnets[fca]`. [
"test_context" # Test fails: Throws a UserWarning asking the user to install `textnets[fca]`.
]; "test_context"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# MemoryError: ("cairo returned CAIRO_STATUS_NO_MEMORY: b'out of memory'", 1)
"test_plot_backbone"
"test_plot_filtered"
"test_plot_layout"
"test_plot_projected"
"test_plot_scaled"
];
meta = with lib; { meta = {
description = "Text analysis with networks"; description = "Text analysis with networks";
homepage = "https://textnets.readthedocs.io"; homepage = "https://textnets.readthedocs.io";
changelog = "https://github.com/jboynyc/textnets/blob/v${version}/HISTORY.rst"; changelog = "https://github.com/jboynyc/textnets/blob/v${version}/HISTORY.rst";
license = licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with maintainers; [ jboy ]; maintainers = with lib.maintainers; [ jboy ];
}; };
} }