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

Build macOS executable for M- series Macs #2263

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
41 changes: 41 additions & 0 deletions .github/workflows/m-series-mac-executable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: WeasyPrint’s M-series macOS binary generation
on: [push]

jobs:
generate:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
brew install pango gobject-introspection cairo glib
brew install [email protected]
echo "export PATH=\"/opt/homebrew/opt/[email protected]/bin:$PATH\"" >> $GITHUB_ENV
- name: Ensure absolute imports
run: |
sed -i '' 's/^from \. /from weasyprint /' weasyprint/__main__.py
sed -i '' 's/^from \./from weasyprint\./' weasyprint/__main__.py
- name: Install requirements
run: python -m pip install . pyinstaller
- name: Create dyld PATH hook
run: |
echo "import os" > weasyprint/set_dyld_path.py
echo "import sys" >> weasyprint/set_dyld_path.py
echo "lib_path = os.path.join(sys._MEIPASS, 'lib')" >> weasyprint/set_dyld_path.py
echo "os.environ['DYLD_LIBRARY_PATH'] = lib_path" >> weasyprint/set_dyld_path.py
- name: Generate executable with included libraries
run: |
python -m PyInstaller weasyprint/__main__.py -n weasyprint -F --add-binary "/opt/homebrew/Cellar/glib/2.82.0/lib/libgobject-2.0.0.dylib:./lib" --add-binary "/opt/homebrew/lib/libgobject-2.0.dylib:./lib" --add-binary "/opt/homebrew/Cellar/pango/1.54.0/lib/libpango-1.0.0.dylib:./lib" --add-binary "/opt/homebrew/lib/libpango-1.0.dylib:./lib" --add-binary "/opt/homebrew/Cellar/fontconfig/2.15.0/lib/libfontconfig.1.dylib:./lib" --add-binary "/opt/homebrew/lib/libfontconfig.1.dylib:./lib" --add-binary "/opt/homebrew/lib/libfontconfig.dylib:./lib" --add-binary "/opt/homebrew/lib/libpangoft2-1.0.0.dylib:./lib" --add-binary "/opt/homebrew/lib/libpangoft2-1.0.dylib:./lib" --add-binary "/opt/homebrew/Cellar/pango/1.54.0/lib/libpangoft2-1.0.0.dylib:./lib" --runtime-hook weasyprint/set_dyld_path.py
- name: Test executable
run: dist/weasyprint --info
- name: Store executable
uses: actions/upload-artifact@v4
with:
name: weasyprint-macos
path: |
dist/weasyprint
README.rst
LICENSE