forked from pool/python-fasttext
Compare commits
6 Commits
Author | SHA256 | Date | |
---|---|---|---|
51843ce6c3 | |||
2ee36eddd0 | |||
8499af3db4 | |||
2d577a62ab | |||
4d0b36e1c1 | |||
b37c5fa6f2 |
35
no-static-lib.patch
Normal file
35
no-static-lib.patch
Normal file
@@ -0,0 +1,35 @@
|
||||
From: Jiri Slaby <jslaby@suse.cz>
|
||||
Subject: [PATCH] no static lib
|
||||
Patch-mainline: no
|
||||
|
||||
We do not want those. Link against shared instead.
|
||||
---
|
||||
CMakeLists.txt | 11 +----------
|
||||
1 file changed, 1 insertion(+), 10 deletions(-)
|
||||
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -57,22 +57,13 @@ if (NOT MSVC)
|
||||
endif()
|
||||
|
||||
add_library(fasttext-shared SHARED ${SOURCE_FILES} ${HEADER_FILES})
|
||||
-add_library(fasttext-static STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
-add_library(fasttext-static_pic STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
set_target_properties(fasttext-shared PROPERTIES OUTPUT_NAME fasttext
|
||||
SOVERSION "${fasttext_VERSION_MAJOR}")
|
||||
-set_target_properties(fasttext-static PROPERTIES OUTPUT_NAME fasttext)
|
||||
-set_target_properties(fasttext-static_pic PROPERTIES OUTPUT_NAME fasttext_pic
|
||||
- POSITION_INDEPENDENT_CODE True)
|
||||
add_executable(fasttext-bin src/main.cc)
|
||||
-target_link_libraries(fasttext-bin pthread fasttext-static)
|
||||
+target_link_libraries(fasttext-bin pthread fasttext-shared)
|
||||
set_target_properties(fasttext-bin PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME fasttext)
|
||||
install (TARGETS fasttext-shared
|
||||
LIBRARY DESTINATION lib)
|
||||
-install (TARGETS fasttext-static
|
||||
- ARCHIVE DESTINATION lib)
|
||||
-install (TARGETS fasttext-static_pic
|
||||
- ARCHIVE DESTINATION lib)
|
||||
install (TARGETS fasttext-bin
|
||||
RUNTIME DESTINATION bin
|
||||
PUBLIC_HEADER DESTINATION include/fasttext)
|
25
proper-lib-dir.patch
Normal file
25
proper-lib-dir.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
From: Jiri Slaby <jslaby@suse.cz>
|
||||
Subject: [PATCH] proper lib dir
|
||||
Patch-mainline: no
|
||||
|
||||
Do not install to /usr/lib. Use CMAKE_INSTALL_LIBDIR instead (lib64 on
|
||||
64bit).
|
||||
|
||||
Actually use CMAKE_INSTALL_* everywhere.
|
||||
---
|
||||
CMakeLists.txt | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -63,7 +63,7 @@ add_executable(fasttext-bin src/main.cc)
|
||||
target_link_libraries(fasttext-bin pthread fasttext-shared)
|
||||
set_target_properties(fasttext-bin PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME fasttext)
|
||||
install (TARGETS fasttext-shared
|
||||
- LIBRARY DESTINATION lib)
|
||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install (TARGETS fasttext-bin
|
||||
- RUNTIME DESTINATION bin
|
||||
- PUBLIC_HEADER DESTINATION include/fasttext)
|
||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fasttext)
|
34
py-link-against-shared.patch
Normal file
34
py-link-against-shared.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
From: Jiri Slaby <jslaby@suse.cz>
|
||||
Subject: [PATCH] py: link against shared
|
||||
Patch-mainline: no
|
||||
|
||||
Link the python bindings to the now present libfasttext.so. It reduces
|
||||
the duplication as well as the compilation time.
|
||||
---
|
||||
setup.py | 10 ++--------
|
||||
1 file changed, 2 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -54,19 +54,13 @@ else:
|
||||
del sys.argv[coverage_index]
|
||||
coverage = True
|
||||
|
||||
-fasttext_src_files = map(str, os.listdir(FASTTEXT_SRC))
|
||||
-fasttext_src_cc = list(filter(lambda x: x.endswith('.cc'), fasttext_src_files))
|
||||
-
|
||||
-fasttext_src_cc = list(
|
||||
- map(lambda x: str(os.path.join(FASTTEXT_SRC, x)), fasttext_src_cc)
|
||||
-)
|
||||
-
|
||||
ext_modules = [
|
||||
Extension(
|
||||
str('fasttext_pybind'),
|
||||
[
|
||||
str('python/fasttext_module/fasttext/pybind/fasttext_pybind.cc'),
|
||||
- ] + fasttext_src_cc,
|
||||
+ ],
|
||||
+ libraries=[str('fasttext')],
|
||||
include_dirs=[
|
||||
# Path to pybind11 headers
|
||||
get_pybind_include(),
|
@@ -1,3 +1,20 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 19 13:15:46 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Convert to libalternatives on SLE-16-based and newer systems
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Oct 10 05:20:36 UTC 2024 - Jiri Slaby <jslaby@suse.cz>
|
||||
|
||||
- switch to cmake + ninja
|
||||
* the former builds a proper lib
|
||||
- package the shared library, fasttext binary and -devel properly
|
||||
(create new %package's for those)
|
||||
- add patches to fit our needs:
|
||||
* no-static-lib.patch
|
||||
* proper-lib-dir.patch
|
||||
* py-link-against-shared.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Apr 21 12:24:59 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-fasttext
|
||||
#
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -16,10 +16,15 @@
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
%define modname fastText
|
||||
%define sover 0
|
||||
# Using annotation futures and dataclasses
|
||||
%define skip_python36 1
|
||||
%if 0%{?suse_version} > 1500
|
||||
%bcond_without libalternatives
|
||||
%else
|
||||
%bcond_with libalternatives
|
||||
%endif
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-fasttext
|
||||
Version: 0.9.2
|
||||
@@ -30,30 +35,61 @@ URL: https://github.com/facebookresearch/fastText
|
||||
Source: https://github.com/facebookresearch/%{modname}/archive/refs/tags/v%{version}.tar.gz#/%{modname}-%{version}.tar.gz
|
||||
Patch0: reproducible.patch
|
||||
Patch1: gcc13-fix.patch
|
||||
Patch2: no-static-lib.patch
|
||||
Patch3: proper-lib-dir.patch
|
||||
Patch4: py-link-against-shared.patch
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module pybind11-devel}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: cmake
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: ninja
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: fasttext
|
||||
Requires: python-numpy
|
||||
Requires: python-pybind11 >= 2.2
|
||||
Requires: python-setuptools >= 0.7.0
|
||||
Provides: fasttext = %{version}
|
||||
%if %{with libalternatives}
|
||||
BuildRequires: alts
|
||||
Requires: alts
|
||||
%else
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun): update-alternatives
|
||||
%endif
|
||||
# SECTION test requirements
|
||||
BuildRequires: %{python_module numpy}
|
||||
BuildRequires: %{python_module pybind11 >= 2.2}
|
||||
BuildRequires: %{python_module setuptools >= 0.7.0}
|
||||
# /SECTION
|
||||
BuildRequires: fdupes
|
||||
Requires: python-numpy
|
||||
Requires: python-pybind11 >= 2.2
|
||||
Requires: python-setuptools >= 0.7.0
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun):update-alternatives
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
fastText is a library for efficient learning of word
|
||||
representations and sentence classification.
|
||||
|
||||
%package -n fasttext-devel
|
||||
Summary: Development files for fasttext
|
||||
Requires: libfasttext%{sover}
|
||||
|
||||
%description -n fasttext-devel
|
||||
fastText is a library for efficient learning of word
|
||||
representations and sentence classification.
|
||||
|
||||
This package provides the fasttext library development files.
|
||||
|
||||
%package -n libfasttext%{sover}
|
||||
Summary: Library for fast text representation and classification
|
||||
|
||||
%description -n libfasttext%{sover}
|
||||
fastText is a library for efficient learning of word
|
||||
representations and sentence classification.
|
||||
|
||||
This package provides the fasttext library.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n %{modname}-%{version}
|
||||
|
||||
@@ -61,22 +97,32 @@ sed -Ei "1{/^#!\/usr\/bin\/env python/d}" \
|
||||
python/fasttext_module/fasttext/util/util.py
|
||||
|
||||
%build
|
||||
export CXXFLAGS="%{optflags}" CFLAGS="%{optflags}"
|
||||
%make_build
|
||||
pushd .
|
||||
%define __builddir build-cmake
|
||||
%define __builder ninja
|
||||
%cmake
|
||||
%cmake_build
|
||||
popd
|
||||
|
||||
export LDFLAGS=-L%{__builddir}
|
||||
%pyproject_wheel
|
||||
|
||||
%install
|
||||
%cmake_install
|
||||
%pyproject_install
|
||||
%{python_expand :
|
||||
install -Dpm 0755 fasttext %{buildroot}%{_bindir}/fasttext
|
||||
%python_clone -a %{buildroot}%{_bindir}/fasttext
|
||||
%{python_expand :
|
||||
%fdupes %{buildroot}%{$python_sitearch}
|
||||
}
|
||||
|
||||
%check
|
||||
# Tests require 300+MB test data
|
||||
|
||||
%ldconfig_scriptlets -n libfasttext%{sover}
|
||||
|
||||
%pre
|
||||
%python_libalternatives_reset_alternative fasttext
|
||||
|
||||
%post
|
||||
%python_install_alternative fasttext
|
||||
|
||||
@@ -86,10 +132,18 @@ install -Dpm 0755 fasttext %{buildroot}%{_bindir}/fasttext
|
||||
%files %{python_files}
|
||||
%doc README.md docs/
|
||||
%license LICENSE
|
||||
# fasttext.pc.in
|
||||
%python_alternative %{_bindir}/fasttext
|
||||
%{python_sitearch}/fasttext
|
||||
%{python_sitearch}/fasttext-%{version}*-info
|
||||
%{python_sitearch}/fasttext_pybind.*.so
|
||||
%python_alternative %{_bindir}/fasttext
|
||||
|
||||
%files -n fasttext-devel
|
||||
%dir %{_includedir}/fasttext
|
||||
%{_includedir}/fasttext/*.h
|
||||
%{_libdir}/libfasttext.so
|
||||
%{_libdir}/pkgconfig/fasttext.pc
|
||||
|
||||
%files -n libfasttext%{sover}
|
||||
%{_libdir}/libfasttext.so.%{sover}
|
||||
|
||||
%changelog
|
||||
|
Reference in New Issue
Block a user