Last active
May 23, 2021 07:47
-
-
Save nightsailer/cf66c2ebe8ebed1766e1e8f27923426c to your computer and use it in GitHub Desktop.
build python pkgs on M1 Apple Silicon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 | |
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 | |
export CFLAGS="-I/opt/homebrew/opt/openssl/include" | |
export LDFLAGS="-L/opt/homebrew/opt/openssl/lib" | |
python setup.py bdist | |
python setup.py install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build special llvm@9, SEE https://github.com/nightsailer/homebrew-brew | |
brew install --build-from-source llvm@9 | |
# py3 | |
LLVM_CONFIG="$(brew --prefix llvm@9)/bin/llvm-config" LDFLAGS="-L$(brew --prefix llvm@9)/lib" CPPFLAGS="-I$(brew --prefix llvm@9)/include" pip install llvmlite | |
# py2 | |
# If build llvm@9 sucess | |
LLVM_CONFIG="$(brew --prefix llvm@9)/bin/llvm-config" LDFLAGS="-L$(brew --prefix llvm@9)/lib" CPPFLAGS="-I$(brew --prefix llvm@9)/include" pip install llvmlite==0.31.0 | |
# FALLBACK | |
#arch --arch x86_64 pip install llvmlite==0.31.0 | |
# updated. | |
Apply the following modification to the source of LLVM 9.0.1. | |
*** llvm-project-llvmorg-9.0.1/llvm/include/llvm/ADT/Triple.h Thu Dec 12 04:15:30 2019 | |
--- llvm-project-llvmorg-9.0.1rev/llvm/include/llvm/ADT/Triple.h Sun May 16 11:49:49 2021 | |
*************** | |
*** 45,50 **** | |
--- 45,51 ---- | |
enum ArchType { | |
UnknownArch, | |
+ arm64, | |
arm, // ARM (little endian): arm, armv.*, xscale | |
armeb, // ARM (big endian): armeb | |
aarch64, // AArch64 (little endian): aarch64 | |
*** llvm-project-llvmorg-9.0.1/llvm/lib/Support/Triple.cpp Thu Dec 12 04:15:30 2019 | |
--- llvm-project-llvmorg-9.0.1rev/llvm/lib/Support/Triple.cpp Sun May 16 11:49:59 2021 | |
*************** | |
*** 1384,1389 **** | |
--- 1384,1390 ---- | |
T.setArch(UnknownArch); | |
break; | |
+ case Triple::arm64: | |
case Triple::aarch64: | |
case Triple::aarch64_be: | |
case Triple::bpfel: | |
Configure, make and install LLVM 9.0.1. | |
% mkdir build-arm64 | |
% cd build-arm64 | |
% cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/somewhere/in/the/world -DLLVM_HOST_TRIPLE=arm64-apple-darwin20.3.0 -DLLVM_TARGETS_TO_BUILD="AArm64" ../llvm | |
% make -j4 | |
% make install | |
Install llvmlite. | |
% env LLVM_CONFIG=/somewhere/in/the/world/bin/llvm-config pip3 install llvmlite | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OPENBLAS="$(brew --prefix openblas)" pip install numpy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install cython | |
# for py3 | |
tar zxvf pandans-1.2.3.tar.gz | |
cd pandas-1.2.3 | |
python setup.py bdist | |
python setup install | |
# for py2 with pandas 0.24.2 | |
# Xcode 12 treats implicit function declarations as an error, rather than a warning | |
# here disable this behavior | |
CFLAGS='-Wno-implicit-function-declaration' pip install pandas |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install snappy | |
CFLAGS="-I $(brew --prefix snappy)/include" pip LDFLAGS="-L$(brew --prefix snappy)/lib" install python-snappy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment