forked from python-microscope/microscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
134 lines (112 loc) · 3.96 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## Copyright (C) 2016 David Pinto <[email protected]>
##
## Copying and distribution of this file, with or without modification,
## are permitted in any medium without royalty provided the copyright
## notice and this notice are preserved. This file is offered as-is,
## without any warranty.
import setuptools
import setuptools.command.sdist
import sys
import sphinx.setup_command
try: # In sphinx 1.7, apidoc was moved to the ext subpackage
import sphinx.ext.apidoc as apidoc
except ImportError:
import sphinx.apidoc as apidoc
try: # In Python 3.3, mock was merged into unittest package
import unittest.mock as mock
except ImportError:
import mock
import microscope.testsuite.libs
project_name = 'microscope'
project_version = '0.1.0+dev'
extra_requires = []
## The enum34 package will cause conflicts with the builtin enum
## package so don't require it. See
## https://bitbucket.org/stoneleaf/enum34/issues/19/enum34-isnt-compatible-with-python-36#comment-36515102
if sys.version_info < (3, 4):
extra_requires += ["enum34"]
## Shadow the sphinx provided command, in order to run sphinx-apidoc
## before sphinx-build. This builds the rst files with the actual
## package inline documentation.
class BuildDoc(sphinx.setup_command.BuildDoc):
@mock.patch('ctypes.CDLL', new=microscope.testsuite.libs.CDLL)
def run(self):
apidoc.main(["sphinx-apidoc",
"--separate", # each module on its own page
"--module-first",
"--output-dir", "doc/api",
"microscope"])
sphinx.setup_command.BuildDoc.run(self)
## Modify the sdist command class to include extra files in the source
## distribution. Seems a bit ridiculous that we have to do this but
## the only alternative is to have a MANIFEST file and we don't want
## to have yet another configuration file.
##
## The package_data (from setuptools) and data_files (from distutils)
## options are for files that will be installed and we don't want to
## install this files, we just want them on the source distribution
## for user information.
manifest_files = [
"COPYING",
"NEWS",
"README",
]
class sdist(setuptools.command.sdist.sdist):
def make_distribution(self):
self.filelist.extend(manifest_files)
setuptools.command.sdist.sdist.make_distribution(self)
setuptools.setup(
name = project_name,
version = project_version,
description = "An extensible microscope hardware interface.",
license = "GPL-3.0+",
## Do not use author_email because that won't play nice once there
## are multiple authors.
author = "Mick Phillips <[email protected]>",
url = "https://github.com/MicronOxford/microscope",
packages = [
"microscope",
"microscope.cameras",
"microscope.lasers",
"microscope.testsuite",
"microscope._wrappers",
],
install_requires = [
"numpy",
"Pyro4",
"pyserial",
## We use six instead of anything else because we are already
## indirectly dependent on it due to serpent which is a Pyro4
## dependency.
"six",
] + extra_requires,
entry_points = {
'console_scripts' : [
'deviceserver = microscope.deviceserver:__main__',
]
},
## https://pypi.python.org/pypi?:action=list_classifiers
classifiers = [
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
],
test_suite="microscope.testsuite",
command_options = {
'build_sphinx' : {
## This seems a bit silly but the dict for command_options must
## be of the form '(option, (source, value))' where source is
## the filename where that information came from.
'project': ('setup.py', project_name),
'version': ('setup.py', project_version),
'release': ('setup.py', project_version),
'source_dir' : ('setup.py', 'doc'),
},
},
cmdclass = {
'build_sphinx' : BuildDoc,
'sdist' : sdist,
},
)