Skip to content

Commit 81819a1

Browse files
separate static and dynamic libraries completely
1 parent d9ae651 commit 81819a1

39 files changed

+1598
-83
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,34 @@ jobs:
187187
with:
188188
name: wheel
189189
path: dist/*
190+
191+
dynamic-distro:
192+
runs-on: ubuntu-18.04
193+
194+
steps:
195+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
196+
- uses: actions/checkout@v2
197+
with:
198+
submodules: recursive
199+
200+
- name: Setup Python
201+
uses: actions/[email protected]
202+
with:
203+
# Version range or exact version of a Python version to use, using SemVer's version range syntax.
204+
python-version: '3.9'
205+
# The target architecture (x86, x64) of the Python interpreter.
206+
architecture: x64
207+
208+
- name: Build raylib-python-cffi-dynamic
209+
run: |
210+
python -m pip install --upgrade pip
211+
pip3 install cffi
212+
pip3 install wheel
213+
cd dynamic
214+
python setup.py sdist
215+
216+
- name: Upload build Artifact wheel
217+
uses: actions/[email protected]
218+
with:
219+
name: wheel
220+
path: dynamic/dist/*

MANIFEST.in

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
include raylib/static/*.so
2-
include raylib/static/*.pyi
3-
include raylib/static/*.pyd
4-
exclude raylib/static/*.a
1+
include raylib/*.so
2+
include raylib/*.pyi
3+
include raylib/*.pyd
4+
exclude raylib/*.a
55
include raylib/*.h
66
include raylib/*.pyi
7-
exclude raylib/static/*.c
8-
exclude raylib/static/*.o
9-
include raylib/dynamic/*.dylib
10-
include raylib/dynamic/*.dll
11-
include raylib/dynamic/*.so
7+
exclude raylib/*.c
8+
exclude raylib/*.o

create_stub_pyray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1414

15-
from raylib.static import rl, ffi
15+
from raylib import rl, ffi
1616

1717
from inspect import ismethod, getmembers, isbuiltin
1818
import inflection, sys, json

create_stub_static.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1414

15-
from raylib.static import rl, ffi
15+
from raylib import rl, ffi
1616

1717
from inspect import ismethod, getmembers, isbuiltin
1818
import inflection, sys, json

docs-src/dynamic.rst

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
11
raylib.dynamic
22
==============
33

4-
CFFI ABI dynamic bindings exist in order to avoid the need to compile a C extension module.
4+
CFFI ABI dynamic bindings avoid the need to compile a C extension module. They now been moved to a separate module::
55

6-
See https://github.com/electronstudio/raylib-python-cffi/blob/master/test_static.py for how to use.
6+
python3 -m pip install raylib_dll
77

8-
Currently the github version may include bundled DLLs in ``raylib/dynamic`` but the pypi version requires a system installed Raylib.
9-
You can put your own DLLs in ``raylib/dynamic`` if you prefer.
8+
.. warning::
109

11-
If your system already has the Raylib library installed, you can set the environment variable ``USE_EXTERNAL_RAYLIB`` and it will
12-
always be used instead of the bundled DLLs.
10+
There have been some weird failures with dynamic bindings and ctypes bindings before and often the
11+
failures are silent
12+
so you dont even know. Also the static bindings are faster. Therefore I personally recommend the static ones.
13+
But the dynamic bindings have the advantage that you don't need to compile anything to install. You just need a Raylib DLL.
1314

14-
If you want to build your own wheel with just raylib.dynamic and not even attempt to compile the static libraries,
15-
the command is::
15+
API is exactly the same as the static one documented here. (Therefore you can't have both modules installed at once.) The only difference is you can't do::
1616

17-
python3 setup_dynamic.py bdist_wheel
17+
from raylib import *
1818

19+
Instead you have to do::
1920

21+
from raylib import raylib as rl
2022

21-
.. warning::
23+
Then you access the functions with ``rl.`` prefix. See
2224

23-
There have been some weird failures with dynamic bindings and ctypes bindings before and often the
24-
failures are silent
25-
so you dont even know. Also the static bindings should be faster. Therefore I personally recommend the static ones.
26-
But the dynamic bindings have the big advantage that you don't need to compile anything to install. You just need a Raylib DLL.
25+
See https://github.com/electronstudio/raylib-python-cffi/blob/master/dynamic/test_dynamic.py for an example.
26+
27+
28+
29+
.. important::
30+
31+
If your system already has the Raylib library installed, you can set the environment variable ``USE_EXTERNAL_RAYLIB`` and it will
32+
always be used instead of the bundled DLLs.
33+
34+
35+
36+
.. note::
37+
38+
If you write a program using the ``rl.`` prefix on all the functions and then you decide you want to use
39+
that same program with the static binding instead of the dynamic, you don't have to remove the ``rl``,
40+
you can just do::
2741

28-
API is the same as raylib.static.
42+
import raylib as rl

dynamic/MANIFEST.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
include raylib/*.pyi
2+
include raylib/*.pyd
3+
exclude raylib/*.a
4+
include raylib/*.h
5+
include raylib/*.pyi
6+
exclude raylib/*.c
7+
exclude raylib/*.o
8+
include raylib/*.dylib
9+
include raylib/*.dll
10+
include raylib/*.so
11+
include raylib/32bit/*.dylib
12+
include raylib/32bit/*.dll
13+
include raylib/32bit/*.so

dynamic/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dynamically linked version of Raylib Python CFFI
File renamed without changes.

raylib/dynamic/__init__.py renamed to dynamic/raylib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
import pathlib
2424
import platform
2525

26-
MODULE = pathlib.Path(__file__).parent.parent
26+
MODULE = pathlib.Path(__file__).parent
2727

2828
def raylib_library_path():
2929
'''Return the full path of the raylib shared library
3030
If the environment variable "USE_EXTERNAL_RAYLIB" is set (no value required)
3131
then the library will be loaded from the system library paths.
3232
'''
3333
def so_path():
34-
return str(MODULE / 'dynamic') if not 'USE_EXTERNAL_RAYLIB' in os.environ else ''
34+
return str(MODULE) if not 'USE_EXTERNAL_RAYLIB' in os.environ else ''
3535
def so_name():
3636
'''Returns the appropriate for the library on the current platform.'''
3737
lib_filenames = {

dynamic/raylib/colors.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 )

0 commit comments

Comments
 (0)