6 Commits

2 changed files with 82 additions and 18 deletions

View File

@@ -1,3 +1,19 @@
-------------------------------------------------------------------
Tue Jun 17 07:04:15 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Switch to pyproject macros to build and install the Python bindings.
-------------------------------------------------------------------
Wed Apr 9 09:22:59 UTC 2025 - Marguerite Su <i@marguerite.su>
- python binding still need by libkkc, reenable
- modern python packaging
-------------------------------------------------------------------
Sun Apr 6 07:41:41 UTC 2025 - Marguerite Su <i@marguerite.su>
- no consumer for perl/ruby/python3 bindings, bcond_with them
-------------------------------------------------------------------
Thu Mar 13 23:53:04 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>

View File

@@ -16,6 +16,9 @@
#
%bcond_without python
%bcond_with perl
%bcond_with ruby
Name: marisa
Version: 0.2.6
Release: 0
@@ -27,16 +30,30 @@ Source: https://github.com/s-yata/marisa-trie/archive/v%{version}/%{name
Source99: baselibs.conf
BuildRequires: gcc-c++
BuildRequires: libtool
%if %{with perl}
BuildRequires: perl
%endif
BuildRequires: pkg-config
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: ruby-devel
%if %{with python}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: python-rpm-macros
BuildRequires: swig
%endif
%if %{with ruby}
BuildRequires: ruby-devel
%endif
Provides: marisa-trie = %{version}
Obsoletes: marisa-trie < %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if %{with python}
%define python_subpackage_only 1
%python_subpackages
%endif
%description
Matching Algorithm with Recursively Implemented StorAge (MARISA) is a
static and space-efficient trie data structure. And libmarisa is a C++
@@ -54,6 +71,7 @@ Group: System/Libraries
%description -n libmarisa0
The libmarisa0 package contains runtime libraries for marisa.
%if %{with perl}
%package -n perl-marisa
Summary: Perl bindings for %{name}
Group: Development/Libraries/Perl
@@ -63,14 +81,19 @@ Requires: %{name} = %{version}
%description -n perl-marisa
Perl bindings for %{name}.
%package -n python3-marisa
Summary: Python3 bindings for %{name}
%endif
%if %{with python}
%package -n python-marisa
Summary: Python bindings for %{name}
Group: Development/Libraries/Python
Requires: %{name} = %{version}
%description -n python3-marisa
Python3 bindings for %{name}.
%description -n python-marisa
Python bindings for %{name}.
%endif
%if %{with ruby}
%package -n ruby-marisa
Summary: Ruby bindings for %{name}
Group: Development/Languages/Ruby
@@ -79,16 +102,23 @@ Requires: ruby
%description -n ruby-marisa
Ruby bindings for %{name}.
%endif
%package devel
%package -n marisa-devel
Summary: Development files for %{name}
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}
%if %{with perl}
Requires: perl-marisa = %{version}
%endif
%if %{with python}
Requires: python3-marisa = %{version}
%endif
%if %{with ruby}
Requires: ruby-marisa = %{version}
%endif
%description devel
%description -n marisa-devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
@@ -101,24 +131,30 @@ autoreconf -fiv
make %{?_smp_mflags}
# build ruby
%if %{with ruby}
pushd bindings/ruby
ruby extconf.rb --with-opt-include=../../include --with-opt-lib=../../lib/marisa/.libs --vendor
make %{?_smp_mflags}
popd
%endif
# build python
%if %{with python}
pushd bindings/python
swig -Wall -c++ -python -py3 -outdir . ../marisa-swig.i
mv ../marisa-swig_wrap.cxx .
python3 setup.py build_ext --include-dirs=../../include --library-dirs=../../lib/marisa/.libs
python3 setup.py build
export CPPFLAGS="-I../../include -L../../lib/marisa/.libs"
%pyproject_wheel
popd
%endif
# build perl
%if %{with perl}
pushd bindings/perl
%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" INC="-I../../include" LIBS="-L../../lib/marisa/.libs"
make %{?_smp_mflags}
popd
%endif
%install
make install DESTDIR=%{buildroot}
@@ -126,17 +162,21 @@ make install DESTDIR=%{buildroot}
rm -rf %{buildroot}%{_libdir}/libmarisa.{la,a}
# install ruby
%if %{with ruby}
pushd bindings/ruby
make install DESTDIR=%{buildroot} hdrdir=%{_includedir}/ruby-%{rb_ver} rubyhdrdir=%{_includedir}/ruby-%{rb_ver}
popd
%endif
# install python
%if %{with python}
pushd bindings/python
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
rm -rf %{buildroot}%{python3_sitearch}/__pycache__
%pyproject_install
popd
%endif
# install perl
%if %{with perl}
pushd bindings/perl
make install DESTDIR=%{buildroot}
rm -rf %{buildroot}%{perl_vendorarch}/auto/marisa/.packlist
@@ -144,6 +184,7 @@ rm -rf %{buildroot}%{perl_vendorarch}/benchmark.pl
rm -rf %{buildroot}%{perl_vendorarch}/sample.pl
popd
sed -i '1s/^=head2 .*:/=head2/' %{buildroot}%{perl_archlib}/perllocal.pod
%endif
%post -n libmarisa0 -p /sbin/ldconfig
@@ -166,24 +207,31 @@ sed -i '1s/^=head2 .*:/=head2/' %{buildroot}%{perl_archlib}/perllocal.pod
%{_libdir}/libmarisa.so.0
%{_libdir}/libmarisa.so.0.0.0
%if %{with ruby}
%files -n ruby-marisa
%defattr(-,root,root)
%{rb_vendorarchdir}/%{name}.so
%files -n python3-marisa
%endif
%if %{with python}
%files %{python_files marisa}
%defattr(-,root,root)
%{python3_sitearch}/_marisa.*.so
%{python3_sitearch}/marisa.py
%{python3_sitearch}/marisa-0.0.0-py%{py3_ver}.egg-info
%{python_sitearch}/_marisa.*.so
%{python_sitearch}/marisa.py
%{python_sitearch}/marisa-0.0.0.dist-info
%{python_sitearch}/__pycache__/marisa.cpython-*.pyc
%endif
%if %{with perl}
%files -n perl-marisa
%defattr(-,root,root)
%{perl_archlib}/perllocal.pod
%dir %{perl_vendorarch}/auto/
%{perl_vendorarch}/auto/marisa
%{perl_vendorarch}/marisa.pm
%endif
%files devel
%files -n marisa-devel
%defattr(-,root,root)
%{_includedir}/%{name}
%{_includedir}/%{name}.h