From 1a9c401374b1531f7bd39125eb8b385774c51555 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 29 Nov 2021 11:01:50 +0000 Subject: [PATCH] Unify the two dependency scripts, for starters --- .github/workflows/wheels.yml | 6 +- install-deps-mac.sh | 106 ----------------------------------- install-deps.sh | 85 ++++++++++++++++++++++++---- 3 files changed, 78 insertions(+), 119 deletions(-) delete mode 100644 install-deps-mac.sh diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index d9783b188..bea402565 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -29,9 +29,9 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.2.2 env: - CIBW_BEFORE_ALL_LINUX: sh install-deps.sh - CIBW_BEFORE_ALL_MACOS: sh install-deps-mac.sh - CIBW_ENVIRONMENT: LIBGIT2_VERSION=1.3.0 LIBSSH2_VERSION=1.10.0 DYLD_LIBRARY_PATH=/usr/local/lib + CIBW_BEFORE_ALL: sh install-deps.sh + CIBW_ENVIRONMENT: LIBGIT2_VERSION=1.3.0 LIBSSH2_VERSION=1.10.0 + CIBW_ENVIRONMENT_MACOS: LIBGIT2_VERSION=1.3.0 LIBSSH2_VERSION=1.10.0 DYLD_LIBRARY_PATH=/usr/local/lib OPENSSL_VERSION=3.0.0 CIBW_SKIP: "*-musllinux*" CIBW_REPAIR_WHEEL_COMMAND_MACOS: "DYLD_LIBRARY_PATH=/usr/local/lib delocate-listdeps {wheel} && DYLD_LIBRARY_PATH=/usr/local/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}" CIBW_ARCHS_MACOS: x86_64 universal2 diff --git a/install-deps-mac.sh b/install-deps-mac.sh deleted file mode 100644 index 79b27f57b..000000000 --- a/install-deps-mac.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -set -x # Print every command and variable -set -e # Fail fast - -# Variables -ARCH=`uname -m` -KERNEL=`uname -s` -BUILD_TYPE=${BUILD_TYPE:-Debug} -PYTHON=${PYTHON:-python3} - -PREFIX="${PREFIX:-$(pwd)/ci/}" -export LDFLAGS="-Wl,-rpath,$PREFIX/lib" - -OPENSSL_VERSION=3.0.0 - -rm -rf ci -mkdir ci || true -cd ci - - -# Install zlib -# XXX Build libgit2 with USE_BUNDLED_ZLIB instead? -if [ -n "$ZLIB_VERSION" ]; then - FILENAME=zlib-$ZLIB_VERSION - wget https://www.zlib.net/$FILENAME.tar.gz -N - tar xf $FILENAME.tar.gz - cd $FILENAME - ./configure --prefix=$PREFIX - make - make install - cd .. -fi - -# Install openssl -FILENAME=openssl-$OPENSSL_VERSION -wget https://www.openssl.org/source/$FILENAME.tar.gz -N --no-check-certificate - -tar xf $FILENAME.tar.gz -mv $FILENAME openssl-x86 - -tar xf $FILENAME.tar.gz -mv $FILENAME openssl-arm - -cd openssl-x86 -./Configure darwin64-x86_64-cc shared -make -cd ../openssl-arm -./Configure enable-rc5 zlib darwin64-arm64-cc no-asm -make -cd .. - -mkdir openssl-universal - -LIBSSL=$(basename openssl-x86/libssl.*.dylib) -lipo -create openssl-x86/libssl.*.dylib openssl-arm/libssl.*.dylib -output openssl-universal/$LIBSSL -LIBCRYPTO=$(basename openssl-x86/libcrypto.*.dylib) -lipo -create openssl-x86/libcrypto.*.dylib openssl-arm/libcrypto.*.dylib -output openssl-universal/$LIBCRYPTO -cd openssl-universal -install_name_tool -id "@rpath/$LIBSSL" $LIBSSL -install_name_tool -id "@rpath/$LIBCRYPTO" $LIBCRYPTO -OPENSSL_PREFIX=$(pwd) -cd .. - - -# Install libssh2 -if [ -n "$LIBSSH2_VERSION" ]; then - FILENAME=libssh2-$LIBSSH2_VERSION - wget https://www.libssh2.org/download/$FILENAME.tar.gz -N --no-check-certificate - tar xf $FILENAME.tar.gz - cd $FILENAME - cmake . \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_EXAMPLES=OFF \ - -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ - -DOPENSSL_CRYPTO_LIBRARY="../openssl-universal/$LIBCRYPTO" \ - -DOPENSSL_SSL_LIBRARY="../openssl-universal/$LIBSSL" \ - -DOPENSSL_INCLUDE_DIR="../openssl-x86/include" \ - -DBUILD_TESTING=OFF - cmake --build . --target install - cd .. - LIBSSH2_PREFIX=$PREFIX -fi - -# Install libgit2 -if [ -n "$LIBGIT2_VERSION" ]; then - FILENAME=libgit2-$LIBGIT2_VERSION - wget https://github.com/libgit2/libgit2/archive/refs/tags/v$LIBGIT2_VERSION.tar.gz -N -O $FILENAME.tar.gz - tar xf $FILENAME.tar.gz - cd $FILENAME - CMAKE_PREFIX_PATH=$OPENSSL_PREFIX:$LIBSSH2_PREFIX cmake . \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_CLAR=OFF \ - -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DOPENSSL_CRYPTO_LIBRARY="../openssl-universal/$LIBCRYPTO" \ - -DOPENSSL_SSL_LIBRARY="../openssl-universal/$LIBSSL" \ - -DOPENSSL_INCLUDE_DIR="../openssl-x86/include" - cmake --build . --target install - cd .. -fi - -# This is gross -cp -r $OPENSSL_PREFIX/*.dylib /usr/local/lib -cp -r $LIBSSH2_PREFIX/lib/*.dylib /usr/local/lib -cp -r $FILENAME/*.dylib /usr/local/lib diff --git a/install-deps.sh b/install-deps.sh index 5e1ec44bb..e47da51a7 100644 --- a/install-deps.sh +++ b/install-deps.sh @@ -80,17 +80,61 @@ if [ -n "$ZLIB_VERSION" ]; then cd .. fi +# Install openssl +if [ -n "$OPENSSL_VERSION" ]; then + FILENAME=openssl-$OPENSSL_VERSION + wget https://www.openssl.org/source/$FILENAME.tar.gz -N --no-check-certificate + + tar xf $FILENAME.tar.gz + mv $FILENAME openssl-x86 + + tar xf $FILENAME.tar.gz + mv $FILENAME openssl-arm + + cd openssl-x86 + ./Configure darwin64-x86_64-cc shared + make + cd ../openssl-arm + ./Configure enable-rc5 zlib darwin64-arm64-cc no-asm + make + cd .. + + mkdir openssl-universal + + LIBSSL=$(basename openssl-x86/libssl.*.dylib) + lipo -create openssl-x86/libssl.*.dylib openssl-arm/libssl.*.dylib -output openssl-universal/$LIBSSL + LIBCRYPTO=$(basename openssl-x86/libcrypto.*.dylib) + lipo -create openssl-x86/libcrypto.*.dylib openssl-arm/libcrypto.*.dylib -output openssl-universal/$LIBCRYPTO + cd openssl-universal + install_name_tool -id "@rpath/$LIBSSL" $LIBSSL + install_name_tool -id "@rpath/$LIBCRYPTO" $LIBCRYPTO + OPENSSL_PREFIX=$(pwd) + cd .. +fi + # Install libssh2 if [ -n "$LIBSSH2_VERSION" ]; then FILENAME=libssh2-$LIBSSH2_VERSION wget https://www.libssh2.org/download/$FILENAME.tar.gz -N --no-check-certificate tar xf $FILENAME.tar.gz cd $FILENAME - cmake . \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_EXAMPLES=OFF \ - -DBUILD_TESTING=OFF + if [ "$KERNEL" = "Darwin" ]; then + cmake . \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_EXAMPLES=OFF \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DOPENSSL_CRYPTO_LIBRARY="../openssl-universal/$LIBCRYPTO" \ + -DOPENSSL_SSL_LIBRARY="../openssl-universal/$LIBSSL" \ + -DOPENSSL_INCLUDE_DIR="../openssl-x86/include" \ + -DBUILD_TESTING=OFF + else + cmake . \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_TESTING=OFF + fi cmake --build . --target install cd .. LIBSSH2_PREFIX=$PREFIX @@ -102,11 +146,32 @@ if [ -n "$LIBGIT2_VERSION" ]; then wget https://github.com/libgit2/libgit2/archive/refs/tags/v$LIBGIT2_VERSION.tar.gz -N -O $FILENAME.tar.gz tar xf $FILENAME.tar.gz cd $FILENAME - CMAKE_PREFIX_PATH=$OPENSSL_PREFIX:$LIBSSH2_PREFIX cmake . \ - -DBUILD_SHARED_LIBS=ON \ - -DBUILD_CLAR=OFF \ - -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE + if [ "$KERNEL" = "Darwin" ]; then + CMAKE_PREFIX_PATH=$OPENSSL_PREFIX:$LIBSSH2_PREFIX cmake . \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_CLAR=OFF \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DOPENSSL_CRYPTO_LIBRARY="../openssl-universal/$LIBCRYPTO" \ + -DOPENSSL_SSL_LIBRARY="../openssl-universal/$LIBSSL" \ + -DOPENSSL_INCLUDE_DIR="../openssl-x86/include" \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE + else + CMAKE_PREFIX_PATH=$OPENSSL_PREFIX:$LIBSSH2_PREFIX cmake . \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_CLAR=OFF \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE + fi cmake --build . --target install cd .. fi + +if [ "$KERNEL" = "Darwin" ]; then + if [ "$GITHUB_ACTIONS" != "true" ]; then + echo "Refusing to install Universal openssl locally!" + exit 1 + fi + # This is gross + cp -r $OPENSSL_PREFIX/*.dylib /usr/local/lib + cp -r $LIBSSH2_PREFIX/lib/*.dylib /usr/local/lib + cp -r $FILENAME/*.dylib /usr/local/lib +fi