Skip to content

Commit 775d2da

Browse files
remove depreciated stuff, tidy build a bit for 4.0
1 parent c818fae commit 775d2da

17 files changed

+63
-201
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ include raylib/*.h
66
include raylib/*.pyi
77
exclude raylib/*.c
88
exclude raylib/*.o
9+
include version.py
10+

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ There is now a separate dynamic version of this binding:
4545

4646
[Read this before using raylib_dynamic](https://electronstudio.github.io/raylib-python-cffi/dynamic.html)
4747

48+
## Beta testing
49+
50+
You can install an alpha or beta version by specifying the version number like this:
51+
52+
python3 -m pip install raylib==4.0a3
53+
4854

4955
# How to use
5056

dynamic/test_dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
mesh = rl.GenMeshHeightmap(image, [16, 8, 16])
1515
model = rl.LoadModelFromMesh(mesh)
1616
print(model.materials) # SHOULD BE A pointer to a 'struct Material' but some is NULL pointer to 'Material' ?
17-
model.materials.maps[rl.MATERIAL_MAP_DIFFUSE].texture = texture
17+
model.materials.maps[rl.MATERIAL_MAP_ALBEDO].texture = texture
1818

1919
rl.UnloadImage(image)
2020
rl.SetCameraMode(camera[0], rl.CAMERA_ORBITAL)

dynamic/test_pyray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
texture = pr.load_texture_from_image(image)
1717
mesh = pr.gen_mesh_heightmap(image, (16, 8, 16))
1818
model = pr.load_model_from_mesh(mesh)
19-
model.materials.maps[pr.MATERIAL_MAP_DIFFUSE].texture = texture
19+
model.materials.maps[pr.MATERIAL_MAP_ALBEDO].texture = texture
2020

2121
pr.unload_image(image)
2222
pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)

examples/models/models_cubicmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# NOTE: By default each cube is mapped to one part of texture atlas
3232
texture = LoadTexture(b"resources/cubicmap_atlas.png") # Load map texture
33-
model.materials[0].maps[MATERIAL_MAP_DIFFUSE ].texture = texture # Set map diffuse texture
33+
model.materials[0].maps[MATERIAL_MAP_ALBEDO ].texture = texture # Set map diffuse texture
3434

3535
mapPosition = [ -16.0, 0.0, -8.0 ] # Set model position
3636

examples/models/models_heightmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
mesh = GenMeshHeightmap(image, ( 16, 8, 16 )) # Generate heightmap mesh (RAM and VRAM)
2828
model = LoadModelFromMesh(mesh) # Load model from generated mesh
2929

30-
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture # Set map diffuse texture
30+
model.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = texture # Set map diffuse texture
3131
mapPosition = ( -8.0, 0.0, -8.0 ) # Define model position
3232

3333
UnloadImage(image) # Unload heightmap image from RAM, already uploaded to VRAM

examples/models/models_obj_loading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
model = LoadModel(b"resources/models/house.obj") # Load OBJ model
3232
texture = LoadTexture(b"resources/models/house_diffuse.png") # Load model texture
33-
model.materials.maps[MATERIAL_MAP_DIFFUSE].texture = texture # Set map diffuse texture
33+
model.materials.maps[MATERIAL_MAP_ALBEDO].texture = texture # Set map diffuse texture
3434
position = [ 0.0, 0.0, 0.0 ] # Set model position
3535

3636
SetTargetFPS(60) # Set our game to run at 60 frames-per-second

raylib/build.py

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import platform
2323
import sys
2424

25-
2625
ffibuilder = FFI()
2726

27+
2828
def mangle(file):
2929
result = ""
3030
skip = False
3131
for line in open(file):
32-
line = line.strip().replace("va_list", "void *")+"\n"
32+
line = line.strip().replace("va_list", "void *") + "\n"
3333
if skip:
3434
if line.startswith("#endif"):
3535
skip = False
@@ -50,16 +50,14 @@ def mangle(file):
5050
if line.startswith("PHYSACDEF"):
5151
line = line.replace('PHYSACDEF ', '')
5252
result += line
53-
print(line)
53+
# print(line)
5454
return result
5555

5656

5757
def build_linux():
5858
print("BUILDING FOR LINUX")
59-
ffibuilder.cdef(mangle("raylib/raylib.h"))
60-
#ffibuilder.cdef(mangle("raylib/raygui.h"))
59+
ffibuilder.cdef(mangle("/usr/local/include/raylib.h"))
6160
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', ''))
62-
#ffibuilder.cdef(mangle("raylib/physac.h"))
6361
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', ''))
6462
ffibuilder.set_source("raylib._raylib_cffi",
6563
"""
@@ -70,18 +68,20 @@ def build_linux():
7068
#define PHYSAC_IMPLEMENTATION
7169
#include "physac.h"
7270
""",
73-
extra_link_args=['/usr/local/lib/libraylib.a','-lm', '-lpthread', '-lGLU', '-lGL', '-lrt', '-lm', '-ldl', '-lX11', '-lpthread'],
74-
libraries=['GL','m','pthread', 'dl', 'rt', 'X11'],
71+
extra_link_args=['/usr/local/lib/libraylib.a', '-lm', '-lpthread', '-lGLU', '-lGL', '-lrt',
72+
'-lm', '-ldl', '-lX11', '-lpthread'],
73+
libraries=['GL', 'm', 'pthread', 'dl', 'rt', 'X11'],
7574
include_dirs=['raylib']
7675
)
7776
if __name__ == "__main__":
7877
ffibuilder.compile(verbose=True)
7978

79+
8080
def build_windows():
8181
print("BUILDING FOR WINDOWS")
82-
ffibuilder.cdef(mangle("raylib/raylib.h"))
83-
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', '').replace('bool','int'))
84-
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', '').replace('bool','int'))
82+
ffibuilder.cdef(mangle("raylib/raylib.h").replace('bool', 'int'))
83+
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', '').replace('bool', 'int'))
84+
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', '').replace('bool', 'int'))
8585
ffibuilder.set_source("raylib._raylib_cffi",
8686
"""
8787
#include "raylib.h"
@@ -92,20 +92,31 @@ def build_windows():
9292
#include "physac.h"
9393
""",
9494
extra_link_args=['/NODEFAULTLIB:MSVCRTD'],
95-
libraries=['raylib', 'gdi32', 'shell32', 'user32','OpenGL32', 'winmm'],
95+
libraries=['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm'],
9696
include_dirs=['raylib'],
9797
)
9898
if __name__ == "__main__":
9999
ffibuilder.compile(verbose=True)
100100

101+
101102
def build_mac():
102103
print("BUILDING FOR MAC")
103-
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
104+
ffibuilder.cdef(mangle("/usr/local/include/raylib.h"))
105+
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', ''))
106+
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', ''))
104107
ffibuilder.set_source("raylib._raylib_cffi",
105108
"""
106-
#include "../../raylib/raylib.h" // the C header of the library, supplied by us here
109+
#include "raylib.h"
110+
#define RAYGUI_IMPLEMENTATION
111+
#define RAYGUI_SUPPORT_RICONS
112+
#include "raygui.h"
113+
#define PHYSAC_IMPLEMENTATION
114+
#include "physac.h"
107115
""",
108-
extra_link_args=['/usr/local/lib/libraylib.a', '-framework', 'OpenGL', '-framework', 'Cocoa', '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework', 'CoreVideo'],
116+
extra_link_args=['/usr/local/lib/libraylib.a', '-framework', 'OpenGL', '-framework', 'Cocoa',
117+
'-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework',
118+
'CoreVideo'],
119+
include_dirs=['raylib'],
109120
)
110121

111122
if __name__ == "__main__":
@@ -114,32 +125,38 @@ def build_mac():
114125

115126
def build_rpi_nox():
116127
print("BUILDING FOR RASPBERRY PI")
117-
ffibuilder.cdef(mangle("raylib/raylib.h"))
128+
ffibuilder.cdef(mangle("/usr/local/include/raylib.h"))
129+
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', ''))
130+
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', ''))
118131
ffibuilder.set_source("raylib._raylib_cffi",
119132
"""
120-
#include "../../raylib/raylib.h"
133+
#include "raylib.h"
134+
#define RAYGUI_IMPLEMENTATION
135+
#define RAYGUI_SUPPORT_RICONS
136+
#include "raygui.h"
137+
#define PHYSAC_IMPLEMENTATION
138+
#include "physac.h"
121139
""",
122140
extra_link_args=['/usr/local/lib/libraylib.a',
123141
'/opt/vc/lib/libEGL_static.a', '/opt/vc/lib/libGLESv2_static.a',
124142
'-L/opt/vc/lib', '-lvcos', '-lbcm_host', '-lbrcmEGL', '-lbrcmGLESv2',
125143
'-lm', '-lpthread', '-lrt'],
144+
include_dirs=['raylib'],
126145
)
127146

128-
129147
if __name__ == "__main__":
130148
ffibuilder.compile(verbose=True)
131149

132150

133-
134-
if platform.system()=="Darwin":
151+
if platform.system() == "Darwin":
135152
build_mac()
136-
elif platform.system()=="Linux":
153+
elif platform.system() == "Linux":
137154
if "x86" in platform.machine():
138155
build_linux()
139156
elif "arm" in platform.machine():
140157
build_rpi_nox()
141-
elif platform.system()=="Windows":
158+
elif platform.system() == "Windows":
142159
build_windows()
143160
else:
144161
print("WARNING: UKKNOWN PLATFORM - trying Linux build")
145-
build_linux()
162+
build_linux()

raylib/pyray.py

Lines changed: 0 additions & 118 deletions
This file was deleted.

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import pathlib
22
from setuptools import setup
33
from setuptools.dist import Distribution
4-
from version import __version__
4+
55

66
# The directory containing this file
77
HERE = pathlib.Path(__file__).parent
88

99
# The text of the README file
1010
README = (HERE / "README.md").read_text()
11+
VERSION = (HERE / "version.py").read_text().split()[-1].strip("\"'")
12+
1113

1214
class BinaryDistribution(Distribution):
1315
"""Distribution which always forces a binary package with platform name"""
@@ -17,7 +19,7 @@ def has_ext_modules(foo):
1719
# This call to setup() does all the work
1820
setup(
1921
name="raylib",
20-
version=__version__,
22+
version=VERSION,
2123
description="Python CFFI bindings for Raylib",
2224
long_description=README,
2325
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)