pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
770 stars 120 forks source link

Nix Flake Support #2967

Open Lumesque opened 2 days ago

Lumesque commented 2 days ago

Description

I created an overlay for pygame-ce for support on Nix for putting it into python projects either on nixos or on the default systems nix supports in its package manager, wanted to see what you guys thought/wanted out of it that isn't set up, and if any documentation is missing that would make it less confusing (and make sure it's okay for me to keep it up anyway)

Currently allows for using in a flake, or calling directly in nix shell 'github:Lumesque/pygame-ce-overlay'

oddbookworm commented 2 days ago

I definitely appreciate the effort that went into this after my recent foray into compiling pygame-ce on nix myself recently. @Starbuck5 @robertpfeiffer @ankith26 thoughts?

oddbookworm commented 2 days ago

I'll try to take a good look at it in the next couple of days, I've got a long weekend coming up, so I should have the time

ankith26 commented 2 days ago

Nice work! As such, I don't think any of the active pygame-ce developers are regular Nix users, so we probably won't be able to test it out to confirm if it works. Though I would like to point out one thing, going over the code. We are gradually moving away from the old setup.py based config to a newer meson-python based buildconfig. The old buildconfig is still in the source tree, and I can see that you are making use of it, but if possible I would recommend using the new one.

Lumesque commented 1 day ago

Ty!

We are gradually moving away from the old setup.py based config to a newer meson-python based buildconfig.

Is there anywhere that I can find an example of how its run?

ankith26 commented 1 day ago

For building wheels, you can invoke the one of the standard wheel tools: pypa/wheel or pypa/build

oddbookworm commented 1 day ago

Just got around to exploring this with a brand new NixOS install. Here's the point I'm at image

oddbookworm commented 1 day ago

It's a VM, so I expected some weird fails (like the time module), but I got some fails that seem unrelated to that image image image image Maybe this one is still related to it being a VM, so running slow? image I also had a bunch of fails due to tests being unable to write to the file system, which I suppose is a nix issue that I just don't know how to fix

oddbookworm commented 1 day ago

Here's the nix.shell that I used image

oddbookworm commented 1 day ago

I was able to play the aliens example though, and everything seemed to be working fine (pretty low fps for that example and I had some really intermittent audio, but I blame the VM)

oddbookworm commented 1 day ago

Now that I look further, did I even do it correctly? Your overlay restricts to python 3.12 right? @Lumesque

Lumesque commented 23 hours ago

Now that I look further, did I even do it correctly? Your overlay restricts to python 3.12 right? @Lumesque

Yeah I currently only have it set to be able to run in Python 3.12, ideally if you run 'nix flake init -t "github:Lumesque/pygame-ce-overlay#init"' and then run 'nix develop' you'd enter the correct corresponding shell

That being said, if you download it manually not using the overlay it probably still puts it in your path and therefore Python can still find it is my guess

oddbookworm commented 19 hours ago

image Yep, that's looking better

oddbookworm commented 19 hours ago

I'm gonna have to install this directly instead of a VM lol. The test suite keeps segfaulting the VM and I have no idea why

Lumesque commented 17 hours ago

Lmao weird that it segfaults the whole vm, I can probably test it on my end my laptop has NixOs installed if you give me what you want me to run

oddbookworm commented 17 hours ago

python -m pygame.tests lol

Lumesque commented 16 hours ago

errors I get these errors when I run python -m pygame.tests on it, don't fully know what they mean/why they'd happen

oddbookworm commented 16 hours ago

That means that a test or two didn't run/complete (probably segfault) I suspect it was pygame.transforms tests

Mind running python -m pygame.tests transform and see what happens?

Lumesque commented 15 hours ago

errors_again Ran that one and that one seems to pass, the window one fails tho, wonder if it's just something with my laptop display 'cause its intel integrated graphics not a full on gpu maybe?

oddbookworm commented 15 hours ago

Hmmmmm, that particular error is interesting because it's ensuring that the window borrowed from pygame.display doesn't have opengl support when it wasn't originally created with opengl support Interesting that it fails

Lumesque commented 15 hours ago

Prob. will mess with it in pdb later, sounds kinda wild

oddbookworm commented 15 hours ago

I don't know that pdb is enough lol. That's all done in C. I guess I'll have to install on bare metal and run some debug builds

Lumesque commented 15 hours ago

lmao unlucky, I wonder if we're at the point where it might also just be how my nixos configuration is set up, I don't definitively define opengl anywhere in there for when it builds the os

oddbookworm commented 15 hours ago

That's why I'm focusing on testing. I suspect it's a nix-specific problem, but I don't know enough to guarantee that right now. Maybe @robertpfeiffer would have more direct knowledge?

ankith26 commented 1 minute ago

BTW, we have a discord server, so if you would prefer that mode of communication, you can join the server and continue this topic there :)