raylib 5.0.0.1__cp311-cp311-macosx_13_0_arm64.whl → 5.0.0.2__cp311-cp311-macosx_13_0_arm64.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.

pyray/__init__.py CHANGED
@@ -11,6 +11,9 @@
11
11
  # available at https://www.gnu.org/software/classpath/license.html.
12
12
  #
13
13
  # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14
+ import re
15
+ import weakref
16
+ from array import array
14
17
 
15
18
  from raylib import rl, ffi
16
19
  from raylib.colors import *
@@ -21,12 +24,21 @@ except AttributeError:
21
24
  print("sorry deprecated enums dont work on dynamic version")
22
25
 
23
26
  from inspect import getmembers, isbuiltin
24
- import inflection
25
27
 
26
28
  current_module = __import__(__name__)
27
29
 
28
30
 
29
- def pointer(self, struct):
31
+ def _underscore(word: str) -> str:
32
+ """
33
+ from inflection
34
+ """
35
+ word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
36
+ word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
37
+ word = word.replace("-", "_")
38
+ return word.lower()
39
+
40
+
41
+ def pointer(struct):
30
42
  return ffi.addressof(struct)
31
43
 
32
44
 
@@ -38,70 +50,93 @@ def pointer(self, struct):
38
50
  # Another possibility is ffi.typeof() but that will throw an exception if you give it a type that isn't a ctype
39
51
  # Another way to improve performance might be to special-case simple types before doing the string comparisons
40
52
 
41
- def makefunc(a):
53
+ def _wrap_function(original_func):
42
54
  # print("makefunc ",a, ffi.typeof(a).args)
43
- def func(*args):
55
+ def wrapped_func(*args):
44
56
  modified_args = []
45
- for (c_arg, arg) in zip(ffi.typeof(a).args, args):
46
- #print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg)))
57
+ for (c_arg, arg) in zip(ffi.typeof(original_func).args, args):
58
+ # print("arg:",str(arg), "c_arg.kind:", c_arg.kind, "c_arg:", c_arg, "type(arg):",str(type(arg)))
47
59
  if c_arg.kind == 'pointer':
48
- if type(arg) == str:
60
+ if type(arg) is str:
49
61
  arg = arg.encode('utf-8')
50
- elif type(arg) is bool:
51
- arg = ffi.new("bool *", arg)
52
- elif type(arg) is int:
53
- arg = ffi.new("int *", arg)
54
- elif type(arg) is float:
55
- arg = ffi.new("float *", arg)
56
- elif type(arg) is list and str(c_arg) == "<ctype 'char * *'>":
62
+ # if c_arg is a 'char *' not a 'const char *' then we ought to raise here because its an out
63
+ # parameter and user should supply a ctype pointer, but cffi cant detect const
64
+ # so we would have to get the info from raylib.json
65
+ elif type(arg) is list and str(c_arg) == "<ctype 'char * *'>":
57
66
  arg = [ffi.new("char[]", x.encode('utf-8')) for x in arg]
58
- elif str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" and "*" not in str(arg): # CPython
59
- arg = ffi.addressof(arg)
60
- elif str(type(arg)) == "<class '_cffi_backend._CDataBase'>" and "*" not in str(arg): # Pypy
67
+ elif is_cdata(arg) and "*" not in str(arg):
61
68
  arg = ffi.addressof(arg)
62
69
  elif arg is None:
63
70
  arg = ffi.NULL
71
+ elif not is_cdata(arg):
72
+ if str(c_arg) == "<ctype '_Bool *'>":
73
+ raise TypeError(
74
+ "Argument must be a ctype bool, please create one with: pyray.ffi.new('bool *', True)")
75
+ elif str(c_arg) == "<ctype 'int *'>":
76
+ raise TypeError(
77
+ "Argument must be a ctype int, please create one with: pyray.ffi.new('int *', 1)")
78
+ elif str(c_arg) == "<ctype 'float *'>":
79
+ raise TypeError(
80
+ "Argument must be a ctype float, please create one with: pyray.ffi.new('float *', 1.0)")
64
81
  modified_args.append(arg)
