Replies: 8 comments 17 replies
-
example of Coding Style Conventions for Python API: https://github.com/sDos280/raylib-python-cffi/blob/Conventions/PYTHON_API_CONVENTIONS.md example of Contributing Conventions for Python API: https://github.com/sDos280/raylib-python-cffi/blob/Conventions/CONTRIBUTING.md I tryied to make the CONTRIBUTING.md and the PYTHON_API_CONVENTIONS.md as close to the CONVENTIONS.md and the CONTRIBUTING.md in the main GitHub repository (https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md, https://github.com/raysan5/raylib/blob/master/CONTRIBUTING.md) |
Beta Was this translation helpful? Give feedback.
-
If you want to see the progress I've made so far: https://github.com/sDos280/raylib-python-cffi/tree/Conventions |
Beta Was this translation helpful? Give feedback.
-
ok, I updated the PYTHON_API_ CONVENTIONS.md to be closer to https://peps.python.org/pep-0008/ . probably, next week I will try to publish the C_API_ CONVENTIONS.md file... I need more help to refactor all of the example that use the python API to stand to the PYTHON_API_ CONVENTIONS.md . any help will be expected happily ;). |
Beta Was this translation helpful? Give feedback.
-
Raylib has a code style conventions because there isn't a standard style for C code. (Also, Raylib has 372 contributors. Raylib-Python-CFFI only has 13 contributors ever and not all of them worked on examples.) Python has a standard, PEP 8, so I think we can just point contributors to use that. I agree it would be nice to make all the examples consistent in style but I don't have time to do it. If you want to tidy them up then go ahead. It's very rare for anyone to contribute examples so I'm not going to reject them just for style reasons. Regarding the main function, I don't think this is necessary in Python. The point of examples is to be as short and clear as possible. If Raylib could write examples without a main function I'm sure they would, but they are C so they can't. If contributors submit examples using main I will still add them however. |
Beta Was this translation helpful? Give feedback.
-
Hi all I am attempting to convert the 2 example to raylib-python-cffi at the moment and running into confusion with the binder and the APIs. Q1. When looking at the Docs, examples and tests I get some differences in naming conventions. From what I can tell the C API (raylib) follows the C naming used in raylib/gui.h and the Py API has C naming for Structures, and Py (snake_case) for functions. Is this the case or are there still some ambiguous cases? Q3. Is it required to use raylib(cffi) to enable pyray(cffi) functionality in some cases? aka are there still parts of the pyray API that are not implemented? Q2 Do all C structures from the raylib.h headers have to be constructed with ffi.new( ...) to use pyray(cffi) or just some and how do I tell? Sorry if these seam like silly questions. In other scripting languages I have used the C structures are created in the module headers so I can just use the data type without constructing each one manually. TIA |
Beta Was this translation helpful? Give feedback.
-
Hi all I am attempting to convert the 2 example to raylib-python-cffi at the moment and running into confusion with the binder and the APIs. Q1. When looking at the Docs, examples and tests I get some differences in naming conventions. From what I can tell the C API (raylib) follows the C naming used in raylib/gui.h and the Py API has C naming for Structures, and Py (snake_case) for functions. Is this the case or are there still some ambiguous cases? Q3. Is it required to use raylib(cffi) to enable pyray(cffi) functionality in some cases? aka are there still parts of the pyray API that are not implemented? Q2 Do all C structures from the raylib.h headers have to be constructed with ffi.new( ...) to use pyray(cffi) or just some and how do I tell? Sorry if these seam like silly questions. In other scripting languages I have used the C structures are created in the module headers so I can just use the data type without constructing each one manually. TIA Update: embarrassed Pikachu face |
Beta Was this translation helpful? Give feedback.
-
Continuation of #87 (reply in thread) yeah, that's why one of the most important things I tried to do in my wrapper(it is less of a binding, at least for me) is to automate almost everything I can. for now, that worked really well, and if I don't screw I will probably try to add those things into pyray, but one of the most challenging things that I need to fix is the auto conversion from c types(int, float, double*, etc...) to ctypes types(c_int, c_float, etc...) for now I just have a large dictionary with all the c type string as a key and the corresponding ctypes type as value(with pointer and array as an exemption), but that really hard to maintain it that way... although cffi and ctypes are different modules it seems like the cffi module relies on ctypes types for its internal functionality, I just looked at #53 and It seems like the idea of using p.s. for benchmarking I just used the bunnymark example, I know that this isn't really the way for doing that so I you have any idea for a better benchmark please let me know. |
Beta Was this translation helpful? Give feedback.
-
Hi @electronstudio, I sent a PR for the conventions work I would really like if you could review it |
Beta Was this translation helpful? Give feedback.
-
Ok, As the title of the discussion say, (i think) we need to talk about adding a coding style conventions for the python example.
As you know, everyone can add (convert from c to python) an example with their own coding style but with no order(conventions) things may go out of control and get messy.
my idea is to make "Coding Style Conventions" for pyray like raylib has (https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md). I personally never designed code conventions for any programing language befor, so I may need your help with that. also i though that we will may need to make to separate code conventions for the C API and the python API (because they are a bit different to use... but there may not really be a need for that)
i know that the pyray wants to be as close to the original c library so I thought to add to the conventions the idea of entry point(as a main function). (like in here https://github.com/sDos280/raylib-python-cffi/blob/master/examples/shapes/shapes_lines_bezier.py).
if you think that this idea is good please let me know🙏, i know that this will mean a big refactor to the library so if you think that is over kill i will understand 👍.
p.s. i know that with the code conventions we will need to refactor any examples that don't stands to the conventions. i will happily refactor any example that we will need to refactor.
Beta Was this translation helpful? Give feedback.
All reactions