-
Notifications
You must be signed in to change notification settings - Fork 24
/
setup.py
140 lines (110 loc) · 3.46 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
import sys, os
import unittest
from setuptools import setup, find_packages
from distutils.command.clean import clean
from distutils.core import Command
from distutils.dir_util import remove_tree
HAS_SPHINX=False
try:
from sphinx.setup_command import BuildDoc
HAS_SPHINX=True
class Doctest(Command):
description = 'Run doctests with Sphinx'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from sphinx.application import Sphinx
sph = Sphinx('./docs', # source directory
'./docs', # directory containing conf.py
'./docs/_build', # output directory
'./docs/_build/doctrees', # doctree directory
'doctest') # finally, specify the doctest builder
sph.build()
except ImportError:
pass
# bleson/VERSION file must follow: https://www.python.org/dev/peps/pep-0440/
version_file = open(os.path.join('bleson', 'VERSION'))
version = version_file.read().strip()
# support overriding version from env
version=os.getenv('MODULE_VERSION', version)
if not version:
raise ValueError("Version not set")
print("Version={}".format(version))
def _os_run_chk(cmd):
print("CMD={}".format(cmd))
rc = os.system(cmd)
print("RC ={}".format(rc))
if rc != 0:
sys.exit(1)
class SimpleCommand(Command):
# default some Command abstract class boilerplate for subclasses
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
class SuperClean(clean):
def run(self):
self.all = True
super().run()
# remove_tree doesn't ignore errors. liek it says it should..
if os.path.exists('sdist'):
remove_tree('sdist')
if os.path.exists('dist'):
remove_tree('dist')
class Tag(SimpleCommand):
def run(self):
_os_run_chk("git tag -a RELEASE_%s -m 'Release version %s'" % (version, version))
_os_run_chk("git push --tags")
class Publish(SimpleCommand):
def run(self):
# TODO: use a Pythonic method
_os_run_chk("twine upload dist/*")
cmdclass={
'clean': SuperClean,
'publish': Publish,
'tag': Tag,
}
if HAS_SPHINX:
cmdclass['doc'] = BuildDoc
cmdclass['doctest'] = Doctest
setup(
name='bleson',
version=version,
packages= find_packages(),
url='https://github.com/TheCellule/python-bleson',
license='MIT',
author='TheCellule',
author_email='[email protected]',
description='Bluetooth LE Library',
extras_require = {
':platform_system=="Windows"': [
'blesonwin'
],
':platform_system=="Darwin"': [
'pyobjc'
]
},
test_suite='tests',
cmdclass=cmdclass,
command_options={
'doc': {
'build_dir': ('setup.py', 'docs/_build'),
},
},
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
]
)