Skip to content

Commit

Permalink
ci: ensure we build static lib
Browse files Browse the repository at this point in the history
Also, run unit tests during 'check' scripts.
  • Loading branch information
tseaver committed Aug 24, 2021
1 parent f49d461 commit c28a20c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 13 deletions.
23 changes: 15 additions & 8 deletions noxfile.py
Expand Up @@ -16,27 +16,34 @@

# Generated by synthtool. DO NOT EDIT!

from __future__ import absolute_import
import os
import sys

import nox
from sys import platform


HERE = os.path.dirname(__file__)

@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
def build_libcrc32c(session):
if platform.startswith("win"):
session.env["PY_BIN"] = f"python{session.python}"
session.env["REPO_ROOT"] = HERE

if sys.platform.startswith("win"):
session.run("cmd", "-c", "scripts\\windows\\build.bat")
elif platform == "linux":
elif sys.platform == "linux":
session.run("bash", "scripts/local-linux/build_libcrc32c.sh")
elif platform == "darwin":
elif sys.platform == "darwin":
session.run("bash", "scripts/osx/build.sh")
else:
raise Exception("Unsupported")


@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
def check(session):
session.install("cffi>=1.0.0")
session.install("--no-index", "--find-links=wheels", "google-crc32c")
session.install("pytest")
session.install("--no-index", f"--find-links={HERE}/wheels", "google-crc32c")

# Run py.test against the unit tests.
session.run("python", "scripts/check_crc32c_extension.py", *session.posargs)
session.run("py.test", "tests")
session.run("python", f"{HERE}/scripts/check_crc32c_extension.py", *session.posargs)
File renamed without changes.
12 changes: 10 additions & 2 deletions scripts/local-linux/build_libcrc32c.sh
Expand Up @@ -14,7 +14,7 @@

set -e -x

PY_BIN="python3.7"
PY_BIN=${PY_BIN:-python3.7}

# Check that the REPO_ROOT variable is set.
if [[ -z "${REPO_ROOT}" ]]; then
Expand All @@ -28,20 +28,28 @@ CRC32C_INSTALL_PREFIX=${REPO_ROOT}/usr
# Create a virtualenv where we can install `cmake`.
VENV=${REPO_ROOT}/venv
${PY_BIN} -m venv ${VENV}
${VENV}/bin/python -m pip install --upgrade setuptools pip wheel
${VENV}/bin/python -m pip install "cmake >= 3.12.0"
rm -rf ${REPO_ROOT}/build
rm -rf ${CRC32C_INSTALL_PREFIX}
# Build `libcrc32c`
cd ${REPO_ROOT}/google_crc32c
rm -rf build
mkdir build
cd build/
${VENV}/bin/cmake \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DBUILD_SHARED_LIBS=no \
-DCMAKE_INSTALL_PREFIX:PATH=${CRC32C_INSTALL_PREFIX} \
..
# Install `libcrc32c` into CRC32C_INSTALL_PREFIX.
make all install

cd ${REPO_ROOT}

${VENV}/bin/python -m pip wheel . --wheel-dir=wheels

# Clean up.
rm -fr ${REPO_ROOT}/google_crc32c/build
rm -fr ${VENV}
2 changes: 1 addition & 1 deletion scripts/osx/build.sh
Expand Up @@ -30,7 +30,7 @@ PYTHON38="/Library/Frameworks/Python.framework/Versions/3.8/bin"
PYTHON39="/Library/Frameworks/Python.framework/Versions/3.9/bin"

# Build and install `libcrc32c`
export PY_BIN="python3"
export PY_BIN="${PY_BIN:-python3}"
export CRC32C_INSTALL_PREFIX="${REPO_ROOT}/usr"

cd ${REPO_ROOT}
Expand Down
2 changes: 1 addition & 1 deletion scripts/osx/build_c_lib.sh
Expand Up @@ -62,7 +62,7 @@ ${VENV}/bin/cmake \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DBUILD_SHARED_LIBS=no \
-DCMAKE_INSTALL_PREFIX:PATH=${CRC32C_INSTALL_PREFIX} \
-DCMAKE_INSTALL_NAME_DIR:PATH=${CRC32C_INSTALL_PREFIX}/lib \
.
Expand Down
6 changes: 6 additions & 0 deletions scripts/osx/check.sh
Expand Up @@ -50,13 +50,17 @@ curl https://bootstrap.pypa.io/get-pip.py | venv36/bin/python3
WHL=${REPO_ROOT}/wheels/google_crc32c-${PACKAGE_VERSION}-cp36-cp36m-macosx_10_9_x86_64.whl
venv36/bin/pip install ${WHL}
venv36/bin/python ${REPO_ROOT}/scripts/check_crc32c_extension.py
venv36/bin/pip install pytest
venv36/bin/py.test ${REPO_ROOT}/tests
${LISTDEPS_CMD} ${WHL}
rm -fr venv36

${PYTHON37}/python3 -m venv venv37
curl https://bootstrap.pypa.io/get-pip.py | venv37/bin/python3
WHL=${REPO_ROOT}/wheels/google_crc32c-${PACKAGE_VERSION}-cp37-cp37m-macosx_10_9_x86_64.whl
venv37/bin/pip install ${WHL}
venv37/bin/pip install pytest
venv37/bin/py.test ${REPO_ROOT}/tests
venv37/bin/python ${REPO_ROOT}/scripts/check_crc32c_extension.py
${LISTDEPS_CMD} ${WHL}
rm -fr venv37
Expand All @@ -65,6 +69,8 @@ ${PYTHON38}/python3 -m venv venv38
curl https://bootstrap.pypa.io/get-pip.py | venv38/bin/python3
WHL=${REPO_ROOT}/wheels/google_crc32c-${PACKAGE_VERSION}-cp38-cp38-macosx_10_9_x86_64.whl
venv38/bin/pip install ${WHL}
venv38/bin/pip install pytest
venv38/bin/py.test ${REPO_ROOT}/tests
venv38/bin/python ${REPO_ROOT}/scripts/check_crc32c_extension.py
${LISTDEPS_CMD} ${WHL}
rm -fr venv38
Expand Down
2 changes: 1 addition & 1 deletion scripts/windows/build.bat
Expand Up @@ -61,7 +61,7 @@ FOR %%V IN (32,64) DO (ddd

echo "Running cmake with Generator: %CMAKE_GENERATOR%, Platform: !TARGET_PLATFORM!, Install Prefix: %CRC32C_INSTALL_PREFIX%"

%cmake% -G %CMAKE_GENERATOR% -A !TARGET_PLATFORM! -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=yes -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 -DCMAKE_INSTALL_PREFIX:PATH=%CRC32C_INSTALL_PREFIX% ..
%cmake% -G %CMAKE_GENERATOR% -A !TARGET_PLATFORM! -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 -DCMAKE_INSTALL_PREFIX:PATH=%CRC32C_INSTALL_PREFIX% ..

%cmake% --build . --config "%CONFIGURATION%" --target install

Expand Down

0 comments on commit c28a20c

Please sign in to comment.