GitHub Codespaces prebuilds now available

What’s Brett going on about?

The PSF via the SC have agreed to fund GitHub Codespaces prebuilds for the CPython repository!

“GitHub Codespaces”? “Prebuilds”? What do all of those words mean?

GitHub has a service called Codespaces where they host a Linux VM for you. You can configure them using dev containers. This lets you specify the dev environment that works for your repository (in our case, a Dockerfile and some commands to run). A prebuild is effectively a building of the dev container that GitHub caches for people to use so they don’t have to do all the initial building and such.

Why should I care?

Two reasons. One, because GitHub Codespaces works entirely in the browser thanks to , this is a very easy way to get someone going during sprints. You can go from the repo’s page on GitHub to a running terminal that has the python binary and docs already built in less than a minute (I consistently launch in under 45 seconds). I have also provided some initial settings and extensions for VS Code to make it as easy as possible for someone to get up and sprinting on the code base.

Two, it means everyone has access to a Linux dev environment now. I have also gone ahead and installed the toolchain for WASI in there since that also works under Linux.

Does this mean we have a Dockerfile for CPython development?

Yep! It’s Fedora-based as a thanks to our friends on the Fedora project and to get free technical support. :grin:

Do I have to use with this?

No! While the default experience is “VS Code in the browser”, you can actually use VS Code desktop if you prefer (see the docs). JetBrains IDEs are also supported.

And if you’re a terminal editor person, you can always just launch VS Code and maximize the terminal and ignore everything else. :wink:

How much does Codespaces cost?

Everyone gets 120 CPU-hours free every month (and this is time having the Codespace open and running, not simply processing, since you’re reserving a VM). The available machines start at 2 cores, so that’s 60 hours/month. There are also 4, 8, and 16-core machines if you want such things and use more of your quota.

If you find you are liking Codespaces but are running out of free quota, please reach out to the SC and let us know as we can talk about getting you some funding for more usage.


‘Everyone’ means each github account? Across all repositories?

Getting to $ was maybe 20 seconds. Great. Learning to use that I see other than type a bash? command will take longer ;-).

Unfortunately for me, tkinter, and dependents, do not run.

@terryjreedy ➜ /workspaces/codespaces-blank $ python -m tkinter
Traceback (most recent call last):
  File "/usr/local/python/3.10.4/lib/python3.10/", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/python/3.10.4/lib/python3.10/", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/python/3.10.4/lib/python3.10/tkinter/", line 7, in <module>
  File "/usr/local/python/3.10.4/lib/python3.10/tkinter/", line 4586, in _test
    root = Tk()
  File "/usr/local/python/3.10.4/lib/python3.10/tkinter/", line 2299, in __init__ = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

I am not surprised, but it should be noted that this is not a solution for anyone, including sprinters, working on tkinter-dependent issues.

Yes. You can go to Sign in to GitHub · GitHub and look at the “Codespaces” part to see how much quota you have.

Yes. While we are paying to have the prebuilds, that’s not a prerequisite to use Codespaces with a repository.

If you’re used to PowerShell we could consider installing that as an available shell (we also install zsh and fish by default). You can then configure VS Code with which shell you want to be the default for you (e.g. I have VS Code set to launch fish automatically instead of bash).

Correct, there’s no X server running to then somehow forward the window to the user’s machine. There might be a way to set that up, though, for someone who knows that much about X servers.

Yep, just like how it won’t work for macOS or Windows-specific sprinters either.

Thanks for adding this, I use codespaces extensively and now it will be much faster.

Our CI uses Ubuntu based image and so does the default GitHub Codespaces and I am very much used to ubuntu, did you consider using an ubuntu based image instead?
It would be nice to have same toolchain as used on CI for development.

Couple of things which are missing from image and would be useful to have in the docker image are gh cli and wget which I use frequently to review PRs.

1 Like

I generally uses Debian or Ubuntu. Are these commands not usable in Fedora?
Or is my codespace broken?

[root@codespaces-abcfa4 shared]# ps
bash: ps: command not found
[root@codespaces-abcfa4 shared]# top
bash: top: command not found
[root@codespaces-abcfa4 shared]# vmstat
bash: vmstat: command not found

These tools are not included in the minimal container.
You can install any packaged command with e.g.:

dnf install /usr/bin/ps /usr/bin/top /usr/bin/vmstat

Or use the package/project name if you know it (these three are all from one package, procps-ng):

dnf install procps

If they’re useful to most people, they should be added to the devcontainer.

0:04:02 load avg: 7.24 [ 72/417/1] test_import failed (1 failure) -- running: test_unicodedata (1 min 37 sec), test_capi (4 min 1 sec), test_math (3 min 54 sec)
test test_import failed -- Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_import/", line 606, in test_creation_mode
AssertionError: '0o646' != '0o644'
- 0o646
?     ^
+ 0o644
?     ^

0:05:28 load avg: 7.59 [ 84/417/3] test_os failed (1 failure) -- running: test_source_encoding (47.3 sec), test_math (5 min 19 sec)
test test_os failed -- Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/", line 1662, in test_mode
    self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)
AssertionError: 511 != 509

This is common pitfall of Codespace (devcontainer?).
We need to execute chmod -R o-w . first.

Thank you. I didn’t know dnf install can install package by command path.

1 Like

And I’m not. :wink:


We can totally consider switching CI over to Fedora. :wink:

Please feel free to add a line to the Dockerfile for that.


Fix umask test failures under Codespaces by brettcannon · Pull Request #104913 · python/cpython · GitHub should fix the test_import and test_os failures.