forked from pytorch/torchrec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
124 lines (104 loc) · 3.58 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import subprocess
import sys
from pathlib import Path
from typing import List
from setuptools import find_packages, setup
ROOT_DIR = Path(__file__).parent.resolve()
def _get_version():
try:
cmd = ["git", "rev-parse", "HEAD"]
sha = subprocess.check_output(cmd, cwd=str(ROOT_DIR)).decode("ascii").strip()
except Exception:
sha = None
if "BUILD_VERSION" in os.environ:
version = os.environ["BUILD_VERSION"]
else:
with open(os.path.join(ROOT_DIR, "version.txt"), "r") as f:
version = f.readline().strip()
if sha is not None and "OFFICIAL_RELEASE" not in os.environ:
version += "+" + sha[:7]
if sha is None:
sha = "Unknown"
return version, sha
def _export_version(version, sha):
version_path = ROOT_DIR / "torchrec" / "version.py"
with open(version_path, "w") as fileobj:
fileobj.write("__version__ = '{}'\n".format(version))
fileobj.write("git_version = {}\n".format(repr(sha)))
def parse_args(argv: List[str]) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="torchrec setup")
return parser.parse_known_args(argv)
def main(argv: List[str]) -> None:
args, unknown = parse_args(argv)
with open(
os.path.join(os.path.dirname(__file__), "README.MD"), encoding="utf8"
) as f:
readme = f.read()
with open(
os.path.join(os.path.dirname(__file__), "install-requirements.txt"),
encoding="utf8",
) as f:
reqs = f.read()
install_requires = reqs.strip().split("\n")
version, sha = _get_version()
_export_version(version, sha)
print(f"-- torchrec building version: {version}")
packages = find_packages(
exclude=(
"*tests",
"*test",
"examples",
"*examples.*",
"*benchmarks",
"*build",
"*rfc",
)
)
sys.argv = [sys.argv[0]] + unknown
setup(
# Metadata
name="torchrec",
version=version,
author="TorchRec Team",
author_email="[email protected]",
maintainer="PaulZhang12",
maintainer_email="[email protected]",
description="TorchRec: Pytorch library for recommendation systems",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/pytorch/torchrec",
license="BSD-3",
keywords=[
"pytorch",
"recommendation systems",
"sharding",
"distributed training",
],
python_requires=">=3.9",
install_requires=install_requires,
packages=packages,
zip_safe=False,
# PyPI package information.
classifiers=[
"Development Status :: 5 - Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
)
if __name__ == "__main__":
main(sys.argv[1:])