-
Notifications
You must be signed in to change notification settings - Fork 4
Building PYCC for MacOS issues
Used MacOS: Catalyna
Note: To build komodod with pycc support you also need to pass --enable-pycc flag to configure.
Where the reference to the python lib is. The ref to Python lib is defined in src/Makefile.am. Be careful it defines both version numbers (3.n), you should install the exact version as default. It was initially set by -lpython3.6m but I changed it to 3.7 as 3.6 installation is not directly supported on my MacOS.
To make headers like "Python.h" available for the compiler I added
-L /usr/local/Cellar/[email protected]/3.7.8_1/Frameworks/Python.framework/Versions/3.7/lib/
to CPPFLAGS var in build-mac.sh
(Note: first I added
-L/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/headers
to CPPFLAGS and yet I added -Wl,-rpath,/Library/Developer/CommandLineTools/Library/Frameworks
to CXXFLAGS to resolve relative dependency to the python3 that was added: @rpath/Python3.framework/Versions/3.7/Python3
. Then it was built okay but komodod began to print errors like base58.py is not installed. Installing base58 with pip3 did not resolve the issue so it looks like this python in /Library... folder is a different installation, and it did not have pip3 in itself)
When I built libpycctx.dylib (running make) make ended with a lot of errors like:
Undefined symbols for architecture x86_64:
"_PyImport_ExecCodeModuleEx", referenced from:
pyo3::types::module::PyModule::from_code::h5221d5256e3ab9a9 in libpyo3-a79a90d0681fac3f.rlib(pyo3-a79a90d0681fac3f.pyo3.dl3qelwn-cgu.9.rcgu.o)
The solution to fix those build errors for Mac was found here: https://github.com/PyO3/pyo3, it is to create a ~/.cargo/config with params (or add to an existing config):
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
When libpycc.dylib is built successfully it is needed to make a link to it from the ./pycc directory
pycc % ln -s ./target/release/libpycctx.dylib pycctx.so
(note .so extension)