-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
88 lines (68 loc) · 2.91 KB
/
setup.py
File metadata and controls
88 lines (68 loc) · 2.91 KB
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
import setuptools
import typing as t
import os
import shutil
import importlib
_HERE = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
classifiers = [
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Text Processing :: Linguistic'
]
description = "toolbox for various tasks in the area of vector space models of computational linguistic"
name = "vsmlib"
url = "http://vsm.blackbird.pw/"
def parse_requirements(requirements_path: str = 'requirements.txt') -> t.List[str]:
"""Read contents of requirements.txt file and return data from its relevant lines.
Only non-empty and non-comment lines are relevant.
"""
requirements = []
with open(os.path.join(_HERE, requirements_path)) as reqs_file:
for requirement in [line.strip() for line in reqs_file.read().splitlines()]:
if not requirement or requirement.startswith('#'):
continue
requirements.append(requirement)
return requirements
def parse_readme(readme_path: str = 'README.rst', encoding: str = 'utf-8') -> str:
"""Read contents of readme file (by default "README.rst") and return them."""
with open(os.path.join(_HERE, readme_path), encoding=encoding) as readme_file:
desc = readme_file.read()
return desc
def clean(build_directory_name: str = 'build') -> None:
"""Recursively delete build directory (by default "build") if it exists."""
build_directory_path = os.path.join(_HERE, build_directory_name)
if os.path.isdir(build_directory_path):
shutil.rmtree(build_directory_path)
def find_version(
package_name: str, version_module_name: str = '_version',
version_variable_name: str = 'VERSION') -> str:
"""Simulate behaviour of "from package_name._version import VERSION", and return VERSION."""
version_module = importlib.import_module('{}.{}'.format(package_name, version_module_name))
return getattr(version_module, version_variable_name)
def setup():
setuptools.setup(
name=name,
version=find_version(name.replace('-', '_')),
url=url,
classifiers=classifiers,
keywords=['NLP', 'linguistics', 'language'],
install_requires=parse_requirements(),
description=description,
long_description=parse_readme(),
packages=setuptools.find_packages(exclude=['contrib', 'docs', 'test*']),
entry_points={'console_scripts': ['vsmlib=vsmlib.cli:main']},
package_data={"vsmlib": ['benchmarks/data/toefl/*']},
include_package_data=True
)
def main() -> None:
clean()
setup()
if __name__ == '__main__':
main()