[PyPI] Packaging for PyPI distribution (#140)

This commit is contained in:
Woosuk Kwon 2023-06-05 20:03:14 -07:00 committed by GitHub
parent 456941cfe4
commit 376725ce74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 72 additions and 7 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
*.csv
build/
docs/build/
dist/
*.pkl
*.png

4
MANIFEST.in Normal file
View File

@ -0,0 +1,4 @@
include LICENSE
include requirements.txt
recursive-include csrc *

View File

@ -5,6 +5,8 @@ from cacheflow.server.arg_utils import ServerArgs
from cacheflow.server.llm_server import LLMServer
from cacheflow.server.ray_utils import initialize_cluster
__version__ = "0.1.0"
__all__ = [
"LLM",
"SamplingParams",

View File

View File

View File

View File

View File

View File

@ -32,7 +32,7 @@ You can install CacheFlow using pip:
$ conda activate myenv
$ # Install CacheFlow.
$ pip install cacheflow
$ pip install cacheflow # This may take 5-10 minutes.
.. _build_from_source:
@ -46,5 +46,4 @@ You can also build and install CacheFlow from source.
$ git clone https://github.com/WoosukKwon/cacheflow.git
$ cd cacheflow
$ pip install -r requirements.txt
$ pip install -e . # This may take 5-10 minutes.

9
pyproject.toml Normal file
View File

@ -0,0 +1,9 @@
[build-system]
requires = [
"ninja",
"packaging",
"setuptools",
"torch >= 2.0.0",
"wheel",
]
build-backend = "setuptools.build_meta"

View File

@ -1,17 +1,24 @@
import io
import os
import re
import subprocess
from typing import List, Set
from packaging.version import parse, Version
import setuptools
import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME
ROOT_DIR = os.path.dirname(__file__)
# Compiler flags.
CXX_FLAGS = ["-g", "-O2"]
CXX_FLAGS = ["-g", "-O2", "-std=c++17"]
# TODO(woosuk): Should we use -O3?
NVCC_FLAGS = ["-O2"]
NVCC_FLAGS = ["-O2", "-std=c++17"]
ABI = 1 if torch._C._GLIBCXX_USE_CXX11_ABI else 0
CXX_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
NVCC_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
if not torch.cuda.is_available():
raise RuntimeError(
@ -102,15 +109,58 @@ activation_extension = CUDAExtension(
ext_modules.append(activation_extension)
def get_path(*filepath) -> str:
return os.path.join(ROOT_DIR, *filepath)
def find_version(filepath: str):
"""Extract version information from the given filepath.
Adapted from https://github.com/ray-project/ray/blob/0b190ee1160eeca9796bc091e07eaebf4c85b511/python/setup.py
"""
with open(filepath) as fp:
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", fp.read(), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
def read_readme() -> str:
"""Read the README file."""
return io.open(get_path("README.md"), "r", encoding="utf-8").read()
def get_requirements() -> List[str]:
"""Get Python package dependencies from requirements.txt."""
with open("requirements.txt") as f:
with open(get_path("requirements.txt")) as f:
requirements = f.read().strip().split("\n")
return requirements
setuptools.setup(
name="cacheflow",
version=find_version(get_path("cacheflow", "__init__.py")),
author="CacheFlow Team",
author_email="cacheflow@gmail.com",
license="Apache 2.0",
description="CacheFlow: A high-performance LLM Serving System",
long_description=read_readme(),
long_description_content_type="text/markdown",
url="https://github.com/WoosukKwon/cacheflow",
project_urls={
"Homepage": "https://github.com/WoosukKwon/cacheflow",
"Documentation": "https://cacheflow.readthedocs.io/en/latest/",
},
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: Apache Software License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
packages=setuptools.find_packages(
exclude=("benchmarks", "csrc", "docs", "examples", "tests")),
python_requires=">=3.8",
install_requires=get_requirements(),
ext_modules=ext_modules,