Skip to content
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

GH-102973: add a dev container #102975

Merged
merged 26 commits into from
Mar 29, 2023
Merged

Conversation

brettcannon
Copy link
Member

@brettcannon brettcannon commented Mar 23, 2023

Defines a Dockerfile based on Fedora along with common tooling (e.g. various shells people may want to use). It also includes the tooling necessary to do a cross-build for WASI.

Co-authored-by: Dusty Phillips dusty@phillips.codes

@encukou
Copy link
Member

encukou commented Mar 24, 2023

@frenzymadness, do you want to take a look?

(I wont't get to it this week)

@frenzymadness
Copy link
Contributor

Thanks @encukou for the ping. I like it. You might want to use --setopt=tsflags=nodocs for the dnf command to skip documentation packages (--no-docs should work as well) and then you might want to do dnf -y clean all to remove cached files from the resulting image.

@brettcannon
Copy link
Member Author

Thanks @frenzymadness ! PTAL and let me know if I got everything you were suggesting.

@frenzymadness
Copy link
Contributor

Thanks @frenzymadness ! PTAL and let me know if I got everything you were suggesting.

Looks perfect to me now.

@encukou
Copy link
Member

encukou commented Mar 28, 2023

I'm not familiar with devcontainers, let me throw ideas around for consideration.

I don't understand the onCreateCommand. Is in any different from the Dockerfile install section? Installing everything at once could save some repo syncing.

You might want to install ccache to speed up builds, especially after switching branches. The default cache size (5G, AFAIK) might be too much.

You might want to install python3-blurb from RPM, if avoiding yet another tool (pipx) sounds interesting.

There's also a python3-sphinx RPM. With it you could make --directory Doc html without venv to save time. If you want to add it, install with dnf --setopt=install_weak_deps=False to skip dependencies related to image manipulation.

@brettcannon
Copy link
Member Author

I don't understand the onCreateCommand. Is in any different from the Dockerfile install section? Installing everything at once could save some repo syncing.

It is, but I view the dev container details as specific to editing via GitHub Codespaces while with the Dockerfile I tried to take a less opinionated approach.

You might want to install ccache to speed up builds, especially after switching branches. The default cache size (5G, AFAIK) might be too much.

👍

You might want to install python3-blurb from RPM, if avoiding yet another tool (pipx) sounds interesting.

I'm up for it!

There's also a python3-sphinx RPM. With it you could make --directory Doc html without venv to save time.

With GitHub Codespaces prebuilds the save is minimal since the assumption is everyone will start from the container already created and all of those commands already run (takes less then 45 seconds to get to a terminal prompt). But I'm up for trying it out!

@brettcannon
Copy link
Member Author

Turns out python3-sphinx is the wrong Sphinx version and skips installing the theme and other things required to build the docs, so I don't think it's going to improve anything.

@brettcannon
Copy link
Member Author

brettcannon commented Mar 28, 2023

I decided to not go with ccache to start since it could lead to actual costs for people who might not be aware that ccache is running and upping the amount of storage their Codespace is using while not being required to simply build Python effectively (granted, people get 15GB free every month and USD $0.07/GB after that, but still).

@brettcannon brettcannon merged commit 0b1d9c4 into python:main Mar 29, 2023
@brettcannon brettcannon deleted the dev-container branch March 29, 2023 20:28
@brettcannon
Copy link
Member Author

I decided to go ahead and merge this as we can easily update it if there's anything we want to tweak.

@methane
Copy link
Member

methane commented Mar 30, 2023

It takes 20min to start Codespace.
Could you enable prebuild in this repository?

@brettcannon
Copy link
Member Author

It takes 20min to start Codespace. Could you enable prebuild in this repository?

Already working on it; have to get budget from the PSF first.

@encukou
Copy link
Member

encukou commented Mar 31, 2023

In case you want to revisit ccache (e.g. if juggling branches is a common use case), the cache size can be set with echo 'max_size = 100M' > /etc/ccache.conf

  • I'm assuming the devcontainer script controls system-wide setup (/etc/): user-specific config should go to $HOME/.config/ccache/ccache.conf & Fedora defaults are compiled in
  • A full build takes up ~27M of cache, two very different branches (3.12 and 3.6) fill ~40M.

Turns out python3-sphinx is the wrong Sphinx version and skips installing the theme and other things required to build the docs, so I don't think it's going to improve anything.

Fair. I use it (one less venv → one less update command to forget to run, and with docs previews a slightly outdated version doesn't matter that much), but, it's not for everyone.
But in case it's useful: to install the theme, linkchecker, and other things, there's dnf builddep python3-docs

@brettcannon
Copy link
Member Author

In case you want to revisit ccache (e.g. if juggling branches is a common use case), the cache size can be set with echo 'max_size = 100M' > /etc/ccache.conf

Yep, I believe you can also use ccache --max-size, but since that decision could cost people money, I didn't want to make that decision for them.

(one less venv → one less update command to forget to run, and with docs previews a slightly outdated version doesn't matter that much

True, although once we get prebuilds up and running that will be automatic after every commit to main.

@brettcannon
Copy link
Member Author

ENV WASMTIME_VERSION=7.0.0
ENV WASMTIME_CPU_ARCH=x86_64

RUN dnf -y --nodocs install git clang xz python3-blurb dnf-plugins-core && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I am late to the party, but you might save space by installing git-core instead of git, which should avoid Perl (unless something else brings it in).
(dnf builddep python3 will bring in git-core as well, because we use git to apply patches, but that is probably not explicit enough.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoking dnf with --setopt=install_weak_deps=False will also save space. Let me try sending a PR and see if it works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
On content update, builds `python` and the docs. Also adds a Dockerfile that should include everything but autoconf 2.69 that's necessary to build CPython and the entire stdlib on Fedora.

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Dusty Phillips <dusty@phillips.codes>
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.

7 participants