summaryrefslogtreecommitdiff
path: root/sentencepiece.spec
blob: e1a22fd79652f5846b98d2196081bc697ac084e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Name:		sentencepiece
Version:	0.1.98
Release:	1
Summary:	An unsupervised text tokenizer and detokenizer
License:	Apache-2.0
URL:		https://github.com/google/sentencepiece
Source0:	https://github.com/google/sentencepiece/archive/v%{version}.tar.gz
BuildRequires:	gcc-c++ gcc autoconf pkgconfig protobuf-compiler protobuf
BuildRequires:  cmake >= 3.14.0
Requires:       protobuf protobuf-compiler

%description
SentencePiece is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation 
systems where the vocabulary size is predetermined prior to the neural model training.

%global debug_package %{nil}

%prep
%autosetup -p1 -n %{name}-%{version}

%package libs
Summary:	Runtime libraries for SentencePiece

%description libs
This package contains the libraries for SentencePiece.

%package tools
Summary:	Tools for SentencePiece
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%description tools
This package contains tools for manipulate models for SentencePiece.

%package devel
Summary:	Libraries and header files for SentencePiece
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%description devel
This package contains header files to develop a software using SentencePiece.

%build
mkdir -p cmake/build
cd cmake/build
cmake ../../ -DCMAKE_CXX_FLAGS="-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare"\
             -DCMAKE_C_FLAGS="-D_FORTIFY_SOURCE=2"\
             -DCMAKE_BUILD_TYPE=Release\
             -DSPM_USE_BUILTIN_PROTOBUF=ON\
             -DSPM_ENABLE_SHARED=OFF\
             -DSPM_BUILD_TEST=ON\
             -DCMAKE_INSTALL_LIBDIR=%{buildroot}%{_libdir}\
             -DCMAKE_INSTALL_BINDIR=%{buildroot}%{_bindir}\
             -DCMAKE_INSTALL_INCDIR=%{buildroot}%{_includedir}

make -j24 V=1
make CTEST_OUTPUT_ON_FAILURE=1 test
cd ../../

%install
cd cmake/build
make install
sed -i'' -e "s,%{buildroot},," %{buildroot}%{_libdir}/pkgconfig/sentencepiece.pc
sed -i'' -e "s,${prefix}/lib,%{_libdir}," %{buildroot}%{_libdir}/pkgconfig/sentencepiece.pc


%files libs
%doc README.md
%license LICENSE
%{_libdir}/*.so.*

%files tools
%{_bindir}/spm*

%files
%defattr(-,root,root)
%{_bindir}/spm_*
%{_libdir}/*.a
%{_libdir}/pkgconfig/*
%{_includedir}/sentencepiece*.h

%changelog
* Mon Apr 15 2024 youser<1328699220@qq.com>
- Initial package