overdev / raylib-py

A Python binding for the great C library raylib.
Other
185 stars 20 forks source link

Fix library search paths not working when used from REPL #2

Closed Pebaz closed 5 years ago

Pebaz commented 5 years ago

Problem statement: Raylib cannot be used from REPL

Solution:

  1. Remove extraneous checks for __file__ and __main__ paths and unify them into one check. This means that if the environment variable RAYLIB_BIN_PATH is set, the user clearly wants to use the library in that location.
  2. Use modern object oriented file system pathlib.Path to simplify code and improve clarity.
  3. Make it so that only one check for __file__ and __main__ is done instead of two.
  4. Log where Raylib-Py found the library as well as the name it searched for.
  5. Provide detailed error message if library was not found.
overdev commented 5 years ago

@Pebaz It looks great! Thanks!

Edit: I borrowed the library loading code from one of the glfw python packages and made some small changes. :sweat_smile:

There's only one small detail: could you please replace the f-strings with str.format(), so it works for py3.5 and earlier?

(Maybe pathlib needs to be added to the dependencies...)

Pebaz commented 5 years ago

I made the suggested change. Thanks for reviewing! Also, pathlib is included in the Python standard library so we should be good there.