-
-
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.
build: 📦 fix macos build, update manylinux images
- Loading branch information
Showing
10 changed files
with
177 additions
and
87 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
PCRE_VERSION=${PCRE_VERSION:-8.45} | ||
|
||
if pkg-config --validate libhs; then | ||
echo "✅ libhs found, nothing to do" | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$HYPERSCAN_VERSION" ]; then | ||
>&2 echo "HYPERSCAN_VERSION must be set" | ||
exit 1 | ||
fi | ||
|
||
cd /tmp | ||
git clone -b "${HYPERSCAN_VERSION}" https://github.com/01org/hyperscan.git | ||
brew install boost cmake git pkg-config python@3.11 ragel wget | ||
cd hyperscan | ||
|
||
# build and install PCRE (static required for Chimera) | ||
wget -qO- https://sourceforge.net/projects/pcre/files/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.gz/download | tar xvz | ||
cd "pcre-${PCRE_VERSION}" | ||
./configure --prefix=/opt/pcre --enable-unicode-properties --enable-utf | ||
nproc=$(sysctl -n hw.logicalcpu) | ||
make -j${nproc} && sudo make install | ||
|
||
# build and install Hyperscan | ||
cd /tmp/hyperscan | ||
cmake \ | ||
-B build \ | ||
-S . \ | ||
-DCMAKE_INSTALL_PREFIX=/opt/hyperscan \ | ||
-DBUILD_STATIC_AND_SHARED=ON \ | ||
-DCMAKE_BUILD_TYPE=${HYPERSCAN_BUILD_TYPE} \ | ||
-DPCRE_SOURCE=/tmp/hyperscan/pcre-${PCRE_VERSION} \ | ||
-DCMAKE_C_FLAGS="-fPIC" \ | ||
-DCMAKE_CXX_FLAGS="$CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0" | ||
cmake --build build --parallel ${nproc} | ||
sudo cmake --install build |
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,6 +1,9 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
export PDM_HOME=${PDM_HOME:-/tmp/pdm} | ||
export PDM_SKIP_ADD_TO_PATH=${PDM_SKIP_ADD_TO_PATH:-true} | ||
export PATH="${PDM_HOME}/bin:${PATH}" | ||
curl -sSL https://pdm.fming.dev/install-pdm.py | python - | ||
export PATH=/root/.local/bin:$PATH | ||
pdm install -g --no-self --no-lock -p /project -G test | ||
pdm export -G test -f requirements -o test_requirements.txt | ||
pip install -r test_requirements.txt |
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,8 +1,10 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# Tests in cibuildwheel are NOT run in the project directory by default | ||
PROJECT_DIR=${1:-/project} | ||
|
||
XDIST_WORKERS=$(python -c "import joblib; print(joblib.cpu_count(only_physical_cores=True))") | ||
echo "👷 Number of workers: $XDIST_WORKERS" | ||
pip show hyperscan | ||
pytest --pyargs "${PROJECT_DIR}/tests/" -n $XDIST_WORKERS -vvv | ||
pytest --pyargs "${PROJECT_DIR}/tests" -n $XDIST_WORKERS -vvv |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ARG PYTHON_VERSION | ||
FROM winamd64/python:$PYTHON_VERSION-windowsservercore | ||
|
||
ARG WHEEL_NAME | ||
ARG CONFTEST_NAME | ||
ARG CIBW_TEST_REQUIRES | ||
|
||
COPY $WHEEL_NAME $WHEEL_NAME | ||
RUN pip install $env:WHEEL_NAME | ||
RUN pip install $env:CIBW_TEST_REQUIRES.split(" ") |
This file was deleted.
Oops, something went wrong.
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,26 +1,62 @@ | ||
import glob | ||
import os | ||
import os.path | ||
import subprocess | ||
import sys | ||
from distutils.sysconfig import get_python_inc | ||
|
||
from setuptools import Extension, setup | ||
|
||
pcre_path = os.getenv("PCRE_PATH", "/opt/pcre/.libs") | ||
hs_cflags = subprocess.getoutput("pkg-config --cflags libhs").strip() | ||
|
||
hyperscan_ext = Extension( | ||
"hyperscan._ext", | ||
sources=["src/hyperscan/hyperscanmodule.c"], | ||
include_dirs=[hs_cflags[2:], get_python_inc(plat_specific=1)], | ||
libraries=["hs", ":libchimera.a", "m", "stdc++"], | ||
library_dirs=["/opt/hyperscan/lib64", "/usr/lib/x86_64-linux-gnu"], | ||
extra_compile_args=["-O0", "-DPCRE_STATIC"], | ||
extra_link_args=["-l:libhs.a", "-l:libchimera.a"], | ||
extra_objects=[ | ||
os.path.join(pcre_path, "libpcre.a"), | ||
*glob.glob(os.path.join(pcre_path, '*.o')), | ||
], | ||
) | ||
|
||
|
||
setup(ext_modules=[hyperscan_ext]) | ||
|
||
def _pkgconfig(args): | ||
return subprocess.getoutput(f"pkg-config {args}").strip() | ||
|
||
|
||
def _pkgconfig_get_cflags(lib): | ||
return _pkgconfig(f"--cflags {lib}") | ||
|
||
|
||
def _pkgconfig_get_libdir(lib): | ||
return _pkgconfig(f"--variable=libdir {lib}") | ||
|
||
|
||
def get_platform_specific_options(): | ||
if sys.platform == "win32": | ||
raise RuntimeError("win32 not currently supported") | ||
|
||
hs_cflags = _pkgconfig_get_cflags("libhs") | ||
pcre_libdir = _pkgconfig_get_libdir("libpcre") | ||
hs_libdir = _pkgconfig_get_libdir("libhs") | ||
pcre_static_libs = [ | ||
os.path.join(pcre_libdir, "libpcre.a"), | ||
*glob.glob(os.path.join(pcre_libdir, '*.o')), | ||
] | ||
ext_kwargs = { | ||
"extra_objects": pcre_static_libs, | ||
"include_dirs": [hs_cflags[2:], get_python_inc(plat_specific=1)], | ||
"libraries": ["m", "stdc++"], | ||
} | ||
|
||
hs_static_libs = [ | ||
os.path.join(hs_libdir, lib) for lib in ["libhs.a", "libchimera.a"] | ||
] | ||
|
||
ext_kwargs["extra_objects"] = [ | ||
*hs_static_libs, | ||
*ext_kwargs["extra_objects"], | ||
] | ||
return ext_kwargs | ||
|
||
|
||
if __name__ == "__main__": | ||
setup( | ||
ext_modules=[ | ||
Extension( | ||
"hyperscan._ext", | ||
sources=["src/hyperscan/hyperscanmodule.c"], | ||
library_dirs=os.getenv("LIBRARY_PATH", "").split(":"), | ||
extra_compile_args=["-O0", "-DPCRE_STATIC"], | ||
**get_platform_specific_options(), | ||
) | ||
] | ||
) |