cirospaciari / socketify.py

Bringing Http/Https and WebSockets High Performance servers for PyPy3 and Python3
https://www.socketify.dev
MIT License
1.44k stars 56 forks source link

Fix MacOS M1 and M2 builds, Maybe link zlib and libuv statically in macOS #34

Closed cirospaciari closed 1 year ago

cirospaciari commented 1 year ago

Add zlib and libuv statically instead of dynamically linked, this will avoid problems with people that don't run.

brew install libuv
brew install zlib

or

apt install libuv1 zlib1g

Discussion: https://github.com/cirospaciari/socketify.py/discussions/10#discussioncomment-4129980

(Should fix arm m2)

cirospaciari commented 1 year ago

@seanr3 I'm trying to fix the build for Apple Silicon, today i will fix that, sorry for the delay, but now is the priority.

cirospaciari commented 1 year ago

Still not solved image

_uv_async_init error on is libuv not being detected or properly linked on macOS ARM

Related issues: https://github.com/nodejs/node/issues/39210 https://github.com/laverdet/isolated-vm/issues/238 https://github.com/JuliaLang/julia/issues/44585 https://github.com/xmrig/xmrig/issues/2323

Possible solution: https://github.com/github/roadmap/issues/528#event-7388263223 https://github.com/actions/runner-images/issues/2187

sean324 commented 1 year ago

Yup same here.

cirospaciari commented 1 year ago

Still trying to figure it out an pre-build for Apple Silicon, but for now the only way is building from source, github has a roadmap to include M1 powered runners and an paid version is available from CirrusLabs but is just too expensive for this project at this stage (without more funding or customers), I'm also checking the possibility of using macOS M1 from AWS to build this, and checking an way to statically link cross compiled libuv and zlib for M1, i think that in this week (or even today) i can fix the build

Manual build:

brew install libuv
brew install zlib
brew install libuv --HEAD
brew install zlib --HEAD

#clone and update submodules
git clone https://github.com/cirospaciari/socketify.py.git
cd ./socketify.py
git submodule update --init --recursive --remote
cd ./src/socketify/native/ && make macos-arm64 && cd ../../../
#install local pip
python3 -m pip install .
cirospaciari commented 1 year ago

@seanr3 Good news, i created an new process to cross-compile libuv statically using cmake and things worked here! image

No need to build manually anymore. Please uninstall and reinstall again

 pip uninstall socketify
 # or
 python3 -m pip uninstall socketify
pip install git+https://github.com/cirospaciari/socketify.py.git
 # or
python3 -m pip install git+https://github.com/cirospaciari/socketify.py.git

Please reopen this issue if you got some other type of errors.

sean324 commented 1 year ago

Works! Thank you.