65
- result = a(*modified_args)
82
+ result = original_func(*modified_args)
66
83
  if result is None:
67
84
  return
68
- if str(type(result)) == "<class '_cffi_backend._CDataBase'>" and str(result).startswith("<cdata 'char *'"):
85
+ elif is_cdata(result) and str(result).startswith("<cdata 'char *'"):
69
86
  if str(result) == "<cdata 'char *' NULL>":
70
- result = ""
87
+ return ""
71
88
  else:
72
- result = ffi.string(result).decode('utf-8')
73
- return result
89
+ return ffi.string(result).decode('utf-8')
90
+ else:
91
+ return result
74
92
 
75
- return func
93
+ # apparently pypy and cpython produce different types so check for both
94
+ def is_cdata(arg):
95
+ return str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" or str(
96
+ type(arg)) == "<class '_cffi_backend._CDataBase'>"
76
97
 
98
+ return wrapped_func
77
99
 
78
- def makeStructHelper(struct):
100
+
101
+ global_weakkeydict = weakref.WeakKeyDictionary()
102
+
103
+
104
+ def _make_struct_constructor_function(struct):
79
105
  def func(*args):
80
- return ffi.new(f"struct {struct} *", args)[0]
106
+ # print(struct, args)
107
+ modified_args = []
108
+ for (field, arg) in zip(ffi.typeof(struct).fields, args):
109
+ # print("arg:", str(arg), "field:", field[1], "field type:", field[1].type, "type(arg):", str(type(arg)))
110
+ if arg is None:
111
+ arg = ffi.NULL
112
+ elif (field[1].type.kind == 'pointer'
113
+ and (str(type(arg)) == "<class 'numpy.ndarray'>"
114
+ or isinstance(arg, (array, bytes, bytearray, memoryview)))):
115
+ arg = ffi.from_buffer(field[1].type, arg)
116
+ modified_args.append(arg)
117
+ s = ffi.new(f"struct {struct} *", modified_args)[0]
118
+ global_weakkeydict[s] = modified_args
119
+ return s
81
120
 
82
121
  return func
83
122
 
84
123
 
85
124
  for name, attr in getmembers(rl):
86
125
  # print(name, attr)
87
- uname = inflection.underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
126
+ uname = _underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
88
127
  if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
89
128
  type(attr)) == "<class '_cffi_backend._CDataBase'>":
90
129
  # print(attr.__call__)
91
130
  # print(attr.__doc__)
92
- # print(attr.__text_signature__)
93
131
  # print(dir(attr))
94
132
  # print(dir(attr.__repr__))
95
- f = makefunc(attr)
133
+ f = _wrap_function(attr)
96
134
  setattr(current_module, uname, f)
97
- # def wrap(*args):
98
- # print("call to ",attr)
99
- # setattr(PyRay, uname, lambda *args: print("call to ",attr))
100
135
  else:
101
136
  setattr(current_module, name, attr)
102
137
 
103
138
  for struct in ffi.list_types()[0]:
104
- f = makeStructHelper(struct)
139
+ f = _make_struct_constructor_function(struct)
105
140
  setattr(current_module, struct, f)
106
141
 
107
142
  # overwrite ffi enums with our own
pyray/__init__.pyi CHANGED
@@ -937,10 +937,10 @@ def gui_line(bounds: Rectangle,text: str,) -> int:
937
937
  def gui_list_view(bounds: Rectangle,text: str,scrollIndex: Any,active: Any,) -> int:
938
938
  """List View control, returns selected list item index"""
939
939
  ...
940
- def gui_list_view_ex(bounds: Rectangle,text: str,count: int,scrollIndex: Any,active: Any,focus: Any,) -> int:
940
+ def gui_list_view_ex(bounds: Rectangle,text: list[str],count: int,scrollIndex: Any,active: Any,focus: Any,) -> int:
941
941
  """List View with extended parameters"""
942
942
  ...
943
- def gui_load_icons(fileName: str,loadIconsName: bool,) -> str:
943
+ def gui_load_icons(fileName: str,loadIconsName: bool,) -> list[str]:
944
944
  """Load raygui icons file (.rgi) into internal icons data"""
