Skip to content

Instantly share code, notes, and snippets.

@soldni
Created October 28, 2022 06:08
Show Gist options
  • Save soldni/e334c195804f28be7e83f3766f9626bb to your computer and use it in GitHub Desktop.
Save soldni/e334c195804f28be7e83f3766f9626bb to your computer and use it in GitHub Desktop.
Compile & install blingfire on a Mac with arm64 (Apple Silicon) processor.
#! /usr/bin/env bash
# get script directory
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it
# relative to the path where the symlink file was located
[[ $SOURCE != /* ]] && SOURCE="$SCRIPT_DIR/$SOURCE"
done
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
CURRENT_DIR="$(pwd)"
# clone blingfire repo to a temp directory
TMP_DIR=$(mktemp -d)
cd $TMP_DIR
git clone "https://github.com/microsoft/BlingFire"
cd blingfire
# build blingfire
mkdir Release
cd Release
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release ..
make -j 4
cd ..
# copy freshly compiled blingfire to the python bindings directory
cp -rf Release/* dist-pypi/blingfire/
# build & install the python bindings
cd dist-pypi
python setup.py sdist bdist_wheel
pip install --force-reinstall dist/blingfire-*-py3-none-any.whl
# cleanup
cd $CURRENT_DIR
rm -rf $TMP_DIR
@gardner
Copy link

gardner commented Jul 14, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment