Skip to content

Env vars for build paths #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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()
    ])

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.

3 participants