Skip to content

Commit

Permalink
[Package] Mac x86
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJH5574 committed Nov 17, 2024
1 parent 8b549df commit 1e27350
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 1 deletion.
107 changes: 107 additions & 0 deletions .github/workflows/wheel_mac_x86.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# GH actions.
name: Wheel-Mac-X86/64

on:
push:
tags:
- '*' # Push events to every tag not containing /

jobs:
Build:
# do not use `macos-latest` to avoid running on arm
# details at https://github.com/actions/runner-images/
runs-on: macos-13
environment:
name: pypi
url: https://pypi.org/p/xgrammar
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
defaults:
run:
shell: 'bash -l {0}'

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Checkout source
run: |
git clone https://github.com/mlc-ai/package package --recursive
- name: Setup script env
run: |
mv package/conda/tvm-unity/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml
rm -rf conda
ln -s package/3rdparty/tlcpack/conda conda
- name: Sync XGrammar Package
run: |
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda
# Use conda for LLVM dep
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: tlcpack-build
channel-priority: strict
environment-file: conda/build-environment.yaml
auto-activate-base: false
- name: Conda info
run: |
conda info
conda list
python --version
- name: Build@MacOS
run: >-
scripts/build_xgrammar_lib_osx.sh
# Build wheel for different python versions
- name: Setup@Py39
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build-Py39
python-version: 3.9
auto-activate-base: false
- name: Wheel-Build@Py39
run: |
python --version
python -m pip install setuptools Cython wheel
cd python
python setup.py bdist_wheel
- name: Setup@Py310
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build-Py310
python-version: '3.10'
auto-activate-base: false
- name: Wheel-Build@Py310
run: |
python --version
python -m pip install setuptools Cython wheel
cd python
python setup.py bdist_wheel
- name: Setup@Py311
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build-Py311
python-version: '3.11'
auto-activate-base: false
- name: Wheel-Build@Py311
run: |
python --version
python -m pip install setuptools Cython wheel
cd python
python setup.py bdist_wheel
- name: Setup@Py312
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build-Py312
python-version: '3.12'
auto-activate-base: false
- name: Wheel-Build@Py312
run: |
python --version
python -m pip install setuptools Cython wheel
cd python
python setup.py bdist_wheel
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages_dir: python/dist
# skip_existing: true
# verbose: true
28 changes: 28 additions & 0 deletions scripts/build_xgrammar_lib_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e
set -u

# setup config.cmake
rm -f config.cmake
echo set\(XGRAMMAR_BUILD_PYTHON_BINDINGS ON\) >>config.cmake
echo set\(XGRAMMAR_BUILD_KERNELS OFF\) >>config.cmake
echo set\(XGRAMMAR_BUILD_CUDA_KERNELS OFF\) >>config.cmake
echo set\(XGRAMMAR_BUILD_CXX_TESTS OFF\) >>config.cmake


# compile the xgrammar
python3 -m pip install ninja pybind11 torch
rm -rf build
mkdir -p build
cd build

MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-10.15}

cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
..

ninja -j 3
cd ..
2 changes: 1 addition & 1 deletion scripts/build_xgrammar_lib_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rd /s /q build
mkdir build
cd build

cmake -A x64 -Thost=x64 ^
cmake -Thost=x64 ^
-G "Visual Studio 17 2022" ^
-G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
Expand Down

0 comments on commit 1e27350

Please sign in to comment.