RFC set up Codespaces to ease contributor experience especially during sprints?

IMO this could be useful as fall-back during sprints, in particular for pesky company Windows laptops, where I (and others for example @adrinjalali and @glemaitre) have been guilty to debug the Windows situation rather than focussing on more important stuff 😅.

Try it on my fork https://github.com/lesteve/scikit-learn

![Image](https://github.com/user-attachments/assets/d0673441-59f5-4abb-b41b-af267602eb64)

Full disclosure: for some reason, this does not work for me on Firefox, I need to use a Chromium-like browser (Vivaldi works for example), maybe due to my addons not sure.

![Image](https://github.com/user-attachments/assets/6ade7d69-626b-4a90-8a7c-67f22e5f65c9)

The setup seems quite maintable see current diff https://github.com/scikit-learn/scikit-learn/compare/main...lesteve:scikit-learn:main. This could be tweaked for example to setup `ccache` if we insist but I think is good enough as is.

I tried it on my fork on a 2-core machine (default):
- build time from scratch: ~7 minutes
- run full test suite: ~13 minutes (with or without `-n2` has similar timings)
- doc `make html-noplot` (i.e. no example) ~9 minutes first time, ~1 minute second time

Pricing: 120 core hours + 15GB storage free per month. With the default 2-core machine, which is probably enough for sprints. See [doc](https://docs.github.com/en/billing/managing-billing-for-your-products/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#monthly-included-storage-and-core-hours-for-personal-accounts) for more details.

I guess we may want to add light documentation about it somewhere.

- numpy mentions codespaces without much detailed instructions:
  https://numpy.org/doc/2.1/dev/development_environment.html
- scipy does something similar:
  https://docs.scipy.org/doc/scipy/dev/dev_quickstart.html#other-workflows

Previous related conversations:
- devcontainer: https://github.com/scikit-learn/scikit-learn/pull/27743
- gitpod: https://github.com/scikit-learn/scikit-learn/pull/23556

COMMENT:
I agree we can get started with a simple https://github.com/scikit-learn/scikit-learn/pull/31096.

> Not something we need to do now or something that is worth if it adds a lot of complexity. 

Optimizing the devcontainer startup time does add complexity. Github does have [prebuilds](https://docs.github.com/en/codespaces/prebuilding-your-codespaces/configuring-prebuilds), but I can not tell if we can share pre-builds on this repo with forks. If a user can go to the main `scikit-learn/scikit-learn` repo and click on "Open codespaces" and then push to their fork, then maybe they could use our GitHub prebuilds. We should test it out once https://github.com/scikit-learn/scikit-learn/pull/31096 gets merged.

---

If we can not use prebuilds we need to have a public custom base image for the dev container. Here is the optimization strategies: (with increasing complexity)

1. Build a custom base image with our dev dependences. We build the image weekly, because these do not change that frequently.
2. In our custom base image, install `ccache` and compile scikit-learn. This means forks can use this image and have a faster time building scikit-learn. I have tried this before with GitPod with SciPy, and it works.
3. In our custom base image, build the docs to cache the docs build. We likely need to mess with the mtime of files to get sphinx to recognize the cache when using the devcontainer in a fork. (I have not figure out the right way to do this 😅)

Labels: RFC