forked from MSLNZ/msl-loadlib
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
154 lines (130 loc) · 5.37 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import sys
from distutils.cmd import Command
from setuptools import setup, find_packages
from msl import loadlib
class ApiDocs(Command):
"""
A custom command that calls sphinx-apidoc
see: https://www.sphinx-doc.org/en/latest/man/sphinx-apidoc.html
"""
description = 'builds the api documentation using sphinx-apidoc'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
command = [
None, # in Sphinx < 1.7.0 the first command-line argument was parsed, in 1.7.0 it became argv[1:]
'--force', # overwrite existing files
'--module-first', # put module documentation before submodule documentation
'--separate', # put documentation for each module on its own page
'-o', './docs/_autosummary', # where to save the output files
'msl', # the path to the Python package to document
]
import sphinx
if sphinx.version_info < (1, 7):
from sphinx.apidoc import main
else:
from sphinx.ext.apidoc import main # Sphinx also changed the location of apidoc.main
command.pop(0)
main(command)
sys.exit(0)
class BuildDocs(Command):
"""
A custom command that calls sphinx-build
see: https://www.sphinx-doc.org/en/latest/man/sphinx-build.html
"""
description = 'builds the documentation using sphinx-build'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import sphinx
command = [
None, # in Sphinx < 1.7.0 the first command-line argument was parsed, in 1.7.0 it became argv[1:]
'-b', 'html', # the builder to use, e.g., create a HTML version of the documentation
'-a', # generate output for all files
'-E', # ignore cached files, forces to re-read all source files from disk
'docs', # the source directory where the documentation files are located
'./docs/_build/html', # where to save the output files
]
if sphinx.version_info < (1, 7):
from sphinx import build_main
else:
from sphinx.cmd.build import build_main # Sphinx also changed the location of build_main
command.pop(0)
build_main(command)
sys.exit(0)
def read(filename):
with open(filename) as fp:
text = fp.read()
return text
# auto generate the MANIFEST.in file based on the platform
if 'sdist' not in sys.argv:
with open('MANIFEST.in', 'w') as f:
f.write('# This file is automatically generated. Do not modify.\n')
f.write('recursive-include msl/examples/loadlib *.jar *.class\n')
f.write('include msl/loadlib/py4j-wrapper.jar\n')
f.write('include msl/examples/loadlib/dotnet_lib32.dll\n')
f.write('include msl/examples/loadlib/dotnet_lib64.dll\n')
f.write('recursive-include msl/loadlib {}*\n'.format(loadlib.SERVER_FILENAME))
f.write('recursive-include msl/examples/loadlib *{}\n'.format(loadlib.DEFAULT_EXTENSION))
if loadlib.IS_WINDOWS:
f.write('include msl/loadlib/verpatch.exe\n')
else:
with open('MANIFEST.in', 'w') as f:
f.write('# This file is automatically generated. Do not modify.\n')
f.write('recursive-include msl *.cpp *.h *.cs *.f90 *.java *.jar *.class *.so *.dll *.txt\n')
f.write('include msl/loadlib/verpatch.exe\n')
testing = {'test', 'tests', 'pytest'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if testing else []
needs_sphinx = {'doc', 'docs', 'apidoc', 'apidocs', 'build_sphinx'}.intersection(sys.argv)
sphinx = ['sphinx', 'sphinx_rtd_theme'] if needs_sphinx else []
tests_require = ['pytest', 'pytest-cov', 'pythonnet', 'py4j']
if sys.version_info < (3, 4):
tests_require += ['pathlib']
if loadlib.IS_WINDOWS:
tests_require += ['comtypes']
setup(
name='msl-loadlib',
version=loadlib.__version__,
author=loadlib.__author__,
url='https://github.com/MSLNZ/msl-loadlib',
description='Load a shared library (and access a 32-bit library from 64-bit Python)',
long_description=read('README.rst'),
license='MIT',
platforms='any',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
],
setup_requires=sphinx + pytest_runner,
tests_require=tests_require,
install_requires=[],
extras_require = {
'clr': ['pythonnet'],
'java': ['py4j'],
'com': ['comtypes'],
'all': ['pythonnet', 'py4j', 'comtypes'],
},
cmdclass={'docs': BuildDocs, 'apidocs': ApiDocs},
packages=find_packages(include=('msl*',)),
include_package_data=True,
)