Skip to content

Commit 5553a77

Browse files
authored
python312Packages.textnets: fix build on darwin, python312Packages.blis: fallback to generic architecure when needed (#382088)
2 parents 5757120 + c6afce4 commit 5553a77

File tree

2 files changed

+65
-32
lines changed

2 files changed

+65
-32
lines changed
Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
22
lib,
3+
stdenv,
34
buildPythonPackage,
45
fetchFromGitHub,
6+
7+
# build-system
58
setuptools,
69
cython,
7-
hypothesis,
810
numpy,
11+
12+
# tests
13+
hypothesis,
914
pytestCheckHook,
10-
pythonOlder,
15+
16+
# passthru
1117
blis,
1218
numpy_1,
1319
gitUpdater,
@@ -18,34 +24,48 @@ buildPythonPackage rec {
1824
version = "1.2.1";
1925
pyproject = true;
2026

21-
disabled = pythonOlder "3.9";
22-
2327
src = fetchFromGitHub {
2428
owner = "explosion";
2529
repo = "cython-blis";
2630
tag = "release-v${version}";
2731
hash = "sha256-krUqAEPxJXdlolSbV5R0ZqrWaFuXh7IxSeFTsCr6iss=";
2832
};
2933

30-
preCheck = ''
31-
# remove src module, so tests use the installed module instead
32-
rm -rf ./blis
33-
'';
34-
3534
build-system = [
3635
setuptools
3736
cython
3837
numpy
3938
];
4039

40+
env =
41+
# Fallback to generic architectures when necessary:
42+
# https://github.com/explosion/cython-blis?tab=readme-ov-file#building-blis-for-alternative-architectures
43+
lib.optionalAttrs
44+
(
45+
# error: [Errno 2] No such file or directory: '/build/source/blis/_src/make/linux-cortexa57.jsonl'
46+
(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)
47+
48+
# clang: error: unknown argument '-mavx512pf'; did you mean '-mavx512f'?
49+
# Patching blis/_src/config/knl/make_defs.mk to remove the said flag does not work
50+
|| (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64)
51+
)
52+
{
53+
BLIS_ARCH = "generic";
54+
};
55+
4156
dependencies = [ numpy ];
4257

58+
pythonImportsCheck = [ "blis" ];
59+
4360
nativeCheckInputs = [
4461
hypothesis
4562
pytestCheckHook
4663
];
4764

48-
pythonImportsCheck = [ "blis" ];
65+
# remove src module, so tests use the installed module instead
66+
preCheck = ''
67+
rm -rf ./blis
68+
'';
4969

5070
passthru = {
5171
tests = {
@@ -58,11 +78,11 @@ buildPythonPackage rec {
5878
};
5979
};
6080

61-
meta = with lib; {
62-
changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${src.tag}";
81+
meta = {
82+
changelog = "https://github.com/explosion/cython-blis/releases/tag/release-${version}";
6383
description = "BLAS-like linear algebra library";
6484
homepage = "https://github.com/explosion/cython-blis";
65-
license = licenses.bsd3;
66-
maintainers = with maintainers; [ nickcao ];
85+
license = lib.licenses.bsd3;
86+
maintainers = with lib.maintainers; [ nickcao ];
6787
};
6888
}

pkgs/development/python-modules/textnets/default.nix

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
{
22
lib,
3+
stdenv,
34
buildPythonPackage,
4-
cairocffi,
5-
cython,
6-
en_core_web_sm,
75
fetchFromGitHub,
6+
7+
# build-system
8+
cython,
9+
poetry-core,
10+
setuptools,
11+
12+
# dependencies
13+
cairocffi,
814
igraph,
915
leidenalg,
1016
pandas,
11-
poetry-core,
1217
pyarrow,
13-
pytestCheckHook,
14-
pythonOlder,
1518
scipy,
16-
setuptools,
17-
spacy-lookups-data,
1819
spacy,
20+
spacy-lookups-data,
1921
toolz,
2022
tqdm,
2123
wasabi,
24+
25+
# tests
26+
en_core_web_sm,
27+
pytestCheckHook,
2228
}:
2329

2430
buildPythonPackage rec {
2531
pname = "textnets";
2632
version = "0.9.5";
2733
pyproject = true;
2834

29-
disabled = pythonOlder "3.9";
30-
3135
src = fetchFromGitHub {
3236
owner = "jboynyc";
3337
repo = "textnets";
@@ -63,8 +67,8 @@ buildPythonPackage rec {
6367
];
6468

6569
nativeCheckInputs = [
66-
pytestCheckHook
6770
en_core_web_sm
71+
pytestCheckHook
6872
];
6973

7074
pythonImportsCheck = [ "textnets" ];
@@ -74,16 +78,25 @@ buildPythonPackage rec {
7478
rm -r textnets
7579
'';
7680

77-
disabledTests = [
78-
# Test fails: Throws a UserWarning asking the user to install `textnets[fca]`.
79-
"test_context"
80-
];
81+
disabledTests =
82+
[
83+
# Test fails: Throws a UserWarning asking the user to install `textnets[fca]`.
84+
"test_context"
85+
]
86+
++ lib.optionals stdenv.hostPlatform.isDarwin [
87+
# MemoryError: ("cairo returned CAIRO_STATUS_NO_MEMORY: b'out of memory'", 1)
88+
"test_plot_backbone"
89+
"test_plot_filtered"
90+
"test_plot_layout"
91+
"test_plot_projected"
92+
"test_plot_scaled"
93+
];
8194

82-
meta = with lib; {
95+
meta = {
8396
description = "Text analysis with networks";
8497
homepage = "https://textnets.readthedocs.io";
8598
changelog = "https://github.com/jboynyc/textnets/blob/v${version}/HISTORY.rst";
86-
license = licenses.gpl3Only;
87-
maintainers = with maintainers; [ jboy ];
99+
license = lib.licenses.gpl3Only;
100+
maintainers = with lib.maintainers; [ jboy ];
88101
};
89102
}

0 commit comments

Comments
 (0)