-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathsetup.py
More file actions
107 lines (88 loc) · 3.71 KB
/
setup.py
File metadata and controls
107 lines (88 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import os
from setuptools import setup, find_packages
from typing import List, Dict, Tuple
# Set the build type using an environment variable to give us
# different package names based on the reason for the build.
VALID_BUILD_TYPES = {"release", "nightly", "dev"}
BUILD_TYPE = os.environ.get("BUILD_TYPE", "dev")
if BUILD_TYPE not in VALID_BUILD_TYPES:
raise ValueError(
f"Unsupported build type {BUILD_TYPE!r}, must be one of {VALID_BUILD_TYPES}"
)
from setuptools_scm import ScmVersion
def version_func(version: ScmVersion) -> str:
from setuptools_scm.version import guess_next_version
if BUILD_TYPE == "nightly":
# Nightly builds use alpha versions to ensure they are marked
# as pre-releases on pypi.org.
return version.format_next_version(
guess_next=guess_next_version,
fmt="{guessed}.a{node_date:%Y%m%d}",
)
if (
BUILD_TYPE == "release"
and not version.dirty
and (version.exact or version.node is None)
):
# When we have a tagged version, use that without modification.
return version.format_with("{tag}")
# In development mode or when the local repository is dirty, treat
# it is as local development version.
return version.format_next_version(
guess_next=guess_next_version,
fmt="{guessed}.dev{distance}",
)
def localversion_func(version: ScmVersion) -> str:
from setuptools_scm.version import get_local_node_and_date
# When we are building nightly versions, we guess the next release
# and add the date as an alpha version. We cannot publish packages
# with local versions, so we do not add one.
if BUILD_TYPE == "nightly":
return ""
# When we have an exact tag, with no local changes, do not append
# anything to the local version field.
if (
BUILD_TYPE == "release"
and not version.dirty
and (version.exact or version.node is None)
):
return ""
# In development mode or when the local repository is dirty,
# return a string that includes the git SHA (node) and a date,
# formatted as a local version tag.
return get_local_node_and_date(version)
def _setup_long_description() -> Tuple[str, str]:
return open("README.md", "r", encoding="utf-8").read(), "text/markdown"
def _setup_packages() -> List:
return find_packages(
"src", include=["compressed_tensors", "compressed_tensors.*"], exclude=["*.__pycache__.*"]
)
def _setup_install_requires() -> List:
return ["torch>=1.7.0,<2.11", "transformers<5.0.0", "pydantic>=2.0", "loguru"]
def _setup_extras() -> Dict:
return {
"dev": ["black==22.12.0", "isort==5.8.0", "wheel>=0.36.2", "flake8>=3.8.3", "pytest>=6.0.0", "nbconvert>=7.16.3", "transformers<5.0", "accelerate"],
"accelerate": ["accelerate"]
}
setup(
name="compressed-tensors",
use_scm_version={
"version_scheme": version_func,
"local_scheme": localversion_func,
"version_file": "src/compressed_tensors/version.py",
},
author="The vLLM Project",
author_email="vllm-questions@lists.berkeley.edu",
license="Apache 2.0",
description="Library for utilization of compressed safetensors of neural network models",
long_description=_setup_long_description()[0],
long_description_content_type=_setup_long_description()[1],
url="https://github.com/vllm-project/compressed-tensors",
extras_require=_setup_extras(),
install_requires=_setup_install_requires(),
package_dir={"": "src"},
package_data={"": ["transform/utils/hadamards.safetensors"]},
packages=_setup_packages(),
)