945
945
  ...
946
946
  def gui_load_style(fileName: str,) -> None:
@@ -994,7 +994,7 @@ def gui_spinner(bounds: Rectangle,text: str,value: Any,minValue: int,maxValue: i
994
994
  def gui_status_bar(bounds: Rectangle,text: str,) -> int:
995
995
  """Status Bar control, shows info text"""
996
996
  ...
997
- def gui_tab_bar(bounds: Rectangle,text: str,count: int,active: Any,) -> int:
997
+ def gui_tab_bar(bounds: Rectangle,text: list[str],count: int,active: Any,) -> int:
998
998
  """Tab Bar control, returns TAB to be closed or -1"""
999
999
  ...
1000
1000
  def gui_text_box(bounds: Rectangle,text: str,textSize: int,editMode: bool,) -> int:
@@ -1864,7 +1864,7 @@ def text_insert(text: str,insert: str,position: int,) -> str:
1864
1864
  def text_is_equal(text1: str,text2: str,) -> bool:
1865
1865
  """Check if two text string are equal"""
1866
1866
  ...
1867
- def text_join(textList: str,count: int,delimiter: str,) -> str:
1867
+ def text_join(textList: list[str],count: int,delimiter: str,) -> str:
1868
1868
  """Join text strings with delimiter"""
1869
1869
  ...
1870
1870
  def text_length(text: str,) -> int:
@@ -1873,7 +1873,7 @@ def text_length(text: str,) -> int:
1873
1873
  def text_replace(text: str,replace: str,by: str,) -> str:
1874
1874
  """Replace text string (WARNING: memory must be freed!)"""
1875
1875
  ...
1876
- def text_split(text: str,delimiter: str,count: Any,) -> str:
1876
+ def text_split(text: str,delimiter: str,count: Any,) -> list[str]:
1877
1877
  """Split text into multiple strings"""
1878
1878
  ...
1879
1879
  def text_subtext(text: str,position: int,length: int,) -> str:
@@ -2260,7 +2260,7 @@ def glfw_get_current_context() -> Any:
2260
2260
  def glfw_get_cursor_pos(window: Any,xpos: Any,ypos: Any,) -> None:
2261
2261
  """"""
2262
2262
  ...
2263
- def glfw_get_error(description: str,) -> int:
2263
+ def glfw_get_error(description: list[str],) -> int:
2264
2264
  """"""
2265
2265
  ...
2266
2266
  def glfw_get_framebuffer_size(window: Any,width: Any,height: Any,) -> None:
@@ -2338,7 +2338,7 @@ def glfw_get_primary_monitor() -> Any:
2338
2338
  def glfw_get_proc_address(procname: str,) -> Any:
2339
2339
  """"""
2340
2340
  ...
2341
- def glfw_get_required_instance_extensions(count: Any,) -> str:
2341
+ def glfw_get_required_instance_extensions(count: Any,) -> list[str]:
2342
2342
  """"""
2343
2343
  ...
2344
2344
  def glfw_get_time() -> float:
@@ -2452,7 +2452,7 @@ def glfw_set_cursor_pos(window: Any,xpos: float,ypos: float,) -> None:
2452
2452
  def glfw_set_cursor_pos_callback(window: Any,callback: Any,) -> Any:
2453
2453
  """"""
2454
2454
  ...
2455
- def glfw_set_drop_callback(window: Any,callback: str,) -> str:
2455
+ def glfw_set_drop_callback(window: Any,callback: list[str],) -> list[str]:
2456
2456
  """"""
2457
2457
  ...
2458
2458
  def glfw_set_error_callback(callback: str,) -> str:
Binary file
raylib/build.py CHANGED
@@ -162,16 +162,19 @@ def build_unix():
162
162
  '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework',
163
163
  'CoreVideo']
164
164
  libraries = []
165
+ extra_compile_args = ["-Wno-error=incompatible-function-pointer-types"]
165
166
  else: #platform.system() == "Linux":
166
167
  print("BUILDING FOR LINUX")
167
168
  extra_link_args = get_lib_flags() + [ '-lm', '-lpthread', '-lGL',
168
169
  '-lrt', '-lm', '-ldl', '-lX11', '-lpthread', '-latomic']
170
+ extra_compile_args = []
169
171
  libraries = ['GL', 'm', 'pthread', 'dl', 'rt', 'X11', 'atomic']
170
172
 
171
173
  ffibuilder.set_source("raylib._raylib_cffi",
172
174
  ffi_includes,
173
175
  include_dirs=[get_the_include_path()],
174
176
  extra_link_args=extra_link_args,
177
+ extra_compile_args=extra_compile_args,
175
178
  libraries=libraries)
176
179
 
177
180
 
raylib/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "5.0.0.1"
1
+ __version__ = "5.0.0.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: raylib
3
- Version: 5.0.0.1
3
+ Version: 5.0.0.2
4
4
  Summary: Python CFFI bindings for Raylib
5
5
  Home-page: https://github.com/electronstudio/raylib-python-cffi
6
6
  Author: Electron Studio
@@ -16,7 +16,6 @@ Classifier: Programming Language :: Python :: 3.7
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: cffi >=1.14.6
19
- Requires-Dist: inflection
20
19
 
21
20
  # Python Bindings for Raylib 5.0
22
21
 
@@ -26,7 +25,7 @@ original Raylib.
26
25
  * Faster, fewer bugs and easier to maintain than ctypes.
27
26
  * Commercial-friendly license.
28
27
  * Docstrings and auto-completion.
29
- * **Now includes extra libraries: raymath, raygui, rlgl and physac**
28
+ * **Now includes extra libraries: raymath, raygui, rlgl, physac and GLFW**
30
29
 
31
30
  [Full documentation](http://electronstudio.github.io/raylib-python-cffi)
32
31
 
@@ -101,6 +100,48 @@ Use [the C API](https://electronstudio.github.io/raylib-python-cffi/raylib.html)
101
100
 
102
101
  Use [the Python API](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
103
102
 
103
+ # Running in a web browser
104
+
105
+ [Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
106
+
107
+ Make a folder `my_project` with a file `main.py`:
108
+
109
+ # /// script
110
+ # dependencies = [
111
+ # "cffi",
112
+ # "inflection",
113
+ # "raylib"
114
+ # ]
115
+ # ///
116
+ import asyncio
117
+ import platform
118
+ from pyray import *
119
+
120
+ async def main(): # You must have an async main function
121
+ init_window(500, 500, "Hello")
122
+ platform.window.window_resize() # You must add this line
123
+ while not window_should_close():
124
+ begin_drawing()
125
+ clear_background(WHITE)
126
+ draw_text("Hello world", 190, 200, 20, VIOLET)
127
+ end_drawing()
128
+ await asyncio.sleep(0) # You must call this in your main loop
129
+ close_window()
130
+
131
+ asyncio.run(main())
132
+
133
+ Then to create the web files and launch a web server:
134
+
135
+ python3 -m pip install --user --upgrade git+https://github.com/pygame-web/pygbag
136
+ python3 -m pygbag --git --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
137
+
138
+ Point your browser to http://localhost:8000
139
+
140
+ This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
141
+ Carefully read all their [documentation](https://pygame-web.github.io/).
142
+
143
+ It does work for most of the examples at https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/
144
+
104
145
  # App showcase
105
146
 
106
147
  [Tanki](https://github.com/pkulev/tanki)
@@ -0,0 +1,15 @@
1
+ pyray/__init__.py,sha256=rrclikSOpisehgQEhF0JJt0BNzJ1BctMe6yn2VTI7kg,5848
2
+ pyray/__init__.pyi,sha256=aYJdrk6qhgSW82CpuQcZrI1VyW19YvXWcRSSjPUZyww,150549
3
+ raylib/__init__.py,sha256=DWXPmoq7tC5wzZsrt6rReGy1RflyZwk-SdF-9lBZHok,919
4
+ raylib/__init__.pyi,sha256=y0lmZ3wI63AC95uIddXQH2cw7e29Tk85b2FF0g0PZtY,138540
5
+ raylib/_raylib_cffi.abi3.so,sha256=YI54fcfe2ECqrZtf7UWuSeWUeRZRU7zWzTwdYn86saM,2923073
6
+ raylib/build.py,sha256=UsGR5Jaq3NHg5mEG9lt4Y09fs6bxdM2QMm7qu_38hrk,8390
7
+ raylib/colors.py,sha256=_u-mYrpdx7_v_4wnJrnSu_m36ixKJWbort780_V6rTw,1523
8
+ raylib/defines.py,sha256=lMv6zU8WSkaH5Dj5Ydx0AlggeA-r76xePcA1M7EudnA,15951
9
+ raylib/enums.py,sha256=RtQpN23zViI2mQSHPPc0Ay4IvNdiDk_xggdMPLCR0ng,17586
10
+ raylib/version.py,sha256=yryH--YVbWBWyZ6iG0g7w5O2zBm-xecY7jnSFTmKeFs,23
11
+ raylib-5.0.0.2.dist-info/LICENSE,sha256=C-zxZWe-t3-iUrdmRjHdF3yPmhiJ5ImVtFN5xxMOUwM,14198
12
+ raylib-5.0.0.2.dist-info/METADATA,sha256=V7KR-LXzTDFkkX56SBUU7x7RKUqLe0nRmY8Itbqqg_s,6871
13
+ raylib-5.0.0.2.dist-info/WHEEL,sha256=2b-71v4wElgbMRjc3K6_XYKCbPJSo3YDBADvpZuPVr4,110
14
+ raylib-5.0.0.2.dist-info/top_level.txt,sha256=PnMBDWaUP4jsbn_NewagcC9FjHYpzSAIQuhxNzt9hkg,13
15
+ raylib-5.0.0.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-macosx_13_0_arm64
5
5
 
@@ -1,15 +0,0 @@
1
- pyray/__init__.py,sha256=rqSg_m5QmUVqPcUpsKZLlemqr0YXbWe7JiEWM3ByNhk,4249
2
- pyray/__init__.pyi,sha256=YhqrlHPkD1pdZKJe3kvzGhHRaSlkt4i4tVkhysYYG1E,150495
3
- raylib/__init__.py,sha256=DWXPmoq7tC5wzZsrt6rReGy1RflyZwk-SdF-9lBZHok,919
4
- raylib/__init__.pyi,sha256=y0lmZ3wI63AC95uIddXQH2cw7e29Tk85b2FF0g0PZtY,138540
5
- raylib/_raylib_cffi.abi3.so,sha256=4k62pLp9juqg07myrxg7Y-uEKr2UicrUqSFLtEGZaNc,2829128
6
- raylib/build.py,sha256=cl1OCJOZNul1-SK264Eoa773PdBcFEFxLcpnpKT1XaI,8213
7
- raylib/colors.py,sha256=_u-mYrpdx7_v_4wnJrnSu_m36ixKJWbort780_V6rTw,1523
8
- raylib/defines.py,sha256=lMv6zU8WSkaH5Dj5Ydx0AlggeA-r76xePcA1M7EudnA,15951
9
- raylib/enums.py,sha256=RtQpN23zViI2mQSHPPc0Ay4IvNdiDk_xggdMPLCR0ng,17586
10
- raylib/version.py,sha256=jxR8hUOjIF7W_jxqRXhSenckU7b3etHSDsGt7TUhigE,23
11
- raylib-5.0.0.1.dist-info/LICENSE,sha256=C-zxZWe-t3-iUrdmRjHdF3yPmhiJ5ImVtFN5xxMOUwM,14198
12
- raylib-5.0.0.1.dist-info/METADATA,sha256=e1B1A9BEDpjh1PtQO9F5BMKPLMOuQOzPhKyZnxCcs48,5501
13
- raylib-5.0.0.1.dist-info/WHEEL,sha256=E-1gYRQuPxSUirHUpbFc1-QH3Vg3hrD7HRk3RIX_hQY,110
14
- raylib-5.0.0.1.dist-info/top_level.txt,sha256=PnMBDWaUP4jsbn_NewagcC9FjHYpzSAIQuhxNzt9hkg,13
15
- raylib-5.0.0.1.dist-info/RECORD,,