Fix Docker build on ARM by pre-installing numpy#1121
Fix Docker build on ARM by pre-installing numpy#1121sbryngelson merged 4 commits intoMFlowCode:masterfrom
Conversation
Several dependencies (cantera, pandas, matplotlib, seaborn) require numpy at build time when compiling from source. On ARM architectures where pre-built wheels aren't available, pip would fail because numpy wasn't installed before these packages tried to build. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
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:
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThe pull request adds a pre-installation step for numpy in the bootstrap script before the main toolchain dependencies are installed. If the numpy installation fails, the script logs an error and exits. The rest of the dependency installation flow remains unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
toolchain/bootstrap/python.sh
Outdated
| log "(venv) Pre-installing numpy (build-time dependency)." | ||
| if ! PIP_DISABLE_PIP_VERSION_CHECK=1 pip3 install numpy; then | ||
| error "(venv) Failed to install numpy." | ||
| log "(venv) Exiting the$MAGENTA Python$COLOR_RESET virtual environment." |
There was a problem hiding this comment.
✅ Suggestion: Fix a formatting issue in a log message by adding a missing space before the color code. [general, importance: 4]
| log "(venv) Exiting the$MAGENTA Python$COLOR_RESET virtual environment." | |
| log "(venv) Exiting the $MAGENTA Python$COLOR_RESET virtual environment." |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Pull request overview
This PR fixes Docker build failures on ARM architecture by pre-installing numpy before other Python dependencies. The issue occurs because several scientific Python packages (pandas, cantera, matplotlib) require numpy to be importable during their build process when compiling from source. On ARM64, pre-built binary wheels often don't exist, causing pip to build from source and fail when numpy isn't available.
Changes:
- Added numpy pre-installation step in
toolchain/bootstrap/python.shbefore installing other dependencies
toolchain/bootstrap/python.sh
Outdated
| # (pandas, cantera, matplotlib, etc.) that may need to compile from source | ||
| # on architectures without pre-built wheels (e.g., ARM) | ||
| log "(venv) Pre-installing numpy (build-time dependency)." | ||
| if ! PIP_DISABLE_PIP_VERSION_CHECK=1 pip3 install numpy; then |
There was a problem hiding this comment.
Consider adding MAKEFLAGS to enable parallel compilation when building numpy from source on ARM. This would be consistent with the main installation command at line 159 and improve build performance. The command could be: PIP_DISABLE_PIP_VERSION_CHECK=1 MAKEFLAGS=$nthreads pip3 install numpy
| if ! PIP_DISABLE_PIP_VERSION_CHECK=1 pip3 install numpy; then | |
| if ! PIP_DISABLE_PIP_VERSION_CHECK=1 MAKEFLAGS=$nthreads pip3 install numpy; then |
toolchain/bootstrap/python.sh
Outdated
| # (pandas, cantera, matplotlib, etc.) that may need to compile from source | ||
| # on architectures without pre-built wheels (e.g., ARM) | ||
| log "(venv) Pre-installing numpy (build-time dependency)." | ||
| if ! PIP_DISABLE_PIP_VERSION_CHECK=1 pip3 install numpy; then |
There was a problem hiding this comment.
pip3 install numpy fetches and executes a third-party package from the default index without any version pinning or integrity controls, which introduces supply chain risk in the build toolchain. If the numpy package or its distribution channel is compromised, a malicious release could execute arbitrary code during the Docker build and persist backdoors into the resulting image. To reduce this risk, pin numpy to a specific trusted version (and/or vendor it or use a private index with vetted artifacts) so that builds are deterministic and not automatically picking up potentially malicious new releases.
Use github.repository variable instead of hardcoded MFlowCode/MFC to allow testing on forks. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Keep the fix targeted to Docker builds only, where ARM architectures lack pre-built wheels. Normal users aren't affected by unnecessary extra installation steps. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
User description
User description
Summary
toolchain/bootstrap/python.shcantera,pandas,matplotlibneed numpy at build time when compiling from sourceContext
The Docker workflow was failing on
ubuntu-22.04-armbecause several scientific Python packages require numpy to be importable during their wheel build process. Since pre-built binary wheels often don't exist for ARM64, pip tries to build from source and fails when numpy isn't installed yet.See: https://github.com/MFlowCode/MFC/actions/runs/21636236188
Test plan
🤖 Generated with Claude Code
PR Type
Bug fix
Description
Pre-installs numpy before other Python dependencies in bootstrap script
Fixes Docker build failures on ARM architecture where packages need numpy at build time
Adds error handling for numpy installation with proper logging and cleanup
Diagram Walkthrough
File Walkthrough
python.sh
Pre-install numpy with error handlingtoolchain/bootstrap/python.sh
on failure
ARM builds
style
Note
Low Risk
Low risk: changes only the Python bootstrap install order by adding an extra
pip3 install numpystep, with straightforward failure handling. Main impact is dependency resolution/build behavior during installs, especially on platforms compiling wheels from source (e.g., ARM).Overview
Fixes ARM/Docker bootstrap failures by pre-installing
numpyin the venv before installing the project’s Python dependencies.toolchain/bootstrap/python.shnow installsnumpyas an explicit build-time prerequisite (with logging and early-exit error handling) prior to runningpip3 install $(pwd)/toolchain.Written by Cursor Bugbot for commit 24a3063. Configure here.
CodeAnt-AI Description
Pre-install numpy in bootstrap to fix Docker ARM builds
What Changed
Impact
✅ Fewer ARM Docker build failures✅ Shorter CI debugging for Python wheel build errors✅ Clearer failure messages when numpy can't be installed💡 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