Unverified Commit 376725ce authored by Woosuk Kwon's avatar Woosuk Kwon Committed by GitHub
Browse files

[PyPI] Packaging for PyPI distribution (#140)

parent 456941cf
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*.csv *.csv
build/ build/
docs/build/ docs/build/
dist/
*.pkl *.pkl
*.png *.png
......
include LICENSE
include requirements.txt
recursive-include csrc *
...@@ -5,6 +5,8 @@ from cacheflow.server.arg_utils import ServerArgs ...@@ -5,6 +5,8 @@ from cacheflow.server.arg_utils import ServerArgs
from cacheflow.server.llm_server import LLMServer from cacheflow.server.llm_server import LLMServer
from cacheflow.server.ray_utils import initialize_cluster from cacheflow.server.ray_utils import initialize_cluster
__version__ = "0.1.0"
__all__ = [ __all__ = [
"LLM", "LLM",
"SamplingParams", "SamplingParams",
......
...@@ -32,7 +32,7 @@ You can install CacheFlow using pip: ...@@ -32,7 +32,7 @@ You can install CacheFlow using pip:
$ conda activate myenv $ conda activate myenv
$ # Install CacheFlow. $ # Install CacheFlow.
$ pip install cacheflow $ pip install cacheflow # This may take 5-10 minutes.
.. _build_from_source: .. _build_from_source:
...@@ -46,5 +46,4 @@ You can also build and install CacheFlow from source. ...@@ -46,5 +46,4 @@ You can also build and install CacheFlow from source.
$ git clone https://github.com/WoosukKwon/cacheflow.git $ git clone https://github.com/WoosukKwon/cacheflow.git
$ cd cacheflow $ cd cacheflow
$ pip install -r requirements.txt
$ pip install -e . # This may take 5-10 minutes. $ pip install -e . # This may take 5-10 minutes.
[build-system]
requires = [
"ninja",
"packaging",
"setuptools",
"torch >= 2.0.0",
"wheel",
]
build-backend = "setuptools.build_meta"
import io
import os
import re
import subprocess import subprocess
from typing import List, Set from typing import List, Set
from packaging.version import parse, Version from packaging.version import parse, Version
import setuptools import setuptools
import torch import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME
from torch.utils.cpp_extension import CUDA_HOME
ROOT_DIR = os.path.dirname(__file__)
# Compiler flags. # Compiler flags.
CXX_FLAGS = ["-g", "-O2"] CXX_FLAGS = ["-g", "-O2", "-std=c++17"]
# TODO(woosuk): Should we use -O3? # 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(): if not torch.cuda.is_available():
raise RuntimeError( raise RuntimeError(
...@@ -102,15 +109,58 @@ activation_extension = CUDAExtension( ...@@ -102,15 +109,58 @@ activation_extension = CUDAExtension(
ext_modules.append(activation_extension) 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]: def get_requirements() -> List[str]:
"""Get Python package dependencies from requirements.txt.""" """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") requirements = f.read().strip().split("\n")
return requirements return requirements
setuptools.setup( setuptools.setup(
name="cacheflow", 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", python_requires=">=3.8",
install_requires=get_requirements(), install_requires=get_requirements(),
ext_modules=ext_modules, ext_modules=ext_modules,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment