forked from opencadc/caom2pipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·99 lines (81 loc) · 3.03 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
93
94
95
96
97
98
99
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import glob
import os
import sys
import imp
from setuptools.command.test import test as TestCommand
from setuptools import find_packages
from setuptools import setup
import subprocess
# read the README.md file and return as string.
def readme():
with open('README.md') as r_obj:
return r_obj.read()
# Get some values from the setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
conf.optionxform=str
conf.read(['setup.cfg'])
metadata = dict(conf.items('metadata'))
PACKAGENAME = metadata.get('package_name', 'packagename')
DESCRIPTION = metadata.get('description', 'CADC package')
AUTHOR = metadata.get('author', 'CADC')
AUTHOR_EMAIL = metadata.get('author_email', '[email protected]')
LICENSE = metadata.get('license', 'unknown')
URL = metadata.get('url', 'http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca')
# VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
VERSION = metadata.get('version', 'none')
# generate the version file
with open(os.path.join(PACKAGENAME, 'version.py'), 'w') as f:
f.write('version = \'{}\'\n'.format(VERSION))
# Treat everything in scripts except README.md as a script to be installed
scripts = [fname for fname in glob.glob(os.path.join('scripts', '*'))
if os.path.basename(fname) != 'README.md']
# Define entry points for command-line scripts
entry_points = {'console_scripts': []}
entry_point_list = conf.items('entry_points')
for entry_point in entry_point_list:
entry_points['console_scripts'].append('{0} = {1}'.format(entry_point[0],
entry_point[1]))
# add the --cov option to the test command
class PyTest(TestCommand):
"""class py.test for the testing
"""
user_options = []
def __init__(self, dist, **kw):
TestCommand.__init__(self, dist, **kw)
self.pytest_args = ['--cov', PACKAGENAME]
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
err_no = pytest.main(self.pytest_args)
sys.exit(err_no)
install_requires=metadata.get('install_requires', '').strip().split()
setup(name=PACKAGENAME,
version=VERSION,
description=DESCRIPTION,
scripts=scripts,
install_requires=install_requires,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
long_description=readme(),
zip_safe=False,
use_2to3=False,
setup_requires=['pytest-runner'],
entry_points=entry_points,
packages=find_packages(),
package_data={PACKAGENAME: ['data/*', 'tests/data/*', '*/data/*', '*/tests/data/*']},
classifiers=[
'Natural Language :: English',
'License :: OSI Approved :: GNU Affero General Public License v3',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6'
],
cmdclass = {'coverage': PyTest}
)