rewrite build system to build separate binary wheels for each platform. only tested on Linux so far. should fix #25.
This commit is contained in:
parent
76121e34a9
commit
9eddc4e528
24 changed files with 148 additions and 25686 deletions
47
README.md
47
README.md
|
@ -8,7 +8,13 @@ New CFFI API static bindings. Faster, fewer bugs and easier to maintain than ct
|
|||
|
||||
# Install
|
||||
|
||||
## Option 1: Install from Pypi (easiest but currently out of date, Raylib 2.6 and Python 3.6 - 3.8)
|
||||
## Option 1: Install from Pypi (easiest but may not be up to date or be available for your platform)
|
||||
|
||||
We distribute a statically linked binary Raylib library, install from Pypi.
|
||||
|
||||
pip3 install raylib
|
||||
|
||||
Some platforms that should be available:
|
||||
|
||||
**Windows 10 (64 bit): Python 3.6 - 3.8**
|
||||
|
||||
|
@ -16,18 +22,11 @@ New CFFI API static bindings. Faster, fewer bugs and easier to maintain than ct
|
|||
|
||||
**Linux (Ubuntu 16.04+): Python 3.6 - 3.8**
|
||||
|
||||
We distribute a statically linked Raylib library, install from Pypi.
|
||||
If yours isn't available then pip should attempt to build from source, but this has not been tested.
|
||||
|
||||
pip3 install raylib
|
||||
## Option 2: Build from source (Raylib 3.5, all platforms)
|
||||
|
||||
## Option 2: Install from github (Raylib 3.5, Python 3.6 - 3.9, Linux, awaiting builds for other platforms)
|
||||
|
||||
The version on Pypi may not always be up to date. If you want to test the latest version,
|
||||
clone the git repo and make a symlink to the `raylib` directory in your current project directory.
|
||||
|
||||
## Option 3: Build from source (Raylib 3.5, all platforms)
|
||||
|
||||
If you're using a platform we dont have binary builds for yet
|
||||
If you're using a platform we don't have binary builds for yet
|
||||
then you can either *use the dynamic binding with your own dll* or else you will have to build from source.
|
||||
If you do build on a new platform please
|
||||
submit your binaries as a PR.
|
||||
|
@ -54,20 +53,33 @@ Make a patched version of raylib header.
|
|||
|
||||
Build
|
||||
|
||||
cd static
|
||||
pip3 install cffi
|
||||
python3 build_linux.py
|
||||
cd ..
|
||||
python3 raylib/static/build.py
|
||||
|
||||
To build a complete set of libs for Python 3.6, 3.7, 3.8 and 3.9:
|
||||
|
||||
./build_linux_multi.sh
|
||||
|
||||
To update the Linux dynamic libs (names will be different on other platfroms):
|
||||
|
||||
cd ../..
|
||||
rm raylib/dynamic/*.so*
|
||||
cp -P /usr/local/lib/libraylib.so* raylib/dynamic/
|
||||
|
||||
### Distributing
|
||||
|
||||
To build a binary wheel distribution:
|
||||
|
||||
python3 setup.py bdist_wheel
|
||||
|
||||
and install it:
|
||||
|
||||
pip3 install dist/raylib*.whl
|
||||
|
||||
To build a complete set of libs for Python 3.6, 3.7, 3.8 and 3.9:
|
||||
|
||||
./raylib/static/build_multi.sh
|
||||
|
||||
(TODO move the dynamic libs into a separate package rather than include them with every one.)
|
||||
|
||||
### Raspberry Pi
|
||||
|
||||
The integrated GPU hardware in a Raspberry Pi ("VideoCore") is rather
|
||||
|
@ -90,9 +102,6 @@ For option 1, then also follow the above instructions, but with these
|
|||
modifications:
|
||||
|
||||
- With `cmake`, use `cmake -DWITH_PIC=on -DSTATIC=on -DSHARED=on -DPLATFORM='Raspberry Pi' ..`
|
||||
- Use `python3 build_rpi_nox.py` instead of `python3 build_linux.py`
|
||||
- Use `build_rpi_nox_multi.sh` to build a complete set of libs if you need it
|
||||
(if you're not sure, then you almost certainly don't).
|
||||
|
||||
# Use
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from ._raylib_cffi import ffi, lib as rl
|
||||
from _raylib_cffi.lib import *
|
||||
from raylib.static._raylib_cffi import ffi, lib as rl
|
||||
from raylib.static._raylib_cffi.lib import *
|
||||
from raylib.colors import *
|
||||
import cffi
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
87
raylib/static/build.py
Normal file
87
raylib/static/build.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them.
|
||||
# Raylib must be installed and compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON ..
|
||||
|
||||
from cffi import FFI
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
ffibuilder = FFI()
|
||||
|
||||
def build_linux():
|
||||
print("BUILDING FOR LINUX")
|
||||
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.set_source("raylib.static._raylib_cffi",
|
||||
"""
|
||||
#include "../../raylib/raylib.h"
|
||||
""",
|
||||
extra_link_args=['/usr/local/lib/libraylib.a','-lm', '-lpthread', '-lGLU', '-lGL', '-lrt', '-lm', '-ldl', '-lX11', '-lpthread'],
|
||||
libraries=['GL','m','pthread', 'dl', 'rt', 'X11']
|
||||
)
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
|
||||
def build_windows():
|
||||
print("BUILDING FOR WINDOWS")
|
||||
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', '').replace('bool','int'))
|
||||
ffibuilder.set_source("raylib.static._raylib_cffi",
|
||||
"""
|
||||
#include "../../raylib/raylib.h"
|
||||
""",
|
||||
extra_link_args=['/NODEFAULTLIB:MSVCRTD'],
|
||||
libraries=['raylib_static', 'gdi32', 'shell32', 'user32','OpenGL32', 'winmm'],
|
||||
)
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
|
||||
def build_mac():
|
||||
print("BUILDING FOR MAC")
|
||||
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.set_source("raylib.static._raylib_cffi",
|
||||
"""
|
||||
#include "./../raylib/raylib.h" // the C header of the library, supplied by us here
|
||||
"""
|
||||
)
|
||||
# Hack to produce static linked lib using static librarylib.a supplied by us
|
||||
version = sys.implementation.cache_tag
|
||||
if version == 'cpython-36' or version == 'cpython-37':
|
||||
version += 'm'
|
||||
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_mac.a -F/System/Library/Frameworks -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo -o ./_raylib_cffi."+version+"-darwin.so"
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
if platform.system()=="Darwin":
|
||||
print(command)
|
||||
os.system(command)
|
||||
|
||||
def build_rpi_nox():
|
||||
print("BUILDING FOR RASPBERRY PI")
|
||||
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
|
||||
ffibuilder.set_source("raylib.static._raylib_cffi",
|
||||
"""
|
||||
#include "./../raylib/raylib.h"
|
||||
""",
|
||||
extra_link_args=['/usr/local/lib/libraylib.a',
|
||||
'/opt/vc/lib/libEGL_static.a', '/opt/vc/lib/libGLESv2_static.a',
|
||||
'-L/opt/vc/lib', '-lvcos', '-lbcm_host', '-lbrcmEGL', '-lbrcmGLESv2',
|
||||
'-lm', '-lpthread', '-lrt'],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
|
||||
|
||||
|
||||
if platform.system()=="Darwin":
|
||||
build_mac()
|
||||
elif platform.system()=="Linux":
|
||||
if "x86" in platform.machine():
|
||||
build_linux()
|
||||
elif "arm" in platform.machine():
|
||||
build_rpi_nox()
|
||||
elif platform.system()=="Windows":
|
||||
build_windows()
|
||||
else:
|
||||
print("WARNING: UKKNOWN PLATFORM - trying Linux build")
|
||||
build_linux()
|
|
@ -1,24 +0,0 @@
|
|||
# Linux build assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them.
|
||||
# Raylib must be installed the compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON ..
|
||||
|
||||
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"
|
||||
""",
|
||||
extra_link_args=['/usr/local/lib/libraylib.a','-lm', '-lpthread', '-lGLU', '-lGL', '-lrt', '-lm', '-ldl', '-lX11', '-lpthread'],
|
||||
libraries=['GL','m','pthread', 'dl', 'rt', 'X11']
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
if ! command -v pyenv &> /dev/null
|
||||
then
|
||||
echo "Pyenv required: https://github.com/pyenv/pyenv-installer"
|
||||
exit
|
||||
fi
|
||||
rm *linux-gnu.so
|
||||
pyenv install -s 3.9.1
|
||||
pyenv global 3.9.1
|
||||
pip3 install cffi
|
||||
python build_linux.py
|
||||
pyenv install -s 3.8.7
|
||||
pyenv global 3.8.7
|
||||
pip3 install cffi
|
||||
python build_linux.py
|
||||
pyenv install -s 3.7.9
|
||||
pyenv global 3.7.9
|
||||
pip3 install cffi
|
||||
python build_linux.py
|
||||
pyenv install -s 3.6.12
|
||||
pyenv global 3.6.12
|
||||
pip3 install cffi
|
||||
python build_linux.py
|
|
@ -1,27 +0,0 @@
|
|||
from cffi import FFI
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
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, supplied by us here
|
||||
"""
|
||||
)
|
||||
|
||||
# Hack to produce static linked lib using static librarylib.a supplied by us
|
||||
version = sys.implementation.cache_tag
|
||||
if version == 'cpython-36' or version == 'cpython-37':
|
||||
version += 'm'
|
||||
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_mac.a -F/System/Library/Frameworks -framework OpenGL -framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo -o ./_raylib_cffi."+version+"-darwin.so"
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
if platform.system()=="Darwin":
|
||||
print(command)
|
||||
os.system(command)
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
rm *darwin.so
|
||||
pyenv global 3.8.1
|
||||
pip3 install cffi
|
||||
python build_mac.py
|
||||
pyenv global 3.7.5
|
||||
pip3 install cffi
|
||||
python build_mac.py
|
||||
pyenv global 3.6.9
|
||||
pip3 install cffi
|
||||
python build_mac.py
|
22
raylib/static/build_multi.sh
Executable file
22
raylib/static/build_multi.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
if ! command -v pyenv &> /dev/null
|
||||
then
|
||||
echo "Pyenv required: https://github.com/pyenv/pyenv-installer"
|
||||
exit
|
||||
fi
|
||||
|
||||
function build() {
|
||||
echo "Building for Python $1"
|
||||
pyenv install -s $1
|
||||
pyenv global $1
|
||||
pip3 install cffi
|
||||
pip3 install wheel
|
||||
rm -rf raylib/static/_raylib_cffi.* build
|
||||
python setup.py bdist_wheel
|
||||
}
|
||||
|
||||
build 3.9.5
|
||||
build 3.8.10
|
||||
build 3.7.10
|
||||
build 3.6.13
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# Raspberry Pi native (non-X) build assumes the GPU libraries are installed in /opt/vc, as per Raspbian.
|
||||
# Raylib must be installed the compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON -DPLATFORM='Raspberry Pi' ..
|
||||
|
||||
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"
|
||||
""",
|
||||
extra_link_args=['/usr/local/lib/libraylib.a',
|
||||
'/opt/vc/lib/libEGL_static.a', '/opt/vc/lib/libGLESv2_static.a',
|
||||
'-L/opt/vc/lib', '-lvcos', '-lbcm_host', '-lbrcmEGL', '-lbrcmGLESv2',
|
||||
'-lm', '-lpthread', '-lrt'],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
if ! command -v pyenv &> /dev/null
|
||||
then
|
||||
echo "Pyenv required: https://github.com/pyenv/pyenv-installer"
|
||||
exit
|
||||
fi
|
||||
rm *arm-linux-gnueabihf.so
|
||||
pyenv install -s 3.9.1
|
||||
pyenv global 3.9.1
|
||||
pip3 install cffi
|
||||
python3 build_rpi_nox.py
|
||||
pyenv install -s 3.8.7
|
||||
pyenv global 3.8.7
|
||||
pip3 install cffi
|
||||
python3 build_rpi_nox.py
|
||||
pyenv install -s 3.7.9
|
||||
pyenv global 3.7.9
|
||||
pip3 install cffi
|
||||
python3 build_rpi_nox.py
|
||||
pyenv install -s 3.6.12
|
||||
pyenv global 3.6.12
|
||||
pip3 install cffi
|
||||
python3 build_rpi_nox.py
|
|
@ -1,17 +0,0 @@
|
|||
# Windows build assumes raylib, OpenGL32, etc are all already installed as system libraries. We dont distribute them.
|
||||
|
||||
from cffi import FFI
|
||||
|
||||
ffibuilder = FFI()
|
||||
ffibuilder.cdef(open("../raylib_modified.h").read().replace('RLAPI ', '').replace('bool','int'))
|
||||
ffibuilder.set_source("_raylib_cffi",
|
||||
"""
|
||||
#include "../raylib.h"
|
||||
""",
|
||||
extra_link_args=['/NODEFAULTLIB:MSVCRTD'],
|
||||
libraries=['raylib_static', 'gdi32', 'shell32', 'user32','OpenGL32', 'winmm'],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ffibuilder.compile(verbose=True)
|
10
setup.py
10
setup.py
|
@ -1,5 +1,6 @@
|
|||
import pathlib
|
||||
from setuptools import setup
|
||||
from setuptools.dist import Distribution
|
||||
|
||||
# The directory containing this file
|
||||
HERE = pathlib.Path(__file__).parent
|
||||
|
@ -7,6 +8,11 @@ HERE = pathlib.Path(__file__).parent
|
|||
# The text of the README file
|
||||
README = (HERE / "README.md").read_text()
|
||||
|
||||
class BinaryDistribution(Distribution):
|
||||
"""Distribution which always forces a binary package with platform name"""
|
||||
def has_ext_modules(foo):
|
||||
return True
|
||||
|
||||
# This call to setup() does all the work
|
||||
setup(
|
||||
name="raylib",
|
||||
|
@ -21,6 +27,7 @@ setup(
|
|||
classifiers=[
|
||||
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
|
@ -28,5 +35,6 @@ setup(
|
|||
packages=["raylib", "raylib.dynamic", "raylib.static"],
|
||||
include_package_data=True,
|
||||
install_requires=["cffi>=1.14.0","inflection"],
|
||||
#cffi_modules=["raylib/build_mac.py:ffibuilder"], # this would build libs whenever the module is installed, but we are distributing static libs instead
|
||||
distclass=BinaryDistribution,
|
||||
cffi_modules=["raylib/static/build.py:ffibuilder"], # this would build libs whenever the module is installed, but we are distributing static libs instead
|
||||
)
|
||||
|
|
Reference in a new issue