Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
potatomashed committed Sep 29, 2024
0 parents commit 1441797
Show file tree
Hide file tree
Showing 101 changed files with 11,952 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BasedOnStyle: LLVM
ColumnLimit: 120
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: build-vscode/
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI

on: [push, pull_request]
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_COMMAND: "pytest -svv {project}/tests/python/"
MLC_CIBW_VERSION: "2.20.0"
MLC_PYTHON_VERSION: "3.9"
MLC_CIBW_WIN_BUILD: "cp39-win_amd64"
MLC_CIBW_MAC_BUILD: "cp39-macosx_arm64"
MLC_CIBW_LINUX_BUILD: "cp312-manylinux_x86_64"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- uses: pre-commit/[email protected]
windows:
name: Windows
runs-on: windows-latest
needs: pre-commit
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel=="${{ env.MLC_CIBW_VERSION }}"
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL: ".\\scripts\\cpp_tests.bat"
CIBW_BUILD: ${{ env.MLC_CIBW_WIN_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
macos:
name: MacOS
runs-on: macos-latest
needs: pre-commit
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==${{ env.MLC_CIBW_VERSION }}
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL: "./scripts/cpp_tests.sh"
CIBW_BUILD: ${{ env.MLC_CIBW_MAC_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
linux:
name: Linux
runs-on: ubuntu-latest
needs: pre-commit
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==${{ env.MLC_CIBW_VERSION }}
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL: "./scripts/setup_manylinux2014.sh && ./scripts/cpp_tests.sh"
CIBW_BUILD: ${{ env.MLC_CIBW_LINUX_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
168 changes: 168 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Release

on:
release:
types: [published]

env:
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_COMMAND: "python -c \"import mlc\""
CIBW_SKIP: "cp313-win_amd64" # Python 3.13 is not quite ready yet
MLC_CIBW_VERSION: "2.20.0"
MLC_PYTHON_VERSION: "3.9"
MLC_CIBW_WIN_BUILD: "cp3*-win_amd64"
MLC_CIBW_MAC_BUILD: "cp3*-macosx_arm64"
MLC_CIBW_MAC_X86_BUILD: "cp3*-macosx_x86_64"
MLC_CIBW_LINUX_BUILD: "cp3*-manylinux_x86_64"

jobs:
windows:
name: Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel=="${{ env.MLC_CIBW_VERSION }}"
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: ${{ env.MLC_CIBW_WIN_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: ./wheelhouse/*.whl
macos:
name: MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==${{ env.MLC_CIBW_VERSION }}
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: ${{ env.MLC_CIBW_MAC_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos
path: ./wheelhouse/*.whl
macos-x86:
name: MacOS-x86
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==${{ env.MLC_CIBW_VERSION }}
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: ${{ env.MLC_CIBW_MAC_X86_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-x86
path: ./wheelhouse/*.whl
linux:
name: Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==${{ env.MLC_CIBW_VERSION }}
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: ${{ env.MLC_CIBW_LINUX_BUILD }}
- name: Show package contents
run: python scripts/show_wheel_content.py wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: ./wheelhouse/*.whl
publish:
name: Publish
runs-on: ubuntu-latest
needs: [windows, macos, linux, macos-x86]
environment:
name: pypi
url: https://pypi.org/p/mlc-python
permissions:
id-token: write
contents: write
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.MLC_PYTHON_VERSION }}
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./wheelhouse
- name: Prepare distribution files
run: |
mkdir -p dist
mv wheelhouse/wheels-macos-x86/*.whl dist/
mv wheelhouse/wheels-macos/*.whl dist/
mv wheelhouse/wheels-linux/*.whl dist/
mv wheelhouse/wheels-windows/*.whl dist/
- name: Upload wheels to release
env:
GITHUB_TOKEN: ${{ secrets.PYMLC_GITHUB_TOKEN }}
run: |
# Get the release ID
release_id=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} --jq '.id')
if [ -z "$release_id" ]; then
echo "Error: Could not find release with tag ${{ github.ref_name }}"
exit 1
fi
upload_url=https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets
echo "Uploading to release ID: $release_id. Upload URL: $upload_url"
for wheel in dist/*.whl; do
echo "⏫ Uploading $(basename $wheel)"
response=$(curl -s -w "%{http_code}" -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$wheel" \
"$upload_url?name=$(basename $wheel)")
http_code=${response: -3}
if [ $http_code -eq 201 ]; then
echo "🎉 Successfully uploaded $(basename $wheel)"
else
echo "❌ Failed to upload $(basename $wheel). HTTP status: $http_code. Error response: ${response%???}"
exit 1
fi
done
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
*.dSYM
build
build-cpp-tests
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "3rdparty/dlpack"]
path = 3rdparty/dlpack
url = https://github.com/dmlc/dlpack.git
[submodule "3rdparty/libbacktrace"]
path = 3rdparty/libbacktrace
url = https://github.com/ianlancetaylor/libbacktrace
[submodule "3rdparty/googletest"]
path = 3rdparty/googletest
url = https://github.com/google/googletest.git
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.1"
hooks:
- id: mypy
additional_dependencies: ['numpy >= 1.22', "ml-dtypes >= 0.1", "pytest"]
args: [--show-error-codes]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v18.1.5"
hooks:
- id: clang-format
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.2
hooks:
- id: cython-lint
- id: double-quote-cython-strings
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
# - repo: https://github.com/cheshirekow/cmake-format-precommit
# rev: v0.6.10
# hooks:
# - id: cmake-format
# - id: cmake-lint
1 change: 1 addition & 0 deletions 3rdparty/dlpack
Submodule dlpack added at bbd2f4
1 change: 1 addition & 0 deletions 3rdparty/googletest
Submodule googletest added at f8d7d7
1 change: 1 addition & 0 deletions 3rdparty/libbacktrace
Submodule libbacktrace added at febbb9
Loading

0 comments on commit 1441797

Please sign in to comment.