-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Hyperscan 5.2.0 support and literal API (#16)
- Loading branch information
Showing
5 changed files
with
92 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from distutils.core import Extension | ||
from distutils.errors import ( | ||
CCompilerError, | ||
DistutilsExecError, | ||
DistutilsPlatformError, | ||
) | ||
from distutils.command.build_ext import build_ext | ||
|
||
|
||
# http://code.activestate.com/recipes/502261-python-distutils-pkg-config/ | ||
def pkgconfig(libs, optional=''): | ||
flag_map = { | ||
'include_dirs': ('--cflags-only-I', 2), | ||
'library_dirs': ('--libs-only-L', 2), | ||
'libraries': ('--libs-only-l', 2), | ||
'extra_compile_args': ('--cflags-only-other', 0), | ||
'extra_link_args': ('--libs-only-other', 0), | ||
} | ||
ext_kwargs = {} | ||
for lib in libs: | ||
for distutils_kwarg, (pkg_option, trim_offset) in flag_map.items(): | ||
try: | ||
options = ( | ||
subprocess.check_output( | ||
['pkg-config', optional, pkg_option, lib] | ||
) | ||
.decode() | ||
.split() | ||
) | ||
except subprocess.CalledProcessError: | ||
continue | ||
ext_kwargs.setdefault(distutils_kwarg, []).extend( | ||
[opt[trim_offset:] for opt in options] | ||
) | ||
return ext_kwargs | ||
|
||
|
||
def build(setup_kwargs): | ||
setup_kwargs.update( | ||
{ | ||
'ext_modules': [ | ||
Extension( | ||
'hyperscan._hyperscan', | ||
['hyperscan/hyperscanmodule.c'], | ||
**pkgconfig(['libhs']) | ||
) | ||
], | ||
'cmdclass': {'build_ext': build_ext}, | ||
} | ||
) | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from distutils.core import Extension | ||
from distutils.errors import ( | ||
CCompilerError, | ||
DistutilsExecError, | ||
DistutilsPlatformError, | ||
) | ||
from distutils.command.build_ext import build_ext | ||
|
||
|
||
# http://code.activestate.com/recipes/502261-python-distutils-pkg-config/ | ||
def pkgconfig(libs, optional=''): | ||
flag_map = { | ||
'include_dirs': ('--cflags-only-I', 2), | ||
'library_dirs': ('--libs-only-L', 2), | ||
'libraries': ('--libs-only-l', 2), | ||
'extra_compile_args': ('--cflags-only-other -O0', 0), | ||
'extra_link_args': ('--libs-only-other', 0), | ||
} | ||
ext_kwargs = {} | ||
for lib in libs: | ||
for distutils_kwarg, (pkg_option, trim_offset) in flag_map.items(): | ||
try: | ||
options = ( | ||
subprocess.check_output( | ||
['pkg-config', optional, pkg_option, lib] | ||
) | ||
.decode() | ||
.split() | ||
) | ||
except subprocess.CalledProcessError: | ||
continue | ||
ext_kwargs.setdefault(distutils_kwarg, []).extend( | ||
[opt[trim_offset:] for opt in options] | ||
) | ||
print(ext_kwargs) | ||
return ext_kwargs | ||
|
||
|
||
def build(setup_kwargs): | ||
setup_kwargs.update( | ||
{ | ||
'ext_modules': [ | ||
Extension( | ||
'hyperscan._hyperscan', | ||
['hyperscan/hyperscanmodule.c'], | ||
**pkgconfig(['libhs']), | ||
) | ||
], | ||
'cmdclass': {'build_ext': build_ext}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters