pydivsufsort 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. pydivsufsort-0.0.0/LICENSE +8 -0
  2. pydivsufsort-0.0.0/MANIFEST.in +4 -0
  3. pydivsufsort-0.0.0/PKG-INFO +164 -0
  4. pydivsufsort-0.0.0/README.md +150 -0
  5. pydivsufsort-0.0.0/build.sh +30 -0
  6. pydivsufsort-0.0.0/libdivsufsort/.git +1 -0
  7. pydivsufsort-0.0.0/libdivsufsort/.gitignore +32 -0
  8. pydivsufsort-0.0.0/libdivsufsort/CHANGELOG.md +21 -0
  9. pydivsufsort-0.0.0/libdivsufsort/CMakeLists.txt +99 -0
  10. pydivsufsort-0.0.0/libdivsufsort/CMakeModules/AppendCompilerFlags.cmake +38 -0
  11. pydivsufsort-0.0.0/libdivsufsort/CMakeModules/CheckFunctionKeywords.cmake +15 -0
  12. pydivsufsort-0.0.0/libdivsufsort/CMakeModules/CheckLFS.cmake +109 -0
  13. pydivsufsort-0.0.0/libdivsufsort/CMakeModules/ProjectCPack.cmake +38 -0
  14. pydivsufsort-0.0.0/libdivsufsort/CMakeModules/cmake_uninstall.cmake.in +36 -0
  15. pydivsufsort-0.0.0/libdivsufsort/LICENSE +21 -0
  16. pydivsufsort-0.0.0/libdivsufsort/README.md +140 -0
  17. pydivsufsort-0.0.0/libdivsufsort/VERSION.cmake +23 -0
  18. pydivsufsort-0.0.0/libdivsufsort/examples/CMakeLists.txt +11 -0
  19. pydivsufsort-0.0.0/libdivsufsort/examples/bwt.c +220 -0
  20. pydivsufsort-0.0.0/libdivsufsort/examples/mksary.c +193 -0
  21. pydivsufsort-0.0.0/libdivsufsort/examples/sasearch.c +165 -0
  22. pydivsufsort-0.0.0/libdivsufsort/examples/suftest.c +164 -0
  23. pydivsufsort-0.0.0/libdivsufsort/examples/unbwt.c +207 -0
  24. pydivsufsort-0.0.0/libdivsufsort/include/CMakeLists.txt +162 -0
  25. pydivsufsort-0.0.0/libdivsufsort/include/config.h.cmake +81 -0
  26. pydivsufsort-0.0.0/libdivsufsort/include/divsufsort.h.cmake +180 -0
  27. pydivsufsort-0.0.0/libdivsufsort/include/divsufsort_private.h +207 -0
  28. pydivsufsort-0.0.0/libdivsufsort/include/lfs.h.cmake +56 -0
  29. pydivsufsort-0.0.0/libdivsufsort/lib/CMakeLists.txt +31 -0
  30. pydivsufsort-0.0.0/libdivsufsort/lib/divsufsort.c +398 -0
  31. pydivsufsort-0.0.0/libdivsufsort/lib/sssort.c +815 -0
  32. pydivsufsort-0.0.0/libdivsufsort/lib/trsort.c +586 -0
  33. pydivsufsort-0.0.0/libdivsufsort/lib/utils.c +381 -0
  34. pydivsufsort-0.0.0/libdivsufsort/pkgconfig/CMakeLists.txt +9 -0
  35. pydivsufsort-0.0.0/libdivsufsort/pkgconfig/libdivsufsort.pc.cmake +11 -0
  36. pydivsufsort-0.0.0/pydivsufsort/__init__.py +26 -0
  37. pydivsufsort-0.0.0/pydivsufsort/divsufsort.py +221 -0
  38. pydivsufsort-0.0.0/pydivsufsort/dll.py +19 -0
  39. pydivsufsort-0.0.0/pydivsufsort/stringalg.cpp +73678 -0
  40. pydivsufsort-0.0.0/pydivsufsort/stringalg.pyx +429 -0
  41. pydivsufsort-0.0.0/pydivsufsort/wonderstring.py +157 -0
  42. pydivsufsort-0.0.0/pydivsufsort.egg-info/PKG-INFO +164 -0
  43. pydivsufsort-0.0.0/pydivsufsort.egg-info/SOURCES.txt +49 -0
  44. pydivsufsort-0.0.0/pydivsufsort.egg-info/dependency_links.txt +1 -0
  45. pydivsufsort-0.0.0/pydivsufsort.egg-info/requires.txt +2 -0
  46. pydivsufsort-0.0.0/pydivsufsort.egg-info/top_level.txt +1 -0
  47. pydivsufsort-0.0.0/pyproject.toml +3 -0
  48. pydivsufsort-0.0.0/setup.cfg +4 -0
  49. pydivsufsort-0.0.0/setup.py +111 -0
  50. pydivsufsort-0.0.0/tests/test_correct.py +235 -0
  51. pydivsufsort-0.0.0/tests/test_interface.py +27 -0
