-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(devcontainer): add Python 3.10 support for dependency installation #9274
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
base: main
Are you sure you want to change the base?
fix(devcontainer): add Python 3.10 support for dependency installation #9274
Conversation
…lchain - Add python3.10-dev for development headers - Add python3-pip to ensure pip is available - Set up alternatives for both python3 and python commands - Ensures robust development environment for all contributors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @keyboardAnt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request resolves a critical issue in the development container setup that prevented new contributors from installing project dependencies. The previous setup used Python 3.9, which conflicted with the project's pyproject.toml
requiring Python 3.10 or newer. This change updates the .devcontainer/Dockerfile
to install Python 3.10 and configure it as the default interpreter, thereby ensuring a robust and compatible development environment for all contributors.
Highlights
- Python 3.10 Installation: Added commands to the
.devcontainer/Dockerfile
to install Python 3.10. - Deadsnakes PPA Integration: Utilized the deadsnakes PPA to reliably source recent Python versions.
- Default Python Version Configuration: Configured
update-alternatives
to set Python 3.10 as the default interpreter for bothpython
andpython3
commands. - Development Packages Inclusion: Included essential development packages like
python3.10-dev
andpython3-pip
for a complete Python toolchain.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a critical issue in the dev container setup by installing Python 3.10 to match the project's requirements. The approach of using the deadsnakes PPA is appropriate. I've added one suggestion to further optimize the Dockerfile layer by incorporating best practices for package installation and cleanup, which will result in a smaller and more efficient image. Overall, this is a valuable fix that improves the contributor experience.
.devcontainer/Dockerfile
Outdated
RUN apt-get update && \ | ||
apt-get install -y software-properties-common && \ | ||
add-apt-repository -y ppa:deadsnakes/ppa && \ | ||
apt-get update && \ | ||
apt-get install -y python3.10 python3.10-venv python3.10-dev python3-pip && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \ | ||
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 && \ | ||
rm -rf /var/lib/apt/lists/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This RUN
instruction can be optimized for a smaller Docker image size by following a few best practices:
- Avoid unnecessary packages: Use the
--no-install-recommends
flag withapt-get install
to prevent the installation of optional recommended packages, which can significantly reduce the image size. - Thorough cleanup: Add
apt-get clean
beforerm -rf /var/lib/apt/lists/*
to remove downloaded package files from/var/cache/apt/archives
.
These changes will help create a more efficient and leaner development environment, and also align with practices in other Dockerfiles in this repository.
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends python3.10 python3.10-venv python3.10-dev python3-pip && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
The add-apt-repository command is a Python script that requires the apt_pkg module, which is provided by python3-apt. Without this package, the Docker build fails with 'ModuleNotFoundError: No module named apt_pkg'. This fix ensures the deadsnakes PPA can be added successfully to install Python 3.10 in the development container.
The current dev container setup prevents new contributors from installing dependencies due to a Python version mismatch. The base Docker image (
lmsysorg/sglang:dev
) only provides Python 3.9, while the project'spyproject.toml
explicitly requirespython>=3.10
.This incompatibility causes modern package managers like
uv
andpip
to fail during dependency installation, effectively blocking developers from setting up a working development environment using the provided dev container.Modifications
.devcontainer/Dockerfile
update-alternatives
to set Python 3.10 as the default interpreterpython3.10-dev
,python3-pip
) for complete toolchain supportpython3
andpython
commands to ensure compatibilityThis ensures the development environment meets the project's explicit Python version requirements and provides a robust setup for all contributors.
Accuracy Tests
Not applicable - this change only affects the development environment setup and does not impact model outputs.
Benchmarking and Profiling
Not applicable - this change only affects the development environment setup and does not impact inference performance.
Checklist
Note: The checked items above are marked as complete because: