forked from ASPP/grader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
54 lines (49 loc) · 1.78 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
# -*- coding: utf-8 -*-
import ast
import os
from setuptools import setup, find_packages
# this file is used to pick the relevant metadata for setup.py
INITFILE = os.path.join('grader', '__init__.py')
# the directory we are in
CWD = os.path.abspath(os.path.dirname(__file__))
def parse_keyword(key):
"""Get metadata from grader/__init__.py using an AST"""
with open(os.path.join(CWD, INITFILE), encoding='utf-8') as f:
ast_tree = ast.parse(f.read())
for node in ast.walk(ast_tree):
if type(node) is ast.Assign:
try:
if node.targets[0].id == key:
return node.value.s
except:
pass
# return "not available" if we didn't find the variable
return 'N/A'
# pick the relevant keywords from the __init__.py file
metadata_vars = ('name', 'version', 'description', 'author', 'license', 'url')
metadata = dict((var, parse_keyword('__%s__'%var)) for var in metadata_vars)
# Get the long description from the README file
with open(os.path.join(CWD, 'README.md'), encoding='utf-8') as f:
metadata['long_description'] = f.read()
setup(
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Programming Language :: Python :: 3',
],
keywords='grading applications',
packages=find_packages(),
install_requires=['pytest'],
package_data={
#'sample': ['package_data.dat'],
},
entry_points={
'console_scripts': [
'grader=grader.grader:main',
],
},
**metadata
)