electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
142 stars 29 forks source link

Mac build issues #48

Closed electronstudio closed 2 years ago

electronstudio commented 2 years ago

Currently on MacOS:

We don't use cmake due to an error, therefore we dont set all the options we set on other platforms. Probably wait for Raylib 4.0 before trying to fix this.

We don't build M1 ARM64 version due to Github Actions not supporting it. Probably wait for https://github.com/actions/virtual-environments/issues/2187

electronstudio commented 2 years ago

https://github.com/raysan5/raylib/issues/2052

pkulev commented 2 years ago

I have m1 mac, so I can test this. Now it says:

      File "raylib/build.py", line 152, in <module>
        build_mac()
      File "raylib/build.py", line 104, in build_mac
        ffibuilder.cdef(mangle("/usr/local/include/raylib.h"))
      File "raylib/build.py", line 31, in mangle
        for line in open(file):
    FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/include/raylib.h'
    BUILDING FOR MAC
    --------------------

raylib was installed via brew:

╭─most@m1 /tmp
╰─$ pkg-config --libs --cflags raylib
-I/opt/homebrew/Cellar/raylib/3.7.0/include -L/opt/homebrew/Cellar/raylib/3.7.0/lib -lraylib
╭─most@m1 /tmp
╰─$ brew list raylib
/opt/homebrew/Cellar/raylib/3.7.0/include/ (5 files)
/opt/homebrew/Cellar/raylib/3.7.0/lib/libraylib.3.5.0.dylib
/opt/homebrew/Cellar/raylib/3.7.0/lib/cmake/ (2 files)
/opt/homebrew/Cellar/raylib/3.7.0/lib/pkgconfig/raylib.pc
/opt/homebrew/Cellar/raylib/3.7.0/lib/ (3 other files)
electronstudio commented 2 years ago

OK you're hitting issues due to things in 4.0a4, which will need to be fixed before release, but for now let's stick to 3.7.0.

Can you please try pip3 install raylib==3.7.0.post10 ?

pkulev commented 2 years ago

Something new actually:

╰─$ pip install raylib==3.7.0.post10
Collecting raylib==3.7.0.post10
  Downloading raylib-3.7.0.post10.tar.gz (71 kB)
     |████████████████████████████████| 71 kB 102 kB/s
Collecting cffi>=1.14.5
  Using cached cffi-1.15.0-cp39-cp39-macosx_11_0_arm64.whl (173 kB)
Collecting inflection
  Using cached inflection-0.5.1-py2.py3-none-any.whl (9.5 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Using legacy 'setup.py install' for raylib, since package 'wheel' is not installed.
Installing collected packages: pycparser, inflection, cffi, raylib
    Running setup.py install for raylib ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/most/proj/tanki/.venv/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-n7w7y5bv/raylib_de5e2b5d3e664b43b7c84101b025411d/setup.py'"'"'; __file__='"'"'/private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-n7w7y5bv/raylib_de5e2b5d3e664b43b7c84101b025411d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-record-ns1hdyp8/install-record.txt --single-version-externally-managed --compile --install-headers /Users/most/proj/tanki/.venv/include/site/python3.9/raylib
         cwd: /private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-n7w7y5bv/raylib_de5e2b5d3e664b43b7c84101b025411d/
    Complete output (41 lines):
    BUILDING FOR MAC
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-11-arm64-3.9
    creating build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/build.py -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/version.py -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/__init__.py -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/pyray.py -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/colors.py -> build/lib.macosx-11-arm64-3.9/raylib
    creating build/lib.macosx-11-arm64-3.9/pyray
    copying pyray/__init__.py -> build/lib.macosx-11-arm64-3.9/pyray
    running egg_info
    writing raylib.egg-info/PKG-INFO
    writing dependency_links to raylib.egg-info/dependency_links.txt
    writing requirements to raylib.egg-info/requires.txt
    writing top-level names to raylib.egg-info/top_level.txt
    reading manifest file 'raylib.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'raylib/*.so'
    warning: no files found matching 'raylib/*.pyd'
    warning: no previously-included files found matching 'raylib/*.a'
    warning: no previously-included files found matching 'raylib/*.c'
    warning: no previously-included files found matching 'raylib/*.o'
    adding license file 'LICENSE'
    writing manifest file 'raylib.egg-info/SOURCES.txt'
    copying raylib/__init__.pyi -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/raylib.h -> build/lib.macosx-11-arm64-3.9/raylib
    copying raylib/raylib_modified.h -> build/lib.macosx-11-arm64-3.9/raylib
    running build_ext
    generating cffi module 'build/temp.macosx-11-arm64-3.9/raylib._raylib_cffi.c'
    creating build/temp.macosx-11-arm64-3.9
    building 'raylib._raylib_cffi' extension
    creating build/temp.macosx-11-arm64-3.9/build
    creating build/temp.macosx-11-arm64-3.9/build/temp.macosx-11-arm64-3.9
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/opt/homebrew/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/sqlite/include -I/Users/most/proj/tanki/.venv/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/temp.macosx-11-arm64-3.9/raylib._raylib_cffi.c -o build/temp.macosx-11-arm64-3.9/build/temp.macosx-11-arm64-3.9/raylib._raylib_cffi.o
    clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk build/temp.macosx-11-arm64-3.9/build/temp.macosx-11-arm64-3.9/raylib._raylib_cffi.o -L/opt/homebrew/lib -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/sqlite/lib -o build/lib.macosx-11-arm64-3.9/raylib/_raylib_cffi.abi3.so /usr/local/lib/libraylib.a -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo
    clang: error: no such file or directory: '/usr/local/lib/libraylib.a'
    error: command '/usr/bin/clang' failed with exit code 1
pkulev commented 2 years ago

I don't know well that C stuff, but it seems that those libs should be symlinked, or maybe something like pkg-config can help.

╰─$ tree /opt/homebrew/Cellar/raylib/3.7.0/
/opt/homebrew/Cellar/raylib/3.7.0/
├── CHANGELOG
├── HISTORY.md
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
├── include
│   ├── physac.h
│   ├── raudio.h
│   ├── raylib.h
│   ├── raymath.h
│   └── rlgl.h
└── lib
    ├── cmake
    │   └── raylib
    │       ├── raylib-config-version.cmake
    │       └── raylib-config.cmake
    ├── libraylib.3.5.0.dylib
    ├── libraylib.351.dylib -> libraylib.3.5.0.dylib
    ├── libraylib.a
    ├── libraylib.dylib -> libraylib.351.dylib
    └── pkgconfig
        └── raylib.pc
electronstudio commented 2 years ago

Does it work if you link /opt/homebrew/Cellar/raylib/3.7.0/lib/librarylib.a to /usr/local/lib/libraylib.a ?

pkulev commented 2 years ago

Yep, already linked and it worked.

electronstudio commented 2 years ago

cool. That's probably good enough for 3.7.0 since I want to move on to 4.0.

I've added pkg-config in raylib==4.0a5 to find the paths.

pkulev commented 2 years ago

Cool! I want to give it a try in lisp gamedev jam at itch.io that started today, using hy (lisp dialect that compiles to python AST) and raylib:)