|
| 1 | +## Have Pip build from source |
| 2 | + |
| 3 | +Useful if the binaries don't work on your system. |
| 4 | + |
| 5 | +Make sure Raylib is installed and then: |
| 6 | + |
| 7 | + pip3 install --no-binary raylib --upgrade --force-reinstall raylib |
| 8 | + |
| 9 | +## Build from source manually |
| 10 | + |
| 11 | +Useful if the Pip build doesn't work, or you want to contribute to the project, or you want to skip building the |
| 12 | +static lib and just *use the dynamic binding with your own dll*. |
| 13 | + |
| 14 | +If you do build on a new platform please |
| 15 | +submit your binaries as a PR. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +### Windows manual build |
| 20 | + |
| 21 | +Clone this repo including submodules so you get correct version of Raylib. |
| 22 | + |
| 23 | + git clone --recurse-submodules https://github.com/electronstudio/raylib-python-cffi |
| 24 | + |
| 25 | +Open Visual C++ command shell. |
| 26 | + |
| 27 | +Fix the symlink that doesnt work on Windows |
| 28 | + |
| 29 | + cd raylib-python-cffi |
| 30 | + copy raylib-c\src\raylib.h raylib\raylib.h |
| 31 | + |
| 32 | +Build and install Raylib from the raylib-c directory. |
| 33 | + |
| 34 | + cd raylib-python-cffi/raylib-c |
| 35 | + mkdir build |
| 36 | + cd build |
| 37 | + cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. |
| 38 | + msbuild raylib.sln /target:raylib /property:Configuration=Release |
| 39 | + copy raylib\Release\raylib.lib ..\.. |
| 40 | + cd ..\.. |
| 41 | + |
| 42 | +To update the dynamic libs, download the official release, e.g. https://github.com/raysan5/raylib/releases/download/3.7.0/raylib-3.7.0_win64_msvc16.zip and extract `raylib.dll` |
| 43 | +into `raylib/dynamic`. Delete the files for other platforms, unless you want them in your distribution. |
| 44 | + |
| 45 | +To build a binary wheel distribution: |
| 46 | + |
| 47 | + rmdir /Q /S build |
| 48 | + pip3 install cffi |
| 49 | + pip3 install wheel |
| 50 | + python setup.py bdist_wheel |
| 51 | + |
| 52 | +and install it: |
| 53 | + |
| 54 | + pip3 install dist\raylib-3.7.0-cp37-cp37m-win_amd64.whl |
| 55 | + |
| 56 | +(Note: your wheel's filename will probably be different than the one here.) |
| 57 | + |
| 58 | +### Linux etc manual build |
| 59 | + |
| 60 | +These instructions have been tested on Ubuntu 20.10 and 16.04. Mac should be very similar. |
| 61 | + |
| 62 | +Clone this repo including submodules so you get correct version of Raylib. |
| 63 | + |
| 64 | + git clone --recurse-submodules https://github.com/electronstudio/raylib-python-cffi |
| 65 | + |
| 66 | +Build and install Raylib from the raylib-c directory. |
| 67 | + |
| 68 | + sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev |
| 69 | + cd raylib-python-cffi/raylib-c |
| 70 | + mkdir build |
| 71 | + cd build |
| 72 | + cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. |
| 73 | + sudo make install |
| 74 | + |
| 75 | +Optional: Build the Raylib shared libs, if you plan to use `raylib.dynamic` binding. |
| 76 | + |
| 77 | + rm -rf * |
| 78 | + cmake -DWITH_PIC=on -DBUILD_SHARED_LIBS=on -DCMAKE_BUILD_TYPE=Release .. |
| 79 | + sudo make install |
| 80 | + |
| 81 | +Optional: Make a patched version of raylib header. (**Not necessary** if you've already got |
| 82 | +raylib_modifed.h from repo and haven't changed anything.) |
| 83 | + |
| 84 | + cd ../../raylib |
| 85 | + cp raylib.h raylib_modified.h |
| 86 | + patch -p0 <raylib_modified.h.patch |
| 87 | + |
| 88 | + |
| 89 | +Build |
| 90 | + |
| 91 | + pip3 install cffi |
| 92 | + cd .. |
| 93 | + rm -rf build raylib/static/_raylib_cffi.* |
| 94 | + python3 raylib/static/build.py |
| 95 | + |
| 96 | + |
| 97 | +To update the Linux dynamic libs (names will be different on other platfroms): |
| 98 | + |
| 99 | + rm raylib/dynamic/*.so* |
| 100 | + cp -P /usr/local/lib/libraylib.so* raylib/dynamic/ |
| 101 | + |
| 102 | +To build a binary wheel distribution: |
| 103 | + |
| 104 | + pip3 install wheel |
| 105 | + python3 setup.py bdist_wheel |
| 106 | + |
| 107 | +and install it: |
| 108 | + |
| 109 | + pip3 install dist/raylib*.whl |
| 110 | + |
| 111 | +To build a complete set of libs for Python 3.6, 3.7, 3.8 and 3.9: |
| 112 | + |
| 113 | + ./raylib/static/build_multi.sh |
| 114 | + |
| 115 | +(NOTE pypi wont accept Linux packages unless they are built `--plat-name manylinux2014_x86_64` so on linux |
| 116 | +please run `./raylib/static/build_multi_linux.sh` ) |
| 117 | + |
| 118 | +(TODO move the dynamic libs into a separate package rather than include them with every one.) |
| 119 | + |
| 120 | +### Raspberry Pi |
| 121 | + |
| 122 | +The integrated GPU hardware in a Raspberry Pi ("VideoCore") is rather |
| 123 | +idiosyncratic, resulting in a complex set of software options. Probably the |
| 124 | +most interesting two options for Raylib applications are: |
| 125 | + |
| 126 | +1. Use the Broadcom proprietary Open GL ES 2.0 drivers, installed by Raspbian |
| 127 | + into `/opt/vc`. These are 32-bit only, and currently X11 doesn't use these |
| 128 | + for its acceleration, so this is most suitable for driving the entire HDMI |
| 129 | + output from one application with minimal overhead (no X11). |
| 130 | + |
| 131 | +2. Use the more recent open-source `vc4-fkms-v3d` kernel driver. This can run |
| 132 | + in either 32-bit or 64-bit, and X11 can use these, so using X11 is probably |
| 133 | + the more common choice here. |
| 134 | + |
| 135 | +With option 2, the regular linux install instructions above should probably |
| 136 | +work as-is. |
| 137 | + |
| 138 | +For option 1, then also follow the above instructions, but with these |
| 139 | +modifications: |
| 140 | + |
| 141 | +- With `cmake`, use `cmake -DWITH_PIC=on -DSTATIC=on -DSHARED=on -DPLATFORM='Raspberry Pi' ..` |
| 142 | + |
| 143 | +(See [here](https://github.com/electronstudio/raylib-python-cffi/issues/31#issuecomment-862078330) for a Raspberry Pi wheel) |
0 commit comments