diff --git a/noxfile.py b/noxfile.py index b516e44c..e566f5b1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,18 +16,24 @@ # 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") @@ -35,8 +41,9 @@ def build_libcrc32c(session): @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) diff --git a/scripts/check_crc32c_exstension.py b/scripts/check_crc32c_extension.py similarity index 100% rename from scripts/check_crc32c_exstension.py rename to scripts/check_crc32c_extension.py diff --git a/scripts/local-linux/build_libcrc32c.sh b/scripts/local-linux/build_libcrc32c.sh index 63508433..0e5d6988 100644 --- a/scripts/local-linux/build_libcrc32c.sh +++ b/scripts/local-linux/build_libcrc32c.sh @@ -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 @@ -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} diff --git a/scripts/osx/build.sh b/scripts/osx/build.sh index 419483e9..64af4b02 100755 --- a/scripts/osx/build.sh +++ b/scripts/osx/build.sh @@ -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} diff --git a/scripts/osx/build_c_lib.sh b/scripts/osx/build_c_lib.sh index 1ad725af..0605b9b8 100755 --- a/scripts/osx/build_c_lib.sh +++ b/scripts/osx/build_c_lib.sh @@ -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 \ . diff --git a/scripts/osx/check.sh b/scripts/osx/check.sh index a3f7f2b7..fc0c6847 100755 --- a/scripts/osx/check.sh +++ b/scripts/osx/check.sh @@ -50,6 +50,8 @@ 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 @@ -57,6 +59,8 @@ ${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 @@ -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 diff --git a/scripts/windows/build.bat b/scripts/windows/build.bat index 75d83b27..05892189 100644 --- a/scripts/windows/build.bat +++ b/scripts/windows/build.bat @@ -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