-
Notifications
You must be signed in to change notification settings - Fork 142
/
setup.py
102 lines (80 loc) · 3.01 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
#!/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 re
import sys
from datetime import date
from setuptools import find_packages, setup
def clean_html(raw_html):
cleanr = re.compile("<.*?>")
cleantext = re.sub(cleanr, "", raw_html).strip()
return cleantext
def get_version():
# get version string from version.py
version_file = os.path.join(os.path.dirname(__file__), "version.py")
version_regex = r"__version__ = ['\"]([^'\"]*)['\"]"
with open(version_file, "r") as f:
version = re.search(version_regex, f.read(), re.M).group(1)
return version
def fetch_long_description():
with open("README.md", encoding="utf8") as f:
readme = f.read()
# https://stackoverflow.com/a/12982689
readme = clean_html(readme)
return readme
def read_requirements(file):
with open(file) as f:
reqs = f.read()
return reqs.strip().split("\n")
def get_nightly_version():
today = date.today()
return f"{today.year}.{today.month}.{today.day}"
def parse_args(argv): # Pass in a list of string from CLI
parser = argparse.ArgumentParser(description="torchmultimodal setup")
parser.add_argument(
"--package_name",
type=str,
default="torchmultimodal",
help="The name of this output wheel",
)
return parser.parse_known_args(argv)
if __name__ == "__main__":
args, unknown = parse_args(sys.argv[1:])
# Set up package name and version
name = args.package_name
is_nightly = "nightly" in name
version = get_nightly_version() if is_nightly else get_version()
print(f"-- {name} building version: {version}")
sys.argv = [sys.argv[0]] + unknown
setup(
name=name,
include_package_data=True,
packages=find_packages(
exclude=("examples*", "tests*")
), # Excluded folders don't get packaged
python_requires=">=3.7",
install_requires=read_requirements("requirements.txt"),
version=version,
description="PyTorch Multimodal Library",
long_description=fetch_long_description(),
long_description_content_type="text/markdown",
url="https://github.com/facebookresearch/multimodal",
author="PyTorch Multimodal Team",
author_email="[email protected]",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
extras_require={"dev": read_requirements("dev-requirements.txt")},
)