open_spiel icon indicating copy to clipboard operation
open_spiel copied to clipboard

Add `uv` building system and add `gpu` support/Makefile

Open alexunderch opened this issue 4 months ago • 10 comments

Whom it may concern,

Do you think that:

  1. adding uv in addition to pip to support the integration with the modern dependency systems
  2. with addition of jax versions and for the sake of build simplification, would it be useful to add a Makefile for different builds and update the dockerfile with the gpu requirements

Thank you!

alexunderch avatar Aug 24 '25 17:08 alexunderch

Thanks for raising this! I think both points make sense, especially:

  • Using uv alongside pip could simplify reproducibility and align with modern dependency practices.

  • A Makefile would be really helpful for standardizing builds across environments (CPU vs GPU), and it could also serve as an entry point for CI/CD pipelines.

I’d be happy to help draft the initial Makefile with targets for:

  • CPU build

  • GPU build with JAX

  • Docker image update for GPU dependencies

Would you be open to me taking a first pass at this and submitting a PR?

YashSachdeva avatar Aug 26 '25 05:08 YashSachdeva

Hi @YashSachdeva. In spite of me fully sharing your intentions, I would still wait for any opinion of the maintainers first.

alexunderch avatar Aug 26 '25 06:08 alexunderch

Hi guys,

Thanks @alexunderch . I don't know about uv and it's the first I'm hearing about it.

I've had numerous requests like this in the past. The problem is that I barely have any time to support OpenSpiel in its current form. When something major like this is added, and then it falls on me to support it, long-term that's an issue because I am not familiar with it and it would cost time I don't have to learn it.

Would there be a way to add this and mark it as optionally supported? Or maybe one of you could offer to support it if something breaks? E.g. would it necessitate any changes to the current pip system? Keep in mind that we also need to keep everything working internally for our project use cases.

Curious to see how this could be put into place but still not affecting my usual pip support workflow. Can you give an outline as to what would be added and where?

Let me know what you think,

lanctot avatar Aug 27 '25 02:08 lanctot

BTW when you say 'Makefile' do you really mean the same GNU Make Makefile? I find that a bit odd for python-based projects given that they're all dynamically run....? (I'm likely out of the loop!)

lanctot avatar Aug 27 '25 02:08 lanctot

Most importantly, I'd like the following question answered: would we be adding this because it's cool and hip, or is there currently something that can't be done without it? (E.g. JAX port of AlphaZero).

I'm afraid I can't entertain supporting this just because they are nice and cool (unless someone other than me helps support it long-term ... :-p ) and it doesn't interfere. We had that kind of this with a Dockerfile, for instance. It was nice to offer that but we didn't use it ourselves, so we marked it as not supported and could break at any time.

lanctot avatar Aug 27 '25 03:08 lanctot

Yes, sure, I'll shortly try to be sure if it's possible to keep both, pip and uv, simultaneously supportable. Reason, why I asked in the fact that uv is being used in many projects and, secondly, it has a different dependency resolution system which may allow to flexibly include/configure it with to other projects.

For Makefiles, yes, but I had in mind like hardware dependent docker runs or testing (rerun only make install/test other than a long bash install/build other than python scripts).

I absolutely understand your concerns about long-term support, will address them. Sure, a lot of things could be done without that and so are they being. Somebody would've asked it in some time, me or not me.

alexunderch avatar Aug 27 '25 06:08 alexunderch

Thanks.

If e.g. uv is so popular that it's a candidate to replace pip, then that would change my stance, of course.

So, simultaneously, I will look into it.

lanctot avatar Aug 27 '25 09:08 lanctot

In case helpful, note that whether or not you use uv in open-spiel does not affect your users' ability to use uv themselves. So if you make changes here it should be because different tooling makes your life easier (or other contributors / maintainers of open-spiel's lives)

hauntsaninja avatar Aug 31 '25 07:08 hauntsaninja

really, looks like a smth transient and easy to support: https://docs.astral.sh/uv/guides/migration/pip-to-project

@hauntsaninja, does uv work nicely with external build systems, like cmake? or it is only for the python part?

If I drew an draft configuration, would you look into it?

alexunderch avatar Sep 01 '25 20:09 alexunderch

It's sort of in between. You should be able to use uv as a project manager with extension modules, but you can't yet use the uv build backend (uv_build ) for extension modules — you'll have to stick with setuptools (or scikit-build-core which has a nice cmake integration)

Yeah I'd take a look (but no promises / I haven't dev-ed on open-spiel myself)!

hauntsaninja avatar Sep 01 '25 20:09 hauntsaninja