Skip to content

Commit

Permalink
Unify the two dependency scripts, for starters
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Nov 29, 2021
1 parent 10ebe70 commit 1a9c401
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 119 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
- name: Build wheels
uses: pypa/[email protected]
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
Expand Down
106 changes: 0 additions & 106 deletions install-deps-mac.sh

This file was deleted.

85 changes: 75 additions & 10 deletions install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 1a9c401

Please sign in to comment.