-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsetup.py
73 lines (61 loc) · 2.16 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
import setuptools
from pathlib import Path
from typing import List
import re
import os
import sys
ROOT_PATH = Path(os.path.dirname(os.path.abspath(__file__))).resolve()
REQUIREMENTS_PATH = Path(ROOT_PATH, "requirements.txt")
DEV_REQUIREMENTS_PATH = Path(ROOT_PATH, "dev.requirements.txt")
README_PATH = Path(ROOT_PATH, "README.md")
EXCLUDE_PACKAGES = ["faiss-gpu",
"psycopg2"] if sys.platform.lower() != "linux" else []
SUBSTITUTE_PACKAGES = [
"psycopg2-binary"] if sys.platform.lower() != "linux" else []
def parse_requirements(requirements: Path) -> List[str]:
with requirements.open(mode="r") as fd:
rlist_sans_comments = [
line.strip()
for line in fd.read().split("\n")
if (line.strip() or line.strip().startswith("#"))
]
final_rlist = [
line
if not re.match(pattern=r"^https?://.*$", string=line)
else re.sub(
pattern=r"(.*(?:https?://.*/)([a-zA-Z0-9_].*)[-]([a-zA-Z0-9.]*)([.]tar[.]gz|[.]tgz).*)",
repl=r"\2 @ \1",
string=line,
)
for line in rlist_sans_comments
]
return final_rlist
def parse_readme(readme: Path) -> str:
with readme.open("r") as fh:
long_description = fh.read()
return long_description
setuptools.setup(
name="gamechangerml",
version="1.10.0",
author="Booz Allen Hamilton",
author_email="gamechanger@advana",
description="Package for GAMECHANGER ML modules",
long_description=parse_readme(README_PATH),
long_description_content_type="text/markdown",
url="https://github.com/dod-advana/gamechanger-ml",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3.8",
"License :: ",
"Operating System :: OS Independent",
],
python_requires=">=3.8.0",
install_requires=[
p
for p in parse_requirements(REQUIREMENTS_PATH)
if re.split(r"\~s*[@=]\s*", p)[0].lower() not in EXCLUDE_PACKAGES
]
+ SUBSTITUTE_PACKAGES,
include_package_data=True,
extras_require={"dev": parse_requirements(DEV_REQUIREMENTS_PATH)},
)