-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7ea3bb
commit 1dfdb88
Showing
9 changed files
with
300 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# GH actions. | ||
name: Wheel-Mac | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' # Push events to every tag not containing / | ||
|
||
jobs: | ||
Build: | ||
strategy: | ||
matrix: | ||
platform: ['macos-13', 'macos-latest'] | ||
|
||
runs-on: ${{ matrix.platform }} | ||
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 scripts/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 }} | ||
# Use conda for LLVM dep | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
activate-environment: xgrammar-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 ${{ matrix.platform == 'macos-13' && '10.15' || '13.02' }} | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# GH actions. | ||
name: Wheel-Windows | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' # Push events to every tag not containing / | ||
|
||
jobs: | ||
Build: | ||
runs-on: windows-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/xgrammar | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
defaults: | ||
run: | ||
shell: 'cmd /C call {0}' | ||
|
||
steps: | ||
- name: Git config | ||
run: >- | ||
git config --system core.longpaths true | ||
- 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 scripts/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 }} | ||
# Use conda for LLVM dep | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
activate-environment: xgrammar-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@Win | ||
run: >- | ||
scripts/build_xgrammar_lib_win.bat | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: xgrammar-build | ||
|
||
channels: | ||
- pytorch | ||
- conda-forge | ||
|
||
dependencies: | ||
- llvmdev>=15 | ||
- cmake>=3.24 | ||
- zlib | ||
- zstd-static | ||
- git | ||
- conda-build | ||
- numpy | ||
- pytest | ||
- pip | ||
- cython | ||
- pybind11 | ||
- pytorch | ||
- cpuonly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/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 | ||
rm -rf build | ||
mkdir -p build | ||
cd build | ||
|
||
MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-${1}} | ||
|
||
cmake -DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \ | ||
-DHIDE_PRIVATE_SYMBOLS=ON \ | ||
.. | ||
|
||
make -j3 | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
echo on | ||
|
||
del /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 | ||
|
||
rd /s /q build | ||
mkdir build | ||
cd build | ||
|
||
cmake -A x64 -Thost=x64 ^ | ||
-G "Visual Studio 17 2022" ^ | ||
.. | ||
|
||
if %errorlevel% neq 0 exit %errorlevel% | ||
|
||
cmake --build . --parallel 3 --config Release --target xgrammar_bindings -- /m | ||
|
||
if %errorlevel% neq 0 exit %errorlevel% | ||
|
||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.