@@ -0,0 +1,8 @@
1
+ Copyright 2020 Louis Abraham
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
@@ -0,0 +1,4 @@
1
+ include build.sh
2
+ include pydivsufsort/stringalg.pyx
3
+ recursive-include libdivsufsort *
4
+
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.1
2
+ Name: pydivsufsort
3
+ Version: 0.0.0
4
+ Summary: String algorithms
5
+ Home-page: https://github.com/louisabraham/pydivsufsort
6
+ Author: Louis Abraham
7
+ Author-email: louis.abraham@yahoo.fr
8
+ License: MIT
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: wheel
13
+ Requires-Dist: numpy
14
+
15
+ [![PyPI
16
+ version](https://badge.fury.io/py/pydivsufsort.svg)](https://badge.fury.io/py/pydivsufsort) [![Downloads](https://pepy.tech/badge/pydivsufsort)](https://pepy.tech/project/pydivsufsort) [![Test](https://github.com/louisabraham/pydivsufsort/actions/workflows/test.yml/badge.svg)](https://github.com/louisabraham/pydivsufsort/actions/workflows/test.yml) [![Build and upload](https://github.com/louisabraham/pydivsufsort/actions/workflows/build-and-upload.yml/badge.svg)](https://github.com/louisabraham/pydivsufsort/actions/workflows/build-and-upload.yml) [![codecov](https://codecov.io/gh/louisabraham/pydivsufsort/branch/master/graph/badge.svg?token=A1BM9U1OLV)](https://codecov.io/gh/louisabraham/pydivsufsort) [![DOI](https://zenodo.org/badge/241137939.svg)](https://zenodo.org/badge/latestdoi/241137939)
17
+
18
+ # `pydivsufsort`: bindings to libdivsufsort
19
+
20
+ `pydivsufsort` prebuilds `libdivsufsort` as a shared library and
21
+ includes it in a Python package with bindings. Wheels are built for Linux, macOS and Windows (32 and 64 bits) using `cibuildwheel` and GitHub Actions. Basically, you should be able to install it with `pip install pydivsufsort` on any system and it should work out of the box. If it doesn't, please create an issue.
22
+
23
+ **Features**:
24
+
25
+ - bindings to `divsufsort` that return numpy arrays
26
+ - handle string, bytes and almost any integer data type (e.g. `int64`) and not only `char`
27
+ - algorithms work even for non char inputs
28
+ - additional string algorithms coded in Cython
29
+
30
+ ## Installation
31
+
32
+ On Linux, macOS and Windows:
33
+
34
+ ```
35
+ python -m pip install pydivsufsort
36
+ ```
37
+
38
+ We provide precompiled wheels for common systems using `cibuildwheel`, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue.
39
+
40
+ ## Features
41
+
42
+ All methods support string, bytes and numpy array inputs, including datatypes greater than `uint8_t` (e.g. `uint64_t`). Below are the signatures of all methods exposed by `pydivsufsort`. To import a method, just do `from pydivsufsort import method_name`. All methods are documented in the docstrings. You can display them with `help(method_name)`.
43
+
44
+ A nicer interface to reuse computations lazily is provided in WonderString but currently undocumented. Please create an issue if you are interested.
45
+
46
+ ### Methods exposed from libdivsufsort
47
+
48
+ - `divsufsort(string)`: suffix array
49
+ - `bw_transform(string)`: Burrows-Wheeler transform
50
+ - `inverse_bw_transform(idx, string)`: inverse Burrows-Wheeler transform
51
+ - `sa_search(string, suffix_array, pattern)`: search for a pattern in a suffix array
52
+
53
+
54
+ ### Additional string algorithms
55
+
56
+ - `kasai(string, suffix_array=None)`: LCP array computation (lazily computes the suffix array if not provided)
57
+ - `lcp_segtree(string, suffix_array=None, lcp=None)`: build a segment tree for LCP queries (lazily computes the suffix array and LCP array if not provided)
58
+ - `lcp_query(segtree, queries)`: query a segment tree for LCP queries. Queries are pairs of indices.
59
+ - `levenshtein(string1, string2)`: Levenshtein distance
60
+ - `most_frequent_substrings(lcp, length, limit=0, minimum_count=1)`: most frequent substrings. See the docstring for details.
61
+ - `common_substrings(string1, string2, limit=25)`: common substrings between two strings.
62
+ - `min_rotation(string)`: minimum rotation of a string
63
+
64
+ ### Example usage
65
+
66
+ ```python
67
+ from pydivsufsort import divsufsort, kasai
68
+
69
+ string_inp = "banana$"
70
+ string_suffix_array = divsufsort(string_inp)
71
+ string_lcp_array = kasai(string_inp, string_suffix_array)
72
+ print(string_suffix_array, string_lcp_array)
73
+ # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0]
74
+
75
+ # You can also convert the string input to integers first
76
+
77
+ import numpy as np
78
+
79
+ int_inp = np.unique(np.array(list(string_inp)), return_inverse=True)[1]
80
+ int_suffix_array = divsufsort(int_inp)
81
+ int_lcp_array = kasai(int_inp, int_suffix_array)
82
+ print(int_suffix_array, int_lcp_array)
83
+ # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0]
84
+ ```
85
+
86
+
87
+ ## Development
88
+
89
+ You can install locally with
90
+
91
+ ```
92
+ pip install -e .
93
+ ```
94
+
95
+ A useful command to iterate quickly when changing Cython code is
96
+
97
+ ```
98
+ python setup.py build_ext --inplace && pytest -s
99
+ ```
100
+
101
+ ### Profiling
102
+
103
+ Profiling can be activated with the environment variable `PROFILE`:
104
+
105
+ ```
106
+ PROFILE=1 python setup.py build_ext --inplace && pytest -s
107
+ ```
108
+
109
+ Here is an example with line_profiler (requires `pip install "line_profiler<4"`):
110
+
111
+ ```
112
+ import line_profiler
113
+ from pydivsufsort import common_substrings
114
+ from pydivsufsort.stringalg import (
115
+ _common_substrings,
116
+ repeated_substrings,
117
+ )
118
+
119
+ s1 = "banana" * 10000
120
+ s2 = "ananas" * 10000
121
+
122
+ func = common_substrings
123
+ profile = line_profiler.LineProfiler(func)
124
+ profile.add_function(_common_substrings)
125
+ profile.add_function(repeated_substrings)
126
+ profile.runcall(func, s1, s2, limit=15)
127
+ profile.print_stats()
128
+ ```
129
+
130
+ ## Testing
131
+
132
+ ```
133
+ pytest
134
+ ```
135
+
136
+ ## Technical details (for performance tweaks)
137
+
138
+ `libdivsufsort` is compiled in both 32 and 64 bits, as [the 32 bits version is faster](https://github.com/y-256/libdivsufsort/issues/21). `pydivsufsort` automatically chooses to use the 32 bits version when possible (aka when the input size is less than `2**31-1`).
139
+
140
+ For best performance, use contiguous arrays. If you have a sliced array, pydivsufsort converts it automatically with [`numpy.ascontiguousarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html).
141
+
142
+ The precompiled libraries use OpenMP. You can disable it by setting the env variable `OMP_NUM_THREADS=1`, and it will yield the same performance as the version compiled without OpenMP
143
+
144
+ The original `libdivsufsort` only supports char as the base type. `pydivsufsort` can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, `pydivsufsort` will automatically change their type (see [#6](https://github.com/louisabraham/pydivsufsort/issues/6)).
145
+
146
+ ## Acknowledgements
147
+
148
+ - [Yuta Mori](https://github.com/y-256) for writing [libdivsufsort](https://github.com/y-256/libdivsufsort)
149
+ - [Sean Law](http://seanlaw.github.io/) for initiating this project and contributing
150
+
151
+ ## Citing
152
+
153
+ If you have used this software in a scientific publication, please cite it using the following BibLaTeX code:
154
+
155
+ ```
156
+ @software{pydivsufsort,
157
+ author = {Louis Abraham},
158
+ title = {pydivsufsort},
159
+ year = 2023,
160
+ publisher = {Zenodo},
161
+ doi = {10.5281/zenodo.7932458},
162
+ url = {https://github.com/louisabraham/pydivsufsort}
163
+ }
164
+ ```
@@ -0,0 +1,150 @@
1
+ [![PyPI
2
+ version](https://badge.fury.io/py/pydivsufsort.svg)](https://badge.fury.io/py/pydivsufsort) [![Downloads](https://pepy.tech/badge/pydivsufsort)](https://pepy.tech/project/pydivsufsort) [![Test](https://github.com/louisabraham/pydivsufsort/actions/workflows/test.yml/badge.svg)](https://github.com/louisabraham/pydivsufsort/actions/workflows/test.yml) [![Build and upload](https://github.com/louisabraham/pydivsufsort/actions/workflows/build-and-upload.yml/badge.svg)](https://github.com/louisabraham/pydivsufsort/actions/workflows/build-and-upload.yml) [![codecov](https://codecov.io/gh/louisabraham/pydivsufsort/branch/master/graph/badge.svg?token=A1BM9U1OLV)](https://codecov.io/gh/louisabraham/pydivsufsort) [![DOI](https://zenodo.org/badge/241137939.svg)](https://zenodo.org/badge/latestdoi/241137939)
3
+
4
+ # `pydivsufsort`: bindings to libdivsufsort
5
+
6
+ `pydivsufsort` prebuilds `libdivsufsort` as a shared library and
7
+ includes it in a Python package with bindings. Wheels are built for Linux, macOS and Windows (32 and 64 bits) using `cibuildwheel` and GitHub Actions. Basically, you should be able to install it with `pip install pydivsufsort` on any system and it should work out of the box. If it doesn't, please create an issue.
8
+
9
+ **Features**:
10
+
11
+ - bindings to `divsufsort` that return numpy arrays
12
+ - handle string, bytes and almost any integer data type (e.g. `int64`) and not only `char`
13
+ - algorithms work even for non char inputs
14
+ - additional string algorithms coded in Cython
15
+
16
+ ## Installation
17
+
18
+ On Linux, macOS and Windows:
19
+
20
+ ```
21
+ python -m pip install pydivsufsort
22
+ ```
23
+
24
+ We provide precompiled wheels for common systems using `cibuildwheel`, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue.
25
+
26
+ ## Features
27
+
28
+ All methods support string, bytes and numpy array inputs, including datatypes greater than `uint8_t` (e.g. `uint64_t`). Below are the signatures of all methods exposed by `pydivsufsort`. To import a method, just do `from pydivsufsort import method_name`. All methods are documented in the docstrings. You can display them with `help(method_name)`.
29
+
30
+ A nicer interface to reuse computations lazily is provided in WonderString but currently undocumented. Please create an issue if you are interested.
31
+
32
+ ### Methods exposed from libdivsufsort
33
+
34
+ - `divsufsort(string)`: suffix array
35
+ - `bw_transform(string)`: Burrows-Wheeler transform
36
+ - `inverse_bw_transform(idx, string)`: inverse Burrows-Wheeler transform
37
+ - `sa_search(string, suffix_array, pattern)`: search for a pattern in a suffix array
38
+
39
+
40
+ ### Additional string algorithms
41
+
42
+ - `kasai(string, suffix_array=None)`: LCP array computation (lazily computes the suffix array if not provided)
43
+ - `lcp_segtree(string, suffix_array=None, lcp=None)`: build a segment tree for LCP queries (lazily computes the suffix array and LCP array if not provided)
44
+ - `lcp_query(segtree, queries)`: query a segment tree for LCP queries. Queries are pairs of indices.
45
+ - `levenshtein(string1, string2)`: Levenshtein distance
46
+ - `most_frequent_substrings(lcp, length, limit=0, minimum_count=1)`: most frequent substrings. See the docstring for details.
47
+ - `common_substrings(string1, string2, limit=25)`: common substrings between two strings.
48
+ - `min_rotation(string)`: minimum rotation of a string
49
+
50
+ ### Example usage
51
+
52
+ ```python
53
+ from pydivsufsort import divsufsort, kasai
54
+
55
+ string_inp = "banana$"
56
+ string_suffix_array = divsufsort(string_inp)
57
+ string_lcp_array = kasai(string_inp, string_suffix_array)
58
+ print(string_suffix_array, string_lcp_array)
59
+ # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0]
60
+
61
+ # You can also convert the string input to integers first
62
+
63
+ import numpy as np
64
+
65
+ int_inp = np.unique(np.array(list(string_inp)), return_inverse=True)[1]
66
+ int_suffix_array = divsufsort(int_inp)
67
+ int_lcp_array = kasai(int_inp, int_suffix_array)
68
+ print(int_suffix_array, int_lcp_array)
69
+ # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0]
70
+ ```
71
+
72
+
73
+ ## Development
74
+
75
+ You can install locally with
76
+
77
+ ```
78
+ pip install -e .
79
+ ```
80
+
81
+ A useful command to iterate quickly when changing Cython code is
82
+
83
+ ```
84
+ python setup.py build_ext --inplace && pytest -s
85
+ ```
86
+
87
+ ### Profiling
88
+
89
+ Profiling can be activated with the environment variable `PROFILE`:
90
+
91
+ ```
92
+ PROFILE=1 python setup.py build_ext --inplace && pytest -s
93
+ ```
94
+
95
+ Here is an example with line_profiler (requires `pip install "line_profiler<4"`):
96
+
97
+ ```
98
+ import line_profiler
99
+ from pydivsufsort import common_substrings
100
+ from pydivsufsort.stringalg import (
101
+ _common_substrings,
102
+ repeated_substrings,
103
+ )
104
+
105
+ s1 = "banana" * 10000
106
+ s2 = "ananas" * 10000
107
+
108
+ func = common_substrings
109
+ profile = line_profiler.LineProfiler(func)
110
+ profile.add_function(_common_substrings)
111
+ profile.add_function(repeated_substrings)
112
+ profile.runcall(func, s1, s2, limit=15)
113
+ profile.print_stats()
114
+ ```
115
+
116
+ ## Testing
117
+
118
+ ```
119
+ pytest
120
+ ```
121
+
122
+ ## Technical details (for performance tweaks)
123
+
124
+ `libdivsufsort` is compiled in both 32 and 64 bits, as [the 32 bits version is faster](https://github.com/y-256/libdivsufsort/issues/21). `pydivsufsort` automatically chooses to use the 32 bits version when possible (aka when the input size is less than `2**31-1`).
125
+
126
+ For best performance, use contiguous arrays. If you have a sliced array, pydivsufsort converts it automatically with [`numpy.ascontiguousarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html).
127
+
128
+ The precompiled libraries use OpenMP. You can disable it by setting the env variable `OMP_NUM_THREADS=1`, and it will yield the same performance as the version compiled without OpenMP
129
+
130
+ The original `libdivsufsort` only supports char as the base type. `pydivsufsort` can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, `pydivsufsort` will automatically change their type (see [#6](https://github.com/louisabraham/pydivsufsort/issues/6)).
131
+
132
+ ## Acknowledgements
133
+
134
+ - [Yuta Mori](https://github.com/y-256) for writing [libdivsufsort](https://github.com/y-256/libdivsufsort)
135
+ - [Sean Law](http://seanlaw.github.io/) for initiating this project and contributing
136
+
137
+ ## Citing
138
+
139
+ If you have used this software in a scientific publication, please cite it using the following BibLaTeX code:
140
+
141
+ ```
142
+ @software{pydivsufsort,
143
+ author = {Louis Abraham},
144
+ title = {pydivsufsort},
145
+ year = 2023,
146
+ publisher = {Zenodo},
147
+ doi = {10.5281/zenodo.7932458},
148
+ url = {https://github.com/louisabraham/pydivsufsort}
149
+ }
150
+ ```
@@ -0,0 +1,30 @@
1
+ #! /bin/bash
2
+
3
+ # doesn't work on Windows
4
+ # we assume we always launch the script
5
+ # from its parent directory
6
+ cd "${0%/*}"
7
+
8
+ git submodule init
9
+ git submodule update
10
+
11
+ rm -rf tempbuild
12
+ mkdir tempbuild
13
+ cd tempbuild
14
+ cmake -DBUILD_DIVSUFSORT64=ON -DBUILD_EXAMPLES=OFF -DUSE_OPENMP=ON $PLATFORM_OPTION ../libdivsufsort
15
+
16
+ # test if we are on Windows
17
+ if [ -n "$WINDIR" ]; then
18
+ cmake --build . --config Release
19
+ OUTPATH="tempbuild/examples/Release/divsufsort"
20
+ else
21
+ make
22
+ OUTPATH="tempbuild/lib/libdivsufsort"
23
+ fi
24
+
25
+ cd ..
26
+
27
+ # copy the two largest files, aka the dll of divsufsort and divsufsort64
28
+ mv $(du $OUTPATH* | sort -nr | head -n2 | cut -f2) pydivsufsort
29
+ rm -rf tempbuild
30
+
@@ -0,0 +1 @@
1
+ gitdir: ../.git/modules/libdivsufsort
@@ -0,0 +1,32 @@
1
+ # Object files
2
+ *.o
3
+ *.ko
4
+ *.obj
5
+ *.elf
6
+
7
+ # Precompiled Headers
8
+ *.gch
9
+ *.pch
10
+
11
+ # Libraries
12
+ *.lib
13
+ *.a
14
+ *.la
15
+ *.lo
16
+
17
+ # Shared objects (inc. Windows DLLs)
18
+ *.dll
19
+ *.so
20
+ *.so.*
21
+ *.dylib
22
+
23
+ # Executables
24
+ *.exe
25
+ *.out
26
+ *.app
27
+ *.i*86
28
+ *.x86_64
29
+ *.hex
30
+
31
+ # CMake files/directories
32
+ build/
@@ -0,0 +1,21 @@
1
+ # libdivsufsort Change Log
2
+
3
+ See full changelog at: https://github.com/y-256/libdivsufsort/commits
4
+
5
+ ## [2.0.1] - 2010-11-11
6
+ ### Fixed
7
+ * Wrong variable used in `divbwt` function
8
+ * Enclose some string variables with double quotation marks in include/CMakeLists.txt
9
+ * Fix typo in include/CMakeLists.txt
10
+
11
+ ## 2.0.0 - 2008-08-23
12
+ ### Changed
13
+ * Switch the build system to [CMake](http://www.cmake.org/)
14
+ * Improve the performance of the suffix-sorting algorithm
15
+
16
+ ### Added
17
+ * OpenMP support
18
+ * 64-bit version of divsufsort
19
+
20
+ [Unreleased]: https://github.com/y-256/libdivsufsort/compare/2.0.1...HEAD
21
+ [2.0.1]: https://github.com/y-256/libdivsufsort/compare/2.0.0...2.0.1
@@ -0,0 +1,99 @@
1
+ ### cmake file for building libdivsufsort Package ###
2
+ cmake_minimum_required(VERSION 2.4.4)
3
+ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
4
+ include(AppendCompilerFlags)
5
+
6
+ ## Project information ##
7
+ project(libdivsufsort C)
8
+ set(PROJECT_VENDOR "Yuta Mori")
9
+ set(PROJECT_CONTACT "yuta.256@gmail.com")
10
+ set(PROJECT_URL "https://github.com/y-256/libdivsufsort")
11
+ set(PROJECT_DESCRIPTION "A lightweight suffix sorting library")
12
+ include(VERSION.cmake)
13
+
14
+ ## CPack configuration ##
15
+ set(CPACK_GENERATOR "TGZ;TBZ2;ZIP")
16
+ set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP")
17
+ include(ProjectCPack)
18
+
19
+ ## Project options ##
20
+ option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
21
+ option(BUILD_EXAMPLES "Build examples" ON)
22
+ option(BUILD_DIVSUFSORT64 "Build libdivsufsort64" OFF)
23
+ option(USE_OPENMP "Use OpenMP for parallelization" OFF)
24
+ option(WITH_LFS "Enable Large File Support" ON)
25
+
26
+ ## Installation directories ##
27
+ set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32 or 64)")
28
+
29
+ set(CMAKE_INSTALL_RUNTIMEDIR "" CACHE PATH "Specify the output directory for dll runtimes (default is bin)")
30
+ if(NOT CMAKE_INSTALL_RUNTIMEDIR)
31
+ set(CMAKE_INSTALL_RUNTIMEDIR "${CMAKE_INSTALL_PREFIX}/bin")
32
+ endif(NOT CMAKE_INSTALL_RUNTIMEDIR)
33
+
34
+ set(CMAKE_INSTALL_LIBDIR "" CACHE PATH "Specify the output directory for libraries (default is lib)")
35
+ if(NOT CMAKE_INSTALL_LIBDIR)
36
+ set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
37
+ endif(NOT CMAKE_INSTALL_LIBDIR)
38
+
39
+ set(CMAKE_INSTALL_INCLUDEDIR "" CACHE PATH "Specify the output directory for header files (default is include)")
40
+ if(NOT CMAKE_INSTALL_INCLUDEDIR)
41
+ set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
42
+ endif(NOT CMAKE_INSTALL_INCLUDEDIR)
43
+
44
+ set(CMAKE_INSTALL_PKGCONFIGDIR "" CACHE PATH "Specify the output directory for pkgconfig files (default is lib/pkgconfig)")
45
+ if(NOT CMAKE_INSTALL_PKGCONFIGDIR)
46
+ set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
47
+ endif(NOT CMAKE_INSTALL_PKGCONFIGDIR)
48
+
49
+ ## Build type ##
50
+ if(NOT CMAKE_BUILD_TYPE)
51
+ set(CMAKE_BUILD_TYPE "Release")
52
+ elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
53
+ set(CMAKE_VERBOSE_MAKEFILE ON)
54
+ endif(NOT CMAKE_BUILD_TYPE)
55
+
56
+ ## Compiler options ##
57
+ if(MSVC)
58
+ append_c_compiler_flags("/W4" "VC" CMAKE_C_FLAGS)
59
+ append_c_compiler_flags("/Oi;/Ot;/Ox;/Oy" "VC" CMAKE_C_FLAGS_RELEASE)
60
+ if(USE_OPENMP)
61
+ append_c_compiler_flags("/openmp" "VC" CMAKE_C_FLAGS)
62
+ endif(USE_OPENMP)
63
+ elseif(BORLAND)
64
+ append_c_compiler_flags("-w" "BCC" CMAKE_C_FLAGS)
65
+ append_c_compiler_flags("-Oi;-Og;-Os;-Ov;-Ox" "BCC" CMAKE_C_FLAGS_RELEASE)
66
+ else(MSVC)
67
+ if(CMAKE_COMPILER_IS_GNUCC)
68
+ append_c_compiler_flags("-Wall" "GCC" CMAKE_C_FLAGS)
69
+ append_c_compiler_flags("-fomit-frame-pointer" "GCC" CMAKE_C_FLAGS_RELEASE)
70
+ if(USE_OPENMP)
71
+ append_c_compiler_flags("-fopenmp" "GCC" CMAKE_C_FLAGS)
72
+ endif(USE_OPENMP)
73
+ else(CMAKE_COMPILER_IS_GNUCC)
74
+ append_c_compiler_flags("-Wall" "UNKNOWN" CMAKE_C_FLAGS)
75
+ append_c_compiler_flags("-fomit-frame-pointer" "UNKNOWN" CMAKE_C_FLAGS_RELEASE)
76
+ if(USE_OPENMP)
77
+ append_c_compiler_flags("-fopenmp;-openmp;-omp" "UNKNOWN" CMAKE_C_FLAGS)
78
+ endif(USE_OPENMP)
79
+ endif(CMAKE_COMPILER_IS_GNUCC)
80
+ endif(MSVC)
81
+
82
+ ## Add definitions ##
83
+ add_definitions(-DHAVE_CONFIG_H=1 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS)
84
+
85
+ ## Add subdirectories ##
86
+ add_subdirectory(pkgconfig)
87
+ add_subdirectory(include)
88
+ add_subdirectory(lib)
89
+ if(BUILD_EXAMPLES)
90
+ add_subdirectory(examples)
91
+ endif(BUILD_EXAMPLES)
92
+
93
+ ## Add 'uninstall' target ##
94
+ CONFIGURE_FILE(
95
+ "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
96
+ "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake"
97
+ IMMEDIATE @ONLY)
98
+ ADD_CUSTOM_TARGET(uninstall
99
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/CMakeModules/cmake_uninstall.cmake")
@@ -0,0 +1,38 @@
1
+ include(CheckCSourceCompiles)
2
+ include(CheckCXXSourceCompiles)
3
+
4
+ macro(append_c_compiler_flags _flags _name _result)
5
+ set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
6
+ string(REGEX REPLACE "[-+/ ]" "_" cname "${_name}")
7
+ string(TOUPPER "${cname}" cname)
8
+ foreach(flag ${_flags})
9
+ string(REGEX REPLACE "^[-+/ ]+(.*)[-+/ ]*$" "\\1" flagname "${flag}")
10
+ string(REGEX REPLACE "[-+/ ]" "_" flagname "${flagname}")
11
+ string(TOUPPER "${flagname}" flagname)
12
+ set(have_flag "HAVE_${cname}_${flagname}")
13
+ set(CMAKE_REQUIRED_FLAGS "${flag}")
14
+ check_c_source_compiles("int main() { return 0; }" ${have_flag})
15
+ if(${have_flag})
16
+ set(${_result} "${${_result}} ${flag}")
17
+ endif(${have_flag})
18
+ endforeach(flag)
19
+ set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
20
+ endmacro(append_c_compiler_flags)
21
+
22
+ macro(append_cxx_compiler_flags _flags _name _result)
23
+ set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
24
+ string(REGEX REPLACE "[-+/ ]" "_" cname "${_name}")
25
+ string(TOUPPER "${cname}" cname)
26
+ foreach(flag ${_flags})
27
+ string(REGEX REPLACE "^[-+/ ]+(.*)[-+/ ]*$" "\\1" flagname "${flag}")
28
+ string(REGEX REPLACE "[-+/ ]" "_" flagname "${flagname}")
29
+ string(TOUPPER "${flagname}" flagname)
30
+ set(have_flag "HAVE_${cname}_${flagname}")
31
+ set(CMAKE_REQUIRED_FLAGS "${flag}")
32
+ check_cxx_source_compiles("int main() { return 0; }" ${have_flag})
33
+ if(${have_flag})
34
+ set(${_result} "${${_result}} ${flag}")
35
+ endif(${have_flag})
36
+ endforeach(flag)
37
+ set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
38
+ endmacro(append_cxx_compiler_flags)
@@ -0,0 +1,15 @@
1
+ include(CheckCSourceCompiles)
2
+
3
+ macro(check_function_keywords _wordlist)
4
+ set(${_result} "")
5
+ foreach(flag ${_wordlist})
6
+ string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}")
7
+ string(TOUPPER "${flagname}" flagname)
8
+ set(have_flag "HAVE_${flagname}")
9
+ check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag})
10
+ if(${have_flag} AND NOT ${_result})
11
+ set(${_result} "${flag}")
12
+ # break()
13
+ endif(${have_flag} AND NOT ${_result})
14
+ endforeach(flag)
15
+ endmacro(check_function_keywords)