-
Notifications
You must be signed in to change notification settings - Fork 64
/
setup.py
67 lines (54 loc) · 2.02 KB
/
setup.py
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
import os
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
from pathlib import Path
# read the contents of your README file
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
class CMakeExtension(Extension):
"""
Overrides the base extension class so that setuptools
doesn't try to build your sources for you
"""
def __init__(self, name, sources=[]):
super().__init__(name=name, sources=sources)
class BuildCMakeExt(build_ext):
def run(self):
for extension in self.extensions:
if extension.name == "xft":
self.build_cmake()
else:
super().run()
def build_cmake(self):
self.announce("Preparing the build environment", level=3)
build_dir = os.path.abspath(os.path.dirname(self.build_temp))
os.makedirs(build_dir, exist_ok=True)
self.announce("Building xft binaries", level=3)
self.spawn(["cmake", f"-B {build_dir}", "."])
self.spawn(["make", "-C", build_dir, "-j"])
def get_xft_version() -> str:
xft_root = Path(__file__).parent
version = open(xft_root / "VERSION").read().strip()
return version
setup(
name="xfastertransformer",
version=get_xft_version(),
keywords="LLM",
description="Boost large language model inference performance on CPU platform.",
long_description=long_description,
long_description_content_type="text/markdown",
license="Apache 2.0",
url="https://github.com/intel/xFasterTransformer",
author="xFasterTransformer",
author_email="xft.maintainer@intel.com",
python_requires=">=3.8",
package_dir={"": "src"},
packages=find_packages(where="src", include=["xfastertransformer"]),
package_data={
"xfastertransformer": ["*.so", "tools/*.*"],
},
platforms="x86_64",
ext_modules=[CMakeExtension(name="xft")],
cmdclass={"build_ext": BuildCMakeExt},
install_requires=["torch>=2.3.0, <2.4.0"],
)