Skip to content

Commit aee216c

Browse files
committed
Remove seq.pyx and import it as cyseq
Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent bd5f176 commit aee216c

12 files changed

Lines changed: 19 additions & 10037 deletions

File tree

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ install_requires =
117117
typecode >= 30.0.1
118118
typecode[full] >= 30.0.1
119119
extractcode[full] >= 31.0.0
120+
cyseq; platform_system == 'Linux'
120121

121122

122123
[options.packages.find]

setup.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
#!/usr/bin/env python
22

33
import setuptools
4-
from Cython.Build import cythonize
5-
6-
7-
extensions = [
8-
setuptools.Extension("licensedcode.seq", ["src/licensedcode/seq.pyx"], language="c++"),
9-
]
104

115
if __name__ == "__main__":
12-
setuptools.setup(
13-
ext_modules=cythonize(extensions)
14-
)
6+
setuptools.setup()

src/licensedcode/index.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@
2828
from licensedcode import match_spdx_lid
2929
from licensedcode import match_unknown
3030
from licensedcode.dmp import match_blocks as match_blocks_dmp
31-
from licensedcode.seq import match_blocks as match_blocks_seq
3231
from licensedcode import query
3332
from licensedcode import tokenize
3433
from licensedcode.spans import Span
3534
from typing import NamedTuple
3635
from typing import Callable
3736

37+
try:
38+
# Use Cython seq.py implementation
39+
from cyseq import match_blocks as match_blocks_seq
40+
except ImportError:
41+
# Use Python seq.py if it is not available
42+
from licensedcode.seq import match_blocks as match_blocks_seq
43+
3844
"""
3945
Main license index construction, query processing and matching entry points for
4046
license detection.

src/licensedcode/match_seq.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def match_sequence(
6363
return []
6464

6565
if not match_blocks:
66-
from licensedcode.seq import match_blocks
66+
try:
67+
# Use Cython seq.py implementation
68+
from cyseq import match_blocks
69+
except ImportError:
70+
# Use Python seq.py if it is not available
71+
from licensedcode.seq import match_blocks
6772

6873
rid = rule.rid
6974
itokens = idx.tids_by_rid[rid]

0 commit comments

Comments
 (0)