-
Notifications
You must be signed in to change notification settings - Fork 126
update python in docker files #1097
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
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe Dockerfile was updated to use Python 3.11 instead of the default Python 3. This involved adding the deadsnakes PPA, installing prerequisites, updating package references to python3.11 variants across both GPU and non-GPU build targets, and setting python3 to point to Python 3.11 via update-alternatives. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| RUN apt-get update -y && \ | ||
| apt-get install -y software-properties-common ca-certificates gnupg && \ | ||
| add-apt-repository ppa:deadsnakes/ppa && \ | ||
| apt-get update -y && \ | ||
| if [ "$TARGET" != "gpu" ]; then \ | ||
| apt-get install -y \ | ||
| build-essential git make cmake gcc g++ gfortran bc\ | ||
| python3 python3-venv python3-pip \ | ||
| build-essential git make cmake gcc g++ gfortran bc \ | ||
| python3.11 python3.11-venv python3.11-distutils \ | ||
| openmpi-bin libopenmpi-dev libfftw3-dev \ | ||
| mpich libmpich-dev; \ | ||
| else \ | ||
| apt-get install -y \ | ||
| build-essential git make cmake bc\ | ||
| python3 python3-venv python3-pip \ | ||
| build-essential git make cmake bc \ | ||
| python3.11 python3.11-venv python3.11-distutils \ | ||
| libfftw3-dev \ | ||
| openmpi-bin libopenmpi-dev; \ | ||
| fi && \ | ||
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ | ||
| rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
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.
Suggestion: Remove the deadsnakes PPA and software-properties-common after use to reduce the final image size and potential security vulnerabilities. [general, importance: 6]
| RUN apt-get update -y && \ | |
| apt-get install -y software-properties-common ca-certificates gnupg && \ | |
| add-apt-repository ppa:deadsnakes/ppa && \ | |
| apt-get update -y && \ | |
| if [ "$TARGET" != "gpu" ]; then \ | |
| apt-get install -y \ | |
| build-essential git make cmake gcc g++ gfortran bc\ | |
| python3 python3-venv python3-pip \ | |
| build-essential git make cmake gcc g++ gfortran bc \ | |
| python3.11 python3.11-venv python3.11-distutils \ | |
| openmpi-bin libopenmpi-dev libfftw3-dev \ | |
| mpich libmpich-dev; \ | |
| else \ | |
| apt-get install -y \ | |
| build-essential git make cmake bc\ | |
| python3 python3-venv python3-pip \ | |
| build-essential git make cmake bc \ | |
| python3.11 python3.11-venv python3.11-distutils \ | |
| libfftw3-dev \ | |
| openmpi-bin libopenmpi-dev; \ | |
| fi && \ | |
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ | |
| rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
| RUN apt-get update -y && \ | |
| apt-get install -y software-properties-common ca-certificates gnupg && \ | |
| add-apt-repository ppa:deadsnakes/ppa && \ | |
| apt-get update -y && \ | |
| if [ "$TARGET" != "gpu" ]; then \ | |
| apt-get install -y \ | |
| build-essential git make cmake gcc g++ gfortran bc \ | |
| python3.11 python3.11-venv python3.11-distutils \ | |
| openmpi-bin libopenmpi-dev libfftw3-dev \ | |
| mpich libmpich-dev; \ | |
| else \ | |
| apt-get install -y \ | |
| build-essential git make cmake bc \ | |
| python3.11 python3.11-venv python3.11-distutils \ | |
| libfftw3-dev \ | |
| openmpi-bin libopenmpi-dev; \ | |
| fi && \ | |
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ | |
| add-apt-repository --remove ppa:deadsnakes/ppa && \ | |
| apt-get purge -y --auto-remove software-properties-common && \ | |
| rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
|
|
||
| RUN apt-get update -y && \ | ||
| apt-get install -y software-properties-common ca-certificates gnupg && \ | ||
| add-apt-repository ppa:deadsnakes/ppa && \ |
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.
Suggestion: Add the -y flag to the add-apt-repository command to prevent it from blocking during non-interactive builds. [possible issue, importance: 7]
| add-apt-repository ppa:deadsnakes/ppa && \ | |
| add-apt-repository -y ppa:deadsnakes/ppa && \ |
.github/Dockerfile
Outdated
| build-essential git make cmake gcc g++ gfortran bc\ | ||
| python3 python3-venv python3-pip \ | ||
| build-essential git make cmake gcc g++ gfortran bc \ | ||
| python3.11 python3.11-venv python3.11-distutils \ |
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.
✅ Suggestion: Add the python3.11-pip package to the apt-get install command to ensure pip is available for Python 3.11. [general, importance: 9]
| python3.11 python3.11-venv python3.11-distutils \ | |
| python3.11 python3.11-venv python3.11-distutils python3.11-pip \ |
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.
No issues found across 1 file
Nitpicks 🔍
|
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.
Pull request overview
This PR updates the Python version in the Docker build configuration from the system default Python 3 to Python 3.11. The change aligns with MFC's minimum Python version requirement of 3.11 specified in toolchain/bootstrap/python.sh.
Key Changes
- Adds the deadsnakes PPA repository to access Python 3.11 packages on Ubuntu
- Replaces generic
python3packages with version-specificpython3.11packages - Configures Python 3.11 as the default
python3binary usingupdate-alternatives
.github/Dockerfile
Outdated
| build-essential git make cmake gcc g++ gfortran bc\ | ||
| python3 python3-venv python3-pip \ | ||
| build-essential git make cmake gcc g++ gfortran bc \ | ||
| python3.11 python3.11-venv python3.11-distutils \ |
Copilot
AI
Dec 19, 2025
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.
The package python3.11-distutils does not exist in the deadsnakes PPA. The distutils module was deprecated in Python 3.10 and removed in Python 3.12. For Python 3.11, you should either:
- Add
python3-pipback to install pip directly, or - Remove this package and rely on
ensurepip(already available in Python 3.11's standard library)
Since the bootstrap script at toolchain/bootstrap/python.sh already handles pip installation via ensurepip when pip is not available, the recommended approach is to remove python3.11-distutils and add python3-pip for explicit pip installation, or simply rely on the bootstrap script's ensurepip fallback.
| libfftw3-dev \ | ||
| openmpi-bin libopenmpi-dev; \ | ||
| fi && \ | ||
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ |
Copilot
AI
Dec 19, 2025
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.
The priority value in update-alternatives is set to 2, which is unusually low. Standard practice is to use higher priority values (e.g., 100 or higher) to ensure the intended version takes precedence. While this may work in a container environment where only Python 3.11 is installed, consider using a more conventional priority value like 100 to follow best practices and avoid potential conflicts.
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 && \ | |
| update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 && \ |
| apt-get install -y software-properties-common ca-certificates gnupg && \ | ||
| add-apt-repository ppa:deadsnakes/ppa && \ | ||
| apt-get update -y && \ |
Copilot
AI
Dec 19, 2025
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 Dockerfile adds the third-party ppa:deadsnakes/ppa repository and installs packages from it during the build, creating a supply chain risk: if that PPA or its signing key is compromised, attackers could ship malicious Python binaries that run with root privileges in CI and access build secrets or modify artifacts. Prefer using only official distro/python images or vendor repositories, or at minimum pin packages to trusted sources and specific versions with integrity verification to limit this attack surface.
|
CodeAnt AI finished reviewing your PR. |
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.
Actionable comments posted: 1
♻️ Duplicate comments (3)
.github/Dockerfile (3)
11-14: Multiple best practices and risk concerns already flagged.Previous reviewers have identified several issues in this section:
- Missing
-yflag onadd-apt-repository(line 13) can cause interactive prompts during build- Missing
DEBIAN_FRONTEND=noninteractiveand--no-install-recommendsflags increase image size- Supply chain risk from third-party deadsnakes PPA
- PPA not removed after installation
Please address the existing review comments on these lines.
23-24: Same pip verification applies here.The GPU target uses the same
python3-pipapproach. See the verification comment on lines 17-18 regarding potential compatibility with Python 3.11.
28-28: Low priority value already flagged.A previous reviewer noted that the priority value of
2is unconventionally low and recommended using100or higher to follow best practices.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/Dockerfile(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & Publish
| build-essential git make cmake gcc g++ gfortran bc \ | ||
| python3.11 python3.11-venv python3-pip \ |
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.
🧩 Analysis chain
🏁 Script executed:
cd .github && cat -n Dockerfile | head -40Repository: MFlowCode/MFC
Length of output: 1503
Replace python3-pip with python3.11-full to ensure pip compatibility with Python 3.11.
The generic python3-pip package is built for the base image's default Python version (3.10 on Ubuntu 22.04), not for Python 3.11. Using it as the default Python after update-alternatives can cause compatibility issues. Instead, use python3.11-full which includes the pip package manager for Python 3.11, or run python3.11 -m ensurepip after installation. This ensures pip is properly configured for the version being set as default.
🤖 Prompt for AI Agents
.github/Dockerfile lines 17-18: replace the apt package `python3-pip` with
`python3.11-full` (or alternatively install pip for 3.11 via `python3.11 -m
ensurepip`) because `python3-pip` targets the distro default Python (3.10) and
can cause pip/version mismatches after switching to Python 3.11; update the
package list to include `python3.11-full` so pip is installed and configured for
Python 3.11, or install/ensure pip for 3.11 immediately after installing Python
3.11.
User description
PR Type
Enhancement
Description
Upgrade Python from default version to Python 3.11
Add deadsnakes PPA for Python 3.11 availability
Replace python3-pip with python3.11-distutils package
Configure python3 symlink to point to Python 3.11
Diagram Walkthrough
File Walkthrough
Dockerfile
Upgrade Dockerfile to use Python 3.11.github/Dockerfile
Note
Moves Docker build to Python 3.11, configuring python3 alternative and adding deadsnakes PPA and required packages.
.github/Dockerfile):deadsnakesPPA and installsoftware-properties-common,ca-certificates,gnupg.python3packages withpython3.11equivalents (python3.11,python3.11-venv,python3.11-distutils).python3alternative to/usr/bin/python3.11.Written by Cursor Bugbot for commit d9ea3c0. Configure here.
CodeAnt-AI Description
Use Python 3.11 as the default runtime in Docker images
What Changed
Impact
✅ Runs user code with Python 3.11 inside official Docker images✅ Can create Python 3.11 virtual environments during image build✅ Consistent python3 runtime across GPU and CPU container builds💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.