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