-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
110 lines (91 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
102
103
104
105
106
107
108
109
110
# -*- coding: utf-8 -*-
import os
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
from setuptools.command.install import install
from setuptools.command.develop import develop
import distutils.cmd
# modifications to develop and install, based on post here:
# https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
develop.run(self)
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
Documentation.run(self)
class PyTestNoSkip(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
# use pytest plugin to force error if a test is skipped
self.test_args = ['--error-for-skips']
self.test_suite = True
def run_tests(self):
import pytest
params = {"args": self.test_args}
params["args"] += ["--junitxml", "test-report/output.xml"]
errcode = pytest.main(self.test_args)
sys.exit(errcode)
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
params = {"args": self.test_args}
params["args"] += ["--junitxml", "test-report/output.xml"]
errcode = pytest.main(self.test_args)
sys.exit(errcode)
class Documentation(distutils.cmd.Command):
description = '''Build the documentation with Sphinx.
sphinx-apidoc is run for automatic generation of the sources.
sphinx-build then creates the html from these sources.'''
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
command = 'sphinx-apidoc -f -o docs/source pysilcam/ --separate'
os.system(command)
command = 'sphinx-build -b html ./docs/source ./docs/build'
os.system(command)
sys.exit()
def read(fname):
with open(fname) as fp:
content = fp.read()
return content
setup(
name='PySilCam',
description='A Python interface to the SilCam.',
long_description=read('README.md'),
author='Emlyn Davies',
author_email='emlyn.davies@sintef.no',
zip_safe=False,
keywords='silcam',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
],
packages=['pysilcam'],
entry_points={
'console_scripts': [
'silcam = pysilcam.__main__:silcam',
'silcam-report = pysilcam.silcreport:silcreport',
'silcam-track = pysilcam.tracking.track:silctrack',
'silcam-gui = pysilcam.silcamgui.silcamgui:main',
]
},
cmdclass={'test': PyTest,
'test_noskip': PyTestNoSkip,
'build_sphinx': Documentation,
'develop': PostDevelopCommand,
'install': PostInstallCommand}
)