-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·76 lines (60 loc) · 2.14 KB
/
setup.py
File metadata and controls
executable file
·76 lines (60 loc) · 2.14 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
#!/usr/bin/env python3
import importlib.util
if importlib.util.find_spec("setuptools_scm") is None:
raise ImportError("setuptools-scm is not installed. Install it by `pip3 install setuptools-scm`")
import os
import subprocess
import sys
from os import path
from setuptools import find_packages, setup
from setuptools_scm.version import get_local_dirty_tag
THIS_DIR = path.dirname(path.abspath(__file__))
UPDATE_SUBMODULES = os.environ.get("QUANTUM_ATTN_BUILD_UPDATE_SUBMODULES", "1") == "1"
def is_git_directory(path="."):
return subprocess.call(["git", "-C", path, "status"], stderr=subprocess.STDOUT, stdout=open(os.devnull, "w")) == 0
if UPDATE_SUBMODULES:
if is_git_directory(THIS_DIR):
print("Updating submodules")
subprocess.run(
["git", "submodule", "update", "--init", "--recursive"],
check=True,
stdout=sys.stdout,
stderr=sys.stderr,
)
else:
print("Not a git directory. Skipping submodule update.")
def my_local_scheme(version):
# The following is used to build release packages.
# Users should never use it.
local_version = os.getenv("QUANTUM_ATTN_BUILD_LOCAL_VERSION")
if local_version is None:
return get_local_dirty_tag(version)
return f"+{local_version}"
def fetch_requirements():
with open("requirements.txt") as f:
reqs = f.read().strip().split("\n")
return reqs
setup(
name="quantum_attn",
use_scm_version={"write_to": path.join("src", "quantum_attn", "_version.py"), "local_scheme": my_local_scheme},
package_dir={
"": "src",
},
packages=find_packages(where="src"),
python_requires=">=3.8",
include_package_data=True,
install_requires=fetch_requirements(),
extras_require={
# optional dependencies, required by some features
"all": [],
# dev dependencies. Install them by `pip3 install 'quantum-attn[dev]'`
"dev": [
"pre-commit",
"pytest>=7.0.0,<8.0.0", # https://github.com/pytest-dev/pytest/issues/12273
"expecttest",
#
"pandas",
"llnl-hatchet",
],
},
)