Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Release

on:
release:
types:
- published
workflow_dispatch:

jobs:
build-sdist:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Validate release tag matches package version
if: github.event_name == 'release'
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<'PY'
import os
import pathlib
import tomllib

project = tomllib.loads(pathlib.Path("pyproject.toml").read_text())
version = project["project"]["version"]
release_tag = os.environ["RELEASE_TAG"]
normalized_tag = release_tag[1:] if release_tag.startswith("v") else release_tag

if normalized_tag != version:
raise SystemExit(
f"Release tag {release_tag!r} does not match pyproject version {version!r}."
)

print(f"Building sdist for version {version}")
PY

- name: Show package version
if: github.event_name == 'workflow_dispatch'
run: |
python - <<'PY'
import pathlib
import tomllib

project = tomllib.loads(pathlib.Path("pyproject.toml").read_text())
print(f"Building TestPyPI sdist for version {project['project']['version']}")
PY

- name: Install packaging tools
run: python -m pip install --upgrade "setuptools>=77.0.3,<81.0.0" build twine

- name: Build source distribution
run: python -m build --sdist --no-isolation --skip-dependency-check

- name: Check package metadata
run: python -m twine check dist/*

- name: Upload source distribution artifact
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: dist/*.tar.gz

publish-pypi:
needs: build-sdist
if: github.event_name == 'release'
runs-on: ubuntu-latest

permissions:
id-token: write

environment:
name: pypi

steps:
- name: Download source distribution
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist

publish-testpypi:
needs: build-sdist
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

permissions:
id-token: write

environment:
name: testpypi

steps:
- name: Download source distribution
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist

- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
repository-url: https://test.pypi.org/legacy/
8 changes: 8 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include LICENSE
include README.md

recursive-include vllm_gguf_plugin/csrc *.h *.cpp *.cu *.cuh

global-exclude __pycache__
global-exclude *.py[cod]
global-exclude *.so
58 changes: 36 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
# SPDX-License-Identifier: Apache-2.0

import sys

from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension

setup(
ext_modules=[
CUDAExtension(
name="vllm_gguf_plugin._C_gguf",
sources=[
"vllm_gguf_plugin/csrc/torch_bindings.cpp",
"vllm_gguf_plugin/csrc/gguf/gguf_kernel.cu",
],
include_dirs=[
"vllm_gguf_plugin/csrc",
"vllm_gguf_plugin/csrc/gguf",
],
extra_compile_args={
"cxx": ["-O3", "-std=c++17"],
"nvcc": ["-O3", "-std=c++17", "--use_fast_math"],
},
)
],
cmdclass={"build_ext": BuildExtension},
)


def _should_build_extension() -> bool:
packaging_commands = {"sdist", "egg_info", "dist_info"}
return not any(command in packaging_commands for command in sys.argv[1:])


setup_kwargs = {}

if _should_build_extension():
from torch.utils.cpp_extension import BuildExtension, CUDAExtension

setup_kwargs.update(
ext_modules=[
CUDAExtension(
name="vllm_gguf_plugin._C_gguf",
sources=[
"vllm_gguf_plugin/csrc/torch_bindings.cpp",
"vllm_gguf_plugin/csrc/gguf/gguf_kernel.cu",
],
include_dirs=[
"vllm_gguf_plugin/csrc",
"vllm_gguf_plugin/csrc/gguf",
],
extra_compile_args={
"cxx": ["-O3", "-std=c++17"],
"nvcc": ["-O3", "-std=c++17", "--use_fast_math"],
},
)
],
cmdclass={"build_ext": BuildExtension},
)

setup(**setup_kwargs)
Loading