-
Notifications
You must be signed in to change notification settings - Fork 38
/
setup.py
48 lines (43 loc) · 1.4 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
from setuptools import setup
project = dict(
name='lecture-summarizer',
version='0.0.1',
install_requires=[
'requests',
],
py_modules=['lecture_summarizer'],
entry_points={
'console_scripts': [
'lecture-summarizer=lecture_summarizer:run'
]
}
)
classifiers = ""
# Beyond this point, code is not project-specific
import io
import os
import re
import sys
try:
from setuptools import setup
except ImportError as exc:
raise RuntimeError("Cannot install '{0}', setuptools is missing ({1})"
.format(project['name'], exc))
project_root = os.path.abspath(os.path.dirname(__file__))
script_name = os.path.join(project_root, project['py_modules'][0] + '.py')
expected_keys = "version author author_email".split()
with io.open(script_name, encoding='utf-8') as handle:
for line in handle:
match = re.match(r"""^__({})__ += (?P<q>['"])(.+?)(?P=q)$"""
.format('|'.join(expected_keys)), line)
if match:
project[match.group(1)] = match.group(3)
# Ensure 'setup.py' is importable by other tools, to access the project's metadata
__all__ = ['project', 'project_root']
if __name__ == '__main__':
if '--metadata' in sys.argv[:2]:
import json
json.dump(project, sys.stdout, default=repr, indent=4, sort_keys=True)
sys.stdout.write('\n')
else:
setup(**project)