-
Notifications
You must be signed in to change notification settings - Fork 247
/
setup.py
92 lines (75 loc) · 3.07 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
#!/usr/bin/env python
import os
import re
from io import open
from setuptools import find_packages, setup
def parse_requirements(filename):
"""
Parse a requirements pip file returning the list of required packages. It exclude commented lines and --find-links directives.
Args:
filename: pip requirements requirements
Returns:
list of required package with versions constraints
"""
with open(filename) as file:
parsed_requirements = file.read().splitlines()
parsed_requirements = [line.strip()
for line in parsed_requirements
if not ((line.strip()[0] == "#") or line.strip().startswith('--find-links'))]
return parsed_requirements
def get_dependency_links(filename):
"""
Parse a requirements pip file looking for the --find-links directive.
Args:
filename: pip requirements requirements
Returns:
list of find-links's url
"""
with open(filename) as file:
parsed_requirements = file.read().splitlines()
dependency_links = list()
for line in parsed_requirements:
line = line.strip()
if line.startswith('--find-links'):
dependency_links.append(line.split('=')[1])
return dependency_links
dependency_links = get_dependency_links('requirements.txt')
parsed_requirements = parse_requirements('requirements.txt')
def versionfromfile(*filepath):
infile = os.path.join(*filepath)
with open(infile) as fp:
version_match = re.search(
r"^__version__\s*=\s*['\"]([^'\"]*)['\"]", fp.read(), re.M
)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string in {}.".format(infile))
here = os.path.abspath(os.path.dirname(__file__))
setup(
name="farm",
version=versionfromfile(here, "farm", "_version.py"),
author="Timo Moeller, Malte Pietsch, Branden Chan, Tanay Soni, Bogdan Kostic, Julian Risch",
author_email="[email protected]",
description="Framework for finetuning and evaluating transformer based language models",
long_description=open("readme.rst", "r", encoding="utf-8").read(),
long_description_content_type="text/x-rst",
keywords="BERT NLP deep-learning language-model transformer qa question-answering transfer-learning",
license="Apache",
url="https://github.com/deepset-ai/FARM",
download_url="https://github.com/deepset-ai/FARM/archive/v"+versionfromfile(here, "farm", "_version.py")+".tar.gz",
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
dependency_links=dependency_links,
install_requires=parsed_requirements,
python_requires=">=3.6.0",
extras_require={
"fasttext": ["fasttext==0.9.1"],
"onnx": ["onnxruntime"],
},
tests_require=["pytest"],
classifiers=[
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
)