generated from opencadc/blank2caom2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·101 lines (84 loc) · 3.22 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
100
101
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import glob
import os
import sys
from setuptools.command.test import test as TestCommand
from setuptools import find_packages
from setuptools import setup
# 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.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)
# Note that requires and provides should not be included in the call to
# ``setup``, since these are now deprecated. See this link for more details:
# https://groups.google.com/forum/#!topic/astropy-dev/urYO8ckB2uM
setup(name=PACKAGENAME,
version=VERSION,
description=DESCRIPTION,
scripts=scripts,
install_requires=metadata.get('install_requires', '').strip().split(),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
long_description=readme(),
zip_safe=False,
use_2to3=False,
setup_requires=[],
entry_points=entry_points,
python_requires='>=3.11',
packages=find_packages(),
package_data={PACKAGENAME: ['data/*']},
data_files=[('.config', ['config/config.yml', 'config/state.yml'])],
classifiers=[
'Natural Language :: English',
'License :: OSI Approved :: GNU Affero General Public License v3',
'Programming Language :: Python',
'Programming Language :: Python :: 3.11'
],
cmdclass = {
'coverage': PyTest,
}
)