From f40f6aff04f33f85f42aebbeac71c65297be2d61 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 21 May 2019 21:20:01 +0100 Subject: [PATCH] separate mac linux builds --- README.md | 23 +++++++++++++++++++++-- raylib/__init__.py | 2 +- raylib/build_linux.py | 8 +++----- raylib/build_mac.py | 23 +++++++++++++++++++++++ setup.py | 4 ++-- 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 raylib/build_mac.py diff --git a/README.md b/README.md index 3f6fb34..0fc66be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python Bindings for Raylib -This uses CFFI API static bindins rather than ctypes. Hopefully this will be faster, the static type knowledge from the C +This uses CFFI API static bindings rather than ctypes. Hopefully this will be faster, the static type knowledge from the C headers will result in fewer bugs, and using the original headers will make it easier to maintain. Currently the goal is make usage as similar to the original C as CFFI will allow. There are a few differences @@ -9,9 +9,28 @@ done yet. See test.py and examples/*.py for how to use. +# Installing + +MacOS: Python 3.7: we distribute a statically linked Raylib library, so in theory the only thing you need to do is install +us from Pypi. + + pip3 install -i https://test.pypi.org/simple/ raylib + +Linux: Python 3.6: we dont distribute Raylib, so you must have Raylib 2.5dev already installed on your system. + + pip3 install -i https://test.pypi.org/simple/ raylib + +If you're using a different version of Python, or using Windows, or maybe a Linux/Mac with incompatible libraries +you will have to build. + + cd raylib + python3 build_linux.py + python3 build_mac.py + # Platforms tested - * MacOS 10.12.6 + * MacOS 10.12.6 - Python 3.7 + * Ubuntu 18.04 LTS - Python 3.6 # HELP WANTED diff --git a/raylib/__init__.py b/raylib/__init__.py index da1eb0e..ed26290 100644 --- a/raylib/__init__.py +++ b/raylib/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.5.dev1" +__version__ = "2.5.dev2" from ._raylib_cffi import ffi, lib as rl from _raylib_cffi.lib import * diff --git a/raylib/build_linux.py b/raylib/build_linux.py index 97007ca..7ef98c4 100644 --- a/raylib/build_linux.py +++ b/raylib/build_linux.py @@ -1,3 +1,5 @@ +# Linux build assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them. + from cffi import FFI import os import platform @@ -18,11 +20,7 @@ ffibuilder.set_source("_raylib_cffi", libraries=['raylib','GL','m','pthread', 'dl', 'rt', 'X11'] ) -# Hack to produce static linked lib -command = "clang -bundle -undefined dynamic_lookup ./_raylib_cffi.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib libraylib.a -F/System/Library/Frameworks -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo -o ./_raylib_cffi.cpython-37m-darwin.so" if __name__ == "__main__": ffibuilder.compile(verbose=True) - if platform.system()=="Darwin": - print(command) - os.system(command) + diff --git a/raylib/build_mac.py b/raylib/build_mac.py new file mode 100644 index 0000000..1cbc075 --- /dev/null +++ b/raylib/build_mac.py @@ -0,0 +1,23 @@ +from cffi import FFI +import os +import platform +ffibuilder = FFI() + + +ffibuilder.cdef(open("raylib_modified.h").read().replace('RLAPI ', '')) + + +ffibuilder.set_source("_raylib_cffi", + """ + #include "raylib.h" // the C header of the library + """ + ) + +# Hack to produce static linked lib +command = "clang -bundle -undefined dynamic_lookup ./_raylib_cffi.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib libraylib.a -F/System/Library/Frameworks -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo -o ./_raylib_cffi.cpython-37m-darwin.so" + +if __name__ == "__main__": + ffibuilder.compile(verbose=True) + if platform.system()=="Darwin": + print(command) + os.system(command) diff --git a/setup.py b/setup.py index f7a3afe..e7ecbfc 100644 --- a/setup.py +++ b/setup.py @@ -10,13 +10,13 @@ README = (HERE / "README.md").read_text() # This call to setup() does all the work setup( name="raylib", - version="2.5.dev1", + version="2.5.dev2", description="Python CFFI bindings for Raylib", long_description=README, long_description_content_type="text/markdown", url="https://github.com/electronstudio/raylib-python-cffi", author="Electron Studio", - author_email="richard@electronstudio.co.uk", + author_email="github@electronstudio.co.uk", license="LGPLv3+", classifiers=[ "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",