Use system Python to install packages for embeddable Python#331
Use system Python to install packages for embeddable Python#331t0mdavid-m merged 1 commit intomainfrom
Conversation
The embeddable Python distribution lacks development headers (Python.h) required to compile native extensions. When using the embeddable Python's pip directly, packages with native code fail to build with: fatal error C1083: Cannot open include file: 'Python.h' This fix uses the system Python (which has headers) to compile packages, while directing the output to the embeddable Python's site-packages directory using pip's --target flag. Changes: - build-windows-executable-app.yaml: Use system Python with --target, remove unnecessary pip installation in embeddable Python - test-win-exe-w-embed-py.yaml: Add setup-python action, use system Python with --target, remove pip installation step - docs/win_exe_with_embed_py.md: Add prerequisites section explaining the need for system Python, update install command to use --target https://claude.ai/code/session_0152zcfBS5dWLtM12ubuYrKC
📝 WalkthroughWalkthroughModified GitHub workflows and documentation for Windows executable creation with embedded Python to use system Python for package installation into embedded Python's site-packages, replacing direct embeddable Python pip usage and removing standalone pip installation steps. Changes
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Summary
This PR fixes package installation for Windows embeddable Python by using the system Python installation to compile and install packages into the embeddable Python's site-packages directory, rather than attempting to use the embeddable Python directly.
Problem
The embeddable Python distribution lacks development headers (
Python.h) needed to compile native extensions. Attempting to install packages directly with the embeddable Python fails when packages require compilation, resulting in errors like:Solution
get-pip.pyon the embeddable Python--targetflag to install packages into the embeddable Python'sLib/site-packagesdirectoryChanges Made
--targetKey Implementation Details
actions/setup-python@v5with the same version as the embeddable Pythonpython -m pip install -r requirements.txt --target python-3.11.9/Lib/site-packages --upgrade --no-warn-script-location--targetflag directs pip to install into the embeddable Python's site-packages while using the system Python's compiler and headershttps://claude.ai/code/session_0152zcfBS5dWLtM12ubuYrKC
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.