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,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
cython,
hypothesis,
numpy,
# tests
hypothesis,
pytestCheckHook,
pythonOlder,
# passthru
blis,
numpy_1,
gitUpdater,
@ -18,8 +24,6 @@ buildPythonPackage rec {
version = "1.2.1";
pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub {
owner = "explosion";
repo = "cython-blis";
@ -27,25 +31,41 @@ buildPythonPackage rec {
hash = "sha256-krUqAEPxJXdlolSbV5R0ZqrWaFuXh7IxSeFTsCr6iss=";
};
preCheck = ''
# remove src module, so tests use the installed module instead
rm -rf ./blis
'';
build-system = [
setuptools
cython
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 ];
pythonImportsCheck = [ "blis" ];
nativeCheckInputs = [
hypothesis
pytestCheckHook
];
pythonImportsCheck = [ "blis" ];
# remove src module, so tests use the installed module instead
preCheck = ''
rm -rf ./blis
'';
passthru = {
tests = {
@ -58,11 +78,11 @@ buildPythonPackage rec {
};
};
meta = with lib; {
changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${src.tag}";
meta = {
changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${version}";
description = "BLAS-like linear algebra library";
homepage = "https://github.com/explosion/cython-blis";
license = licenses.bsd3;
maintainers = with maintainers; [ nickcao ];
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ nickcao ];
};
}

View File

@ -1,24 +1,30 @@
{
lib,
stdenv,
buildPythonPackage,
cairocffi,
cython,
en_core_web_sm,
fetchFromGitHub,
# build-system
cython,
poetry-core,
setuptools,
# dependencies
cairocffi,
igraph,
leidenalg,
pandas,
poetry-core,
pyarrow,
pytestCheckHook,
pythonOlder,
scipy,
setuptools,
spacy-lookups-data,
spacy,
spacy-lookups-data,
toolz,
tqdm,
wasabi,
# tests
en_core_web_sm,
pytestCheckHook,
}:
buildPythonPackage rec {
@ -26,8 +32,6 @@ buildPythonPackage rec {
version = "0.9.5";
pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub {
owner = "jboynyc";
repo = "textnets";
@ -63,8 +67,8 @@ buildPythonPackage rec {
];
nativeCheckInputs = [
pytestCheckHook
en_core_web_sm
pytestCheckHook
];
pythonImportsCheck = [ "textnets" ];
@ -74,16 +78,25 @@ buildPythonPackage rec {
rm -r textnets
'';
disabledTests = [
# Test fails: Throws a UserWarning asking the user to install `textnets[fca]`.
"test_context"
];
disabledTests =
[
# 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";
homepage = "https://textnets.readthedocs.io";
changelog = "https://github.com/jboynyc/textnets/blob/v${version}/HISTORY.rst";
license = licenses.gpl3Only;
maintainers = with maintainers; [ jboy ];
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ jboy ];
};
}