-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
87 lines (76 loc) · 3.31 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
#!/usr/bin/env python
import os
import re
import sys
import urllib.request
from glob import glob
from itertools import chain
from subprocess import run
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
from semstr.__version__ import VERSION
try:
this_file = __file__
except NameError:
this_file = sys.argv[0]
os.chdir(os.path.dirname(os.path.abspath(this_file)))
extras_require = {}
install_requires = []
for requirements_file in glob("requirements.*txt"):
suffix = re.match(r"[^.]*\.(.*)\.?txt", requirements_file).group(1).rstrip(".")
with open(requirements_file) as f:
(extras_require.setdefault(suffix, []) if suffix else install_requires).extend(f.read().splitlines())
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
class install(_install):
# noinspection PyBroadException
def run(self):
# Get submodules
self.announce("Getting git submodules...")
run(["git", "submodule", "update", "--init", "--recursive"], check=True)
# Install requirements
self.announce("Installing dependencies...")
run(["pip", "--no-cache-dir", "install"] + install_requires +
list(chain.from_iterable(extras_require.values())), check=True)
# Install AMR resource
for filename in ("have-org-role-91-roles-v1.06.txt", "have-rel-role-91-roles-v1.06.txt",
"verbalization-list-v1.06.txt", "morph-verbalization-v1.01.txt"):
out_file = os.path.join("semstr", "util", "resources", filename)
if not os.path.exists(out_file):
self.announce("Getting '%s'..." % filename)
for attempt in 1, 2:
try:
urllib.request.urlretrieve("https://amr.isi.edu/download/lists/" + filename, out_file)
except Exception as e:
self.warn("Failed downloading https://amr.isi.edu/download/lists/" + filename + " to " + out_file + ": " + str(e))
import ssl
if getattr(ssl, '_create_unverified_context', None):
ssl._create_default_https_context = ssl._create_unverified_context
# Install actual package
_install.run(self)
setup(name="SEMSTR",
version=VERSION,
description="Scheme Evaluation and Mapping for Structural Text Representation",
long_description=long_description,
long_description_content_type='text/markdown',
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.6",
"Topic :: Text Processing :: Linguistic",
],
author="Daniel Hershcovich",
author_email="[email protected]",
url="https://github.com/huji-nlp/semstr",
install_requires=install_requires,
extras_require=extras_require,
packages=find_packages() + ["src"],
package_dir={
"src": os.path.join("semstr", "amr", "src"),
},
package_data={"src": ["amr.peg"], "semstr.util": ["resources/*.txt"]},
cmdclass={"install": install},
)