raylib 5.5.0.3rc1__pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of raylib might be problematic. Click here for more details.

raylib/build.py ADDED
@@ -0,0 +1,322 @@
1
+ # Copyright (c) 2021 Richard Smith and others
2
+ #
3
+ # This program and the accompanying materials are made available under the
4
+ # terms of the Eclipse Public License 2.0 which is available at
5
+ # http://www.eclipse.org/legal/epl-2.0.
6
+ #
7
+ # This Source Code may also be made available under the following Secondary
8
+ # licenses when the conditions for such availability set forth in the Eclipse
9
+ # Public License, v. 2.0 are satisfied: GNU General Public License, version 2
10
+ # with the GNU Classpath Exception which is
11
+ # available at https://www.gnu.org/software/classpath/license.html.
12
+ #
13
+ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+
15
+ # Assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them.
16
+ # Raylib must be installed and compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON ..
17
+
18
+
19
+ import re
20
+ from cffi import FFI
21
+ import os
22
+ import platform
23
+ import subprocess
24
+ import time
25
+ from pathlib import Path
26
+
27
+ THIS_DIR = Path(__file__).resolve().parent
28
+ REPO_ROOT = THIS_DIR.parent
29
+
30
+ # TODO: I think the customisation is making this file overly complex and probably isn't used
31
+ # by many/any users, see discussion at https://github.com/electronstudio/raylib-python-cffi/pull/172
32
+ #
33
+ # Environment variables you can set before build
34
+ #
35
+ # RAYLIB_PLATFORM: Any one of: Desktop, SDL, DRM, PLATFORM_COMMA
36
+ # RAYLIB_LINK_ARGS: Arguments to pass to the linker rather than getting them from pkg-config.
37
+ # e.g.: -L/usr/local/lib -lraylib
38
+ # RAYLIB_INCLUDE_PATH: Directory to find raylib.h rather than getting from pkg-config.
39
+ # e.g.: /usr/local/include
40
+ # RAYGUI_INCLUDE_PATH: Directory to find raygui.h
41
+ # e.g.: /usr/local/include
42
+ # GLFW_INCLUDE_PATH: Directory to find glfw3.h
43
+ # e.g.: /usr/local/include/GLFW
44
+ # PHYSAC_INCLUDE_PATH: Directory to find physac.h
45
+ # e.g.: /usr/local/include
46
+ # LIBFFI_INCLUDE_PATH:
47
+ # e.g.: /usr/local/include
48
+ #
49
+ # PKG_CONFIG_LIB_raylib: the package to request from pkg-config for raylib include files, default 'raylib'
50
+ # PKG_CONFIG_LIB_raygui: the package to request from pkg-config for raygui include files
51
+ # set to 'raygui' if you have a separate raygui package, else unset for default 'raylib'
52
+ # PKG_CONFIG_LIB_physac: the package to request from pkg-config for physac indlude files
53
+ # set to 'physac' if you have a separate raygui physac, else unset for default 'raylib'
54
+ # PKG_CONFIG_LIB_glfw3: the package to request from pkg-config for glfw3 include files
55
+ # set to 'glfw3' if you have a separate glfw3 package, else unset for default 'raylib'
56
+ # PKG_CONFIG_LIB_libffi: the package to request from pkg-config for libffi include files
57
+
58
+ RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
59
+
60
+ def check_raylib_pkgconfig_installed():
61
+ # this should be 'pkg-config --exists raylib' but result is non-deterministic on old versions of pkg-config!
62
+ return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
63
+
64
+ def check_sdl_pkgconfig_installed():
65
+ # this should be 'pkg-config --exists sdl2' but result is non-deterministic on old versions of pkg-config!
66
+ return subprocess.run(['pkg-config', '--libs', 'sdl2'], text=True, stdout=subprocess.PIPE).returncode == 0
67
+
68
+
69
+ def get_the_include_path_from_pkgconfig(libname):
70
+ return subprocess.run(
71
+ ['pkg-config', '--variable=includedir', os.environ.get("PKG_CONFIG_LIB_" + libname, 'raylib')], text=True,
72
+ stdout=subprocess.PIPE).stdout.strip()
73
+
74
+
75
+ def get_the_lib_path_from_pkgconfig():
76
+ return subprocess.run(['pkg-config', '--variable=libdir', 'raylib'], text=True,
77
+ stdout=subprocess.PIPE).stdout.strip()
78
+
79
+ def get_lib_flags_from_pkgconfig():
80
+ return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
81
+ stdout=subprocess.PIPE).stdout.strip()
82
+
83
+ def pre_process_header(filename, remove_function_bodies=False):
84
+ print("Pre-processing " + filename)
85
+ file = open(filename, "r")
86
+ filetext = "".join([line for line in file if '#include' not in line])
87
+ command = ['gcc', '-CC', '-P', '-undef', '-nostdinc', '-DRL_MATRIX_TYPE',
88
+ '-DRL_QUATERNION_TYPE','-DRL_VECTOR4_TYPE','-DRL_VECTOR3_TYPE','-DRL_VECTOR2_TYPE',
89
+ '-DRLAPI=', '-DPHYSACDEF=', '-DRAYGUIDEF=','-DRMAPI=',
90
+ '-dDI', '-E', '-']
91
+ filetext = subprocess.run(command, text=True, input=filetext, stdout=subprocess.PIPE).stdout
92
+ filetext = filetext.replace("va_list", "void *")
93
+ if remove_function_bodies:
94
+ filetext = re.sub('\n{\n(.|\n)*?\n}\n', ';', filetext)
95
+ filetext = "\n".join([line for line in filetext.splitlines() if not line.startswith("#")])
96
+ file = open("raylib/"+os.path.basename(filename)+".modified", "w")
97
+ file.write(filetext)
98
+ # print(r)
99
+ return filetext
100
+
101
+
102
+ def check_header_exists(file):
103
+ if not os.path.isfile(file):
104
+ print("\n\n*************** WARNING ***************\n\n")
105
+ print(
106
+ file + " not found. Build will not contain these extra functions.\n\nPlease copy file from src/extras to " + file + " if you want them.\n\n")
107
+ print("**************************************\n\n")
108
+ time.sleep(1)
109
+ return False
110
+ return True
111
+
112
+
113
+ # def mangle(file):
114
+ # result = ""
115
+ # skip = False
116
+ # for line in open(file):
117
+ # line = line.strip().replace("va_list", "void *") + "\n"
118
+ # if skip:
119
+ # if line.startswith("#endif"):
120
+ # skip = False
121
+ # continue
122
+ # if line.startswith("#if defined(__cplusplus)"):
123
+ # skip = True
124
+ # continue
125
+ # if line.startswith("#endif // RAYGUI_H"):
126
+ # break
127
+ # if line.startswith("#"):
128
+ # continue
129
+ # if line.startswith("RLAPI"):
130
+ # line = line.replace('RLAPI ', '')
131
+ # if line.startswith("RAYGUIDEF"):
132
+ # line = line.replace('RAYGUIDEF ', '')
133
+ # if line.startswith("PHYSACDEF"):
134
+ # line = line.replace('PHYSACDEF ', '')
135
+ # result += line
136
+ # # print(line)
137
+ # return result
138
+
139
+
140
+ def build_unix():
141
+ if os.getenv("RAYLIB_LINK_ARGS") is None and not check_raylib_pkgconfig_installed():
142
+ print("PKG_CONFIG_PATH is set to: "+os.getenv("PKG_CONFIG_PATH"))
143
+ raise Exception("ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib"
144
+ "or else set RAYLIB_LINK_ARGS env variable.")
145
+
146
+ if RAYLIB_PLATFORM=="SDL" and os.getenv("RAYLIB_LINK_ARGS") is None and not check_sdl_pkgconfig_installed():
147
+ print("PKG_CONFIG_PATH is set to: "+os.getenv("PKG_CONFIG_PATH"))
148
+ raise Exception("ERROR: SDL2 not found by pkg-config. Please install pkg-config and SDL2."
149
+ "or else set RAYLIB_LINK_ARGS env variable.")
150
+
151
+ raylib_include_path = os.getenv("RAYLIB_INCLUDE_PATH")
152
+ if raylib_include_path is None:
153
+ raylib_include_path = get_the_include_path_from_pkgconfig("raylib")
154
+ raylib_h = raylib_include_path + "/raylib.h"
155
+ rlgl_h = raylib_include_path + "/rlgl.h"
156
+ raymath_h = raylib_include_path + "/raymath.h"
157
+
158
+ if not os.path.isfile(raylib_h):
159
+ raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
160
+
161
+ if not os.path.isfile(rlgl_h):
162
+ raise Exception("ERROR: " + rlgl_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
163
+
164
+ if not os.path.isfile(raymath_h):
165
+ raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
166
+
167
+ ffi_includes = """
168
+ #include "raylib.h"
169
+ #include "rlgl.h"
170
+ #include "raymath.h"
171
+ """
172
+
173
+ glfw_include_path = os.getenv("GLFW_INCLUDE_PATH")
174
+ if glfw_include_path is None:
175
+ glfw_include_path = get_the_include_path_from_pkgconfig("glfw3")
176
+ glfw3_h = glfw_include_path + "/GLFW/glfw3.h"
177
+ if RAYLIB_PLATFORM=="Desktop" and check_header_exists(glfw3_h):
178
+ ffi_includes += """
179
+ #include "GLFW/glfw3.h"
180
+ """
181
+
182
+ raygui_include_path = os.getenv("RAYGUI_INCLUDE_PATH")
183
+ if raygui_include_path is None:
184
+ raygui_include_path = get_the_include_path_from_pkgconfig("raygui")
185
+ raygui_h = raygui_include_path + "/raygui.h"
186
+ if check_header_exists(raygui_h):
187
+ ffi_includes += """
188
+ #define RAYGUI_IMPLEMENTATION
189
+ #define RAYGUI_SUPPORT_RICONS
190
+ #include "raygui.h"
191
+ """
192
+
193
+ physac_include_path = os.getenv("PHYSAC_INCLUDE_PATH")
194
+ if physac_include_path is None:
195
+ physac_include_path = get_the_include_path_from_pkgconfig("physac")
196
+ physac_h = physac_include_path + "/physac.h"
197
+ if check_header_exists(physac_h):
198
+ ffi_includes += """
199
+ #define PHYSAC_IMPLEMENTATION
200
+ #include "physac.h"
201
+ """
202
+
203
+ libffi_include_path = os.getenv("LIBFFI_INCLUDE_PATH")
204
+ if libffi_include_path is None:
205
+ libffi_include_path = get_the_include_path_from_pkgconfig("libffi")
206
+
207
+ ffibuilder.cdef(pre_process_header(raylib_h))
208
+ ffibuilder.cdef(pre_process_header(rlgl_h))
209
+ ffibuilder.cdef(pre_process_header(raymath_h, True))
210
+
211
+ if os.path.isfile(raygui_h):
212
+ ffibuilder.cdef(pre_process_header(raygui_h))
213
+ if os.path.isfile(physac_h):
214
+ ffibuilder.cdef(pre_process_header(physac_h))
215
+ if RAYLIB_PLATFORM=="Desktop" and os.path.isfile(glfw3_h):
216
+ ffibuilder.cdef(pre_process_header(glfw3_h))
217
+
218
+
219
+ if platform.system() == "Darwin":
220
+ print("BUILDING FOR MAC")
221
+ flags = os.getenv("RAYLIB_LINK_ARGS")
222
+ if flags is None:
223
+ flags = get_the_lib_path_from_pkgconfig() + '/libraylib.a'
224
+ # We use /usr/local/lib/libraylib.a to ensure we link to static version
225
+ extra_link_args = flags.split() + ['-framework', 'OpenGL', '-framework', 'Cocoa',
226
+ '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework',
227
+ 'CoreVideo']
228
+ if RAYLIB_PLATFORM=="SDL":
229
+ extra_link_args += ['/usr/local/lib/libSDL2.a', '-framework', 'CoreHaptics', '-framework', 'ForceFeedback',
230
+ '-framework', 'GameController']
231
+ libraries = []
232
+ extra_compile_args = ["-Wno-error=incompatible-function-pointer-types", "-D_CFFI_NO_LIMITED_API"]
233
+ else: #platform.system() == "Linux":
234
+ print("BUILDING FOR LINUX")
235
+ flags = os.getenv("RAYLIB_LINK_ARGS")
236
+ if flags is None:
237
+ flags = get_lib_flags_from_pkgconfig()
238
+ extra_link_args = flags.split() + [ '-lm', '-lpthread', '-lGL',
239
+ '-lrt', '-lm', '-ldl', '-lpthread', '-latomic']
240
+ if RAYLIB_PLATFORM=="SDL":
241
+ extra_link_args += ['-lX11','-lSDL2']
242
+ elif RAYLIB_PLATFORM=="DRM":
243
+ extra_link_args += ['-lEGL', '-lgbm']
244
+ elif RAYLIB_PLATFORM=="PLATFORM_COMMA":
245
+ extra_link_args.remove('-lGL')
246
+ extra_link_args += ['-lGLESv2', '-lEGL', '-lwayland-client', '-lwayland-egl']
247
+ else:
248
+ extra_link_args += ['-lX11']
249
+ extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
250
+ libraries = [] # Not sure why but we put them in extra_link_args instead so *shouldnt* be needed here
251
+
252
+
253
+ print("extra_link_args: "+str(extra_link_args))
254
+ print("extra_compile_args: "+str(extra_compile_args))
255
+ print("libraries: "+str(libraries))
256
+ ffibuilder.set_source("raylib._raylib_cffi",
257
+ ffi_includes,
258
+ py_limited_api=False,
259
+ include_dirs=[raylib_include_path, raygui_include_path, physac_include_path, glfw_include_path,
260
+ libffi_include_path],
261
+ extra_link_args=extra_link_args,
262
+ extra_compile_args=extra_compile_args,
263
+ libraries=libraries)
264
+
265
+
266
+ def build_windows():
267
+ print("BUILDING FOR WINDOWS")
268
+ ffibuilder.cdef((THIS_DIR / "raylib.h.modified").read_text())
269
+ if RAYLIB_PLATFORM=="Desktop":
270
+ ffibuilder.cdef((THIS_DIR / "glfw3.h.modified").read_text())
271
+ ffibuilder.cdef((THIS_DIR / "rlgl.h.modified").read_text())
272
+ ffibuilder.cdef((THIS_DIR / "raygui.h.modified").read_text())
273
+ ffibuilder.cdef((THIS_DIR / "physac.h.modified").read_text())
274
+ ffibuilder.cdef((THIS_DIR / "raymath.h.modified").read_text())
275
+
276
+ ffi_includes = """
277
+ #include "raylib.h"
278
+ #include "rlgl.h"
279
+ #include "raymath.h"
280
+ """
281
+
282
+ if RAYLIB_PLATFORM=="Desktop":
283
+ ffi_includes += """
284
+ #include "GLFW/glfw3.h"
285
+ """
286
+
287
+ ffi_includes += """
288
+ #define RAYGUI_IMPLEMENTATION
289
+ #define RAYGUI_SUPPORT_RICONS
290
+ #include "raygui.h"
291
+ #define PHYSAC_IMPLEMENTATION
292
+ #define PHYSAC_NO_THREADS
293
+ #include "physac.h"
294
+ """
295
+ libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
296
+ if RAYLIB_PLATFORM=="SDL":
297
+ libraries += ['SDL2']
298
+
299
+ print("libraries: "+str(libraries))
300
+ ffibuilder.set_source("raylib._raylib_cffi", ffi_includes,
301
+ extra_link_args=['/NODEFAULTLIB:MSVCRTD'],
302
+ extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
303
+ py_limited_api=False,
304
+ libraries=libraries,
305
+ include_dirs=[str(REPO_ROOT / 'raylib-c/src'),
306
+ str(REPO_ROOT / 'raylib-c/src/external/glfw/include'),
307
+ str(REPO_ROOT / 'raygui/src'),
308
+ str(REPO_ROOT / 'physac/src')],
309
+ )
310
+
311
+
312
+ ffibuilder = FFI()
313
+
314
+ if platform.system() == "Windows":
315
+ build_windows()
316
+ else:
317
+ print("not windows, trying Unix build")
318
+ build_unix()
319
+
320
+
321
+ if __name__ == "__main__":
322
+ ffibuilder.compile(verbose=True)
raylib/colors.py ADDED
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2021 Richard Smith and others
2
+ #
3
+ # This program and the accompanying materials are made available under the
4
+ # terms of the Eclipse Public License 2.0 which is available at
5
+ # http://www.eclipse.org/legal/epl-2.0.
6
+ #
7
+ # This Source Code may also be made available under the following Secondary
8
+ # licenses when the conditions for such availability set forth in the Eclipse
9
+ # Public License, v. 2.0 are satisfied: GNU General Public License, version 2
10
+ # with the GNU Classpath Exception which is
11
+ # available at https://www.gnu.org/software/classpath/license.html.
12
+ #
13
+ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+
15
+ LIGHTGRAY =( 200, 200, 200, 255 )
16
+ GRAY =( 130, 130, 130, 255 )
17
+ DARKGRAY =( 80, 80, 80, 255 )
18
+ YELLOW =( 253, 249, 0, 255 )
19
+ GOLD =( 255, 203, 0, 255 )
20
+ ORANGE =( 255, 161, 0, 255 )
21
+ PINK =( 255, 109, 194, 255 )
22
+ RED =( 230, 41, 55, 255 )
23
+ MAROON =( 190, 33, 55, 255 )
24
+ GREEN =( 0, 228, 48, 255 )
25
+ LIME =( 0, 158, 47, 255 )
26
+ DARKGREEN =( 0, 117, 44, 255 )
27
+ SKYBLUE =( 102, 191, 255, 255 )
28
+ BLUE =( 0, 121, 241, 255 )
29
+ DARKBLUE =( 0, 82, 172, 255 )
30
+ PURPLE =( 200, 122, 255, 255 )
31
+ VIOLET =( 135, 60, 190, 255 )
32
+ DARKPURPLE =( 112, 31, 126, 255 )
33
+ BEIGE =( 211, 176, 131, 255 )
34
+ BROWN =( 127, 106, 79, 255 )
35
+ DARKBROWN =( 76, 63, 47, 255 )
36
+ WHITE =( 255, 255, 255, 255 )
37
+ BLACK =( 0, 0, 0, 255 )
38
+ BLANK =( 0, 0, 0, 0 )
39
+ MAGENTA =( 255, 0, 255, 255 )
40
+ RAYWHITE =( 245, 245, 245, 255 )
41
+