Skip to content

Conversation

@electronstudio
Copy link
Owner

@electronstudio electronstudio commented May 5, 2025

Environment variables you can set before build

RAYLIB_PLATFORM: Any one of: Desktop, SDL, DRM, PLATFORM_COMMA

RAYLIB_LINK_ARGS: Arguments to pass to the linker rather than getting them from pkg-config.
e.g.: -L/usr/local/lib -lraylib

RAYLIB_INCLUDE_PATH: Directory to find raylib.h rather than getting from pkg-config.
e.g.: /usr/local/include

RAYGUI_INCLUDE_PATH: Directory to find raygui.h
e.g.: /usr/local/include

GLFW_INCLUDE_PATH: Directory to find glfw3.h
e.g.: /usr/local/include/GLFW

PHYSAC_INCLUDE_PATH: Directory to find physac.h
e.g.: /usr/local/include

LIBFFI_INCLUDE_PATH:
e.g.: /usr/local/include

@electronstudio
Copy link
Owner Author

NixOS: @Sigmanificient @WeetHet @natsukium @3demax

CommaAI: @maxime-desroches @incognitojam

Instead of patching build.py you should now be able to set these variables before running it, then pkg-config won't be used at all. (Unless you want to use pkg-config, in which you can call it yourself, and put the output into these vars.)

@WeetHet
Copy link

WeetHet commented May 5, 2025

I don't see any issue In using pkg-config. If you would like to help us in building this library in nixpkgs you are better off applying our patch here, in upstream since it should not break other builds anyways and is overall more correct

@electronstudio
Copy link
Owner Author

Repeating what I already said in the issue #169

Your patch breaks the build on non NixOS systems because they don't have separate packages for raygui, glfw and physac. So would need to have fallback if packages don't exist.

I think probably NixOS is doing this wrong by allowing raylib-python-cffi to build against the system packages for raygui, glfw and physac. I designed the build so it was possible to use different versions by installing them at system level but this isn't something that majority of users will ever want to do. For the official binary builds we just take the bundled versions and copy them to /usr/local so the build finds them. So I think probably NixOS should be using our bundled versions.

@electronstudio
Copy link
Owner Author

And what I said on the Physac PR:

Issue seems to be Nixos has broken it up into separate packages for Raylib-Python-CFFi, Raylib, Raygui and GLFW. Which is fine, it still builds a valid Raylib-Python-CFFI. But it doesn’t build Raylib-Python-CFFI 5.5.0.2 unless all those package versions match ours, and they don’t. So either NixOS needs to specify specific versions of those dependencies, or else not claim the resultant package is 5.5.0.2.

@WeetHet
Copy link

WeetHet commented May 6, 2025

Your patch breaks the build on non NixOS systems because they don't have separate packages for raygui, glfw and physac.

Considering this, I think it would be fine to just leave the patch in place as is. Nixpkgs does patching like that all the time.

I think probably NixOS is doing this wrong by allowing raylib-python-cffi to build against the system packages for raygui, glfw and physac

We are doing the same thing as we do with a lot of other packages by devendoring system libraries. In this case we are lucky that the build process was already well designed for us enough that only such a small patch was required to do so

So either NixOS needs to specify specific versions of those dependencies, or else not claim the resultant package is 5.5.0.2

What would you prefer we put as the resulting package version? I'm ready to make a PR for that if you think claiming 5.5.0.2 is incorrect

@Sigmanificient
Copy link

Sigmanificient commented May 6, 2025

Couldn't we extend https://github.com/3demax/raylib-python-cffi/pull/1/files by having module_name resolution in env variable to not break on other system? Sorry, I arrived a bit late to the discussion 😅

def get_the_include_path(libname):
    return subprocess.run([
        'pkg-config',
        '--variable=includedir',
        os.environ.get("PKG_CONFIG_LIB_" + libname, 'raylib'),
        text=True,
        stdout=subprocess.PIPE).stdout.strip()
    ])

@electronstudio electronstudio force-pushed the env-vars-for-build-paths branch from c1e3fa2 to 79fb570 Compare August 27, 2025 13:27
@electronstudio electronstudio force-pushed the env-vars-for-build-paths branch from 1379a37 to e62325a Compare August 27, 2025 16:30
@electronstudio
Copy link
Owner Author

@Sigmanificient yes that solves my objection :-)

I do have another objection: The whole point of using 'pkg-config' was that it would do the work for us, so we didn't have to write much code, and yet it would just work on every system. Now it's getting rather complicated and it makes me wonder if we should even be using pkg-config at all.

Nevertheless if the users request it, I'll make the change...

So for Nix you should now set:

PKG_CONFIG_LIB_raygui=raygui
PKG_CONFIG_LIB_physac=physac
PKG_CONFIG_LIB_glfw3=glfw3
PKG_CONFIG_LIB_libffi=libffi

@electronstudio electronstudio merged commit 34171b1 into master Aug 27, 2025
91 of 116 checks passed
@Sigmanificient
Copy link

For Qtile, we resolved all dependency with --config-settings flags, and headers via env variables: https://github.com/qtile/qtile/blob/master/nix/build-config.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants