-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
setup.py
112 lines (93 loc) · 2.81 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
import codecs
import os
import pathlib
import platform
import re
from setuptools import setup, find_packages
def clean_html(raw_html):
"""
Args:
raw_html:
Returns:
"""
cleanr = re.compile("<.*?>")
cleantext = re.sub(cleanr, "", raw_html).strip()
return cleantext
# Single sourcing code from here:
# https://packaging.python.org/guides/single-sourcing-package-version/
def find_version(*file_paths):
"""
Args:
*file_paths:
Returns:
"""
here = os.path.abspath(os.path.dirname(__file__))
def read(*parts):
"""
Args:
*parts:
Returns:
"""
with codecs.open(os.path.join(here, *parts), "r") as fp:
return fp.read()
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
def fetch_long_description():
"""
Returns:
"""
with open("README.md", encoding="utf8") as f:
readme = f.read()
# https://stackoverflow.com/a/12982689
readme = clean_html(readme)
return readme
def fetch_requirements():
"""
Returns:
"""
requirements_file = "requirements.txt"
if platform.system() == "Windows":
DEPENDENCY_LINKS.append("https://download.pytorch.org/whl/torch_stable.html")
with open(requirements_file) as f:
reqs = f.read()
reqs = reqs.strip().split("\n")
return reqs
HERE = pathlib.Path(__file__).parent
DISTNAME = "self_attention_cv"
DESCRIPTION = "Self-attention building blocks for computer vision applications in PyTorch"
LONG_DESCRIPTION = (HERE / "README.md").read_text()
LONG_DESCRIPTION_CONTENT_TYPE = "text/markdown"
URL = "https://github.com/The-AI-Summer/self_attention_cv"
AUTHOR = "Adaloglou Nikolas"
AUTHOR_EMAIL = "[email protected]"
LICENSE = "MIT"
DEPENDENCY_LINKS = []
REQUIREMENTS = (fetch_requirements())
EXCLUDES = ("examples")
EXT_MODULES = []
if __name__ == "__main__":
setup(
name=DISTNAME,
install_requires=REQUIREMENTS,
url=URL,
license=LICENSE,
include_package_data=True,
version=find_version("self_attention_cv", "version.py"),
packages=find_packages(exclude=EXCLUDES),
python_requires=">=3.6",
ext_modules=EXT_MODULES,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type=LONG_DESCRIPTION_CONTENT_TYPE,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
dependency_links=DEPENDENCY_LINKS,
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
]
)