[packages/python-fasttext] - fix for numpy 2.x issue; release 2
qboosh
qboosh at pld-linux.org
Mon Jan 26 20:41:13 CET 2026
commit 697f53b26261c77ac35a0b26202a44c3b3387f64
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Mon Jan 26 20:41:18 2026 +0100
- fix for numpy 2.x issue; release 2
fasttext-numpy2.patch | 11 +++++++++++
python-fasttext.spec | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/python-fasttext.spec b/python-fasttext.spec
index 4d0acd2..f6dba96 100644
--- a/python-fasttext.spec
+++ b/python-fasttext.spec
@@ -1,5 +1,6 @@
#
# Conditional build:
+%bcond_without tests # unit tests
%bcond_without python2 # CPython 2.x module
%bcond_without python3 # CPython 3.x module
@@ -7,23 +8,30 @@ Summary: fasttext Python bindings
Summary(pl.UTF-8): Wiązania Pythona do biblioteki fasttext
Name: python-fasttext
Version: 0.9.3
-Release: 1
+Release: 2
License: MIT
Group: Libraries/Python
#Source0Download: https://pypi.org/simple/fasttext/
Source0: https://files.pythonhosted.org/packages/source/f/fasttext/fasttext-%{version}.tar.gz
# Source0-md5: 0ccab4e897c80f2d85402d03c8f7734b
+Patch0: fasttext-numpy2.patch
URL: https://pypi.org/project/fasttext/
BuildRequires: libstdc++-devel >= 6:7
%if %{with python2}
BuildRequires: python-devel >= 1:2.7
BuildRequires: python-pybind11 >= 2.2
BuildRequires: python-setuptools >= 1:0.7.0
+%if %{with tests}
+BuildRequires: python-numpy
+%endif
%endif
%if %{with python3}
BuildRequires: python3-devel >= 1:3.4
BuildRequires: python3-pybind11 >= 2.2
BuildRequires: python3-setuptools >= 1:0.7.0
+%if %{with tests}
+BuildRequires: python3-numpy
+%endif
%endif
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.714
@@ -54,14 +62,34 @@ reprezentacji słów i klasyfikacji zdań.
%prep
%setup -q -n fasttext-%{version}
+%patch -P0 -p1
+
+# extracted from runtests.py in git (limited to unit tests)
+cat >unit_tests.py <<EOF
+import unittest
+from fasttext.tests import gen_unit_tests
+
+suite = unittest.TestLoader().loadTestsFromTestCase(gen_unit_tests(verbose=True))
+unittest.TextTestRunner(verbosity=3).run(suite)
+EOF
%build
%if %{with python2}
%py_build
+
+%if %{with tests}
+PYTHONPATH=$(readlink -f build-2/lib.*) \
+%{__python} unit_tests.py
+%endif
%endif
%if %{with python3}
%py3_build
+
+%if %{with tests}
+PYTHONPATH=$(readlink -f build-3/lib.*) \
+%{__python3} unit_tests.py
+%endif
%endif
%install
@@ -71,10 +99,13 @@ rm -rf $RPM_BUILD_ROOT
%py_install
%py_postclean
+%{__rm} -r $RPM_BUILD_ROOT%{py_sitedir}/fasttext/tests
%endif
%if %{with python3}
%py3_install
+
+%{__rm} -r $RPM_BUILD_ROOT%{py3_sitedir}/fasttext/tests
%endif
%clean
diff --git a/fasttext-numpy2.patch b/fasttext-numpy2.patch
new file mode 100644
index 0000000..89b01a0
--- /dev/null
+++ b/fasttext-numpy2.patch
@@ -0,0 +1,11 @@
+--- fasttext-0.9.3/python/fasttext_module/fasttext/FastText.py.orig 2024-06-12 10:55:55.000000000 +0200
++++ fasttext-0.9.3/python/fasttext_module/fasttext/FastText.py 2026-01-26 19:59:43.125607977 +0100
+@@ -236,7 +236,7 @@ class _FastText:
+ else:
+ probs, labels = ([], ())
+
+- return labels, np.array(probs, copy=False)
++ return labels, np.asarray(probs)
+
+ def get_input_matrix(self):
+ """
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-fasttext.git/commitdiff/697f53b26261c77ac35a0b26202a44c3b3387f64
More information about the pld-cvs-commit
mailing list