-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
190 lines (155 loc) · 6.09 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import json
import os
import re
import subprocess
from setuptools import setup, find_packages, Command
from mopack.app_version import version
root_dir = os.path.abspath(os.path.dirname(__file__))
class Coverage(Command):
description = 'run tests with code coverage'
user_options = [
('test-suite=', 's',
"test suite to run (e.g. 'some_module.test_suite')"),
]
def initialize_options(self):
self.test_suite = None
def finalize_options(self):
pass
def run(self):
env = dict(os.environ)
pythonpath = os.path.join(root_dir, 'test', 'scripts')
if env.get('PYTHONPATH'):
pythonpath += os.pathsep + env['PYTHONPATH']
env.update({
# Set the top srcdir so that our coverage configuration can find
# the source files, even if we run `mopack` from another directory.
'TOP_SRCDIR': root_dir,
'PYTHONPATH': pythonpath,
'COVERAGE_FILE': os.path.join(root_dir, '.coverage'),
'COVERAGE_PROCESS_START': os.path.join(root_dir, 'setup.cfg'),
})
subprocess.run(['coverage', 'erase'], check=True)
subprocess.run(
['coverage', 'run', 'setup.py', 'test'] +
(['-q'] if self.verbose == 0 else []) +
(['-s', self.test_suite] if self.test_suite else []),
env=env, check=True
)
subprocess.run(['coverage', 'combine'], check=True,
stdout=subprocess.DEVNULL)
custom_cmds = {
'coverage': Coverage,
}
try:
from verspec.python import Version
class DocServe(Command):
description = 'serve the documentation locally'
user_options = [
('working', 'w', 'use the documentation in the working directory'),
('dev-addr=', None, 'address to host the documentation on'),
]
def initialize_options(self):
self.working = False
self.dev_addr = '0.0.0.0:8000'
def finalize_options(self):
pass
def run(self):
cmd = 'mkdocs' if self.working else 'mike'
subprocess.run([
cmd, 'serve', '--dev-addr=' + self.dev_addr
], check=True)
class DocDeploy(Command):
description = 'push the documentation to GitHub'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
v = Version(version)
alias = 'dev' if v.is_devrelease else 'latest'
title = '{} ({})'.format(v.base_version, alias)
short_version = '{}.{}'.format(*v.release[:2])
try:
info = json.loads(subprocess.run(
['mike', 'list', '-j', alias], universal_newlines=True,
check=True, stdout=subprocess.PIPE
).stdout)
except subprocess.CalledProcessError:
info = None
if info and info['version'] != short_version:
t = re.sub(r' \({}\)$'.format(re.escape(alias)), '',
info['title'])
subprocess.run(['mike', 'retitle', info['version'], t],
check=True)
subprocess.run(['mike', 'deploy', '-ut', title, short_version,
alias], check=True)
custom_cmds['doc_serve'] = DocServe
custom_cmds['doc_deploy'] = DocDeploy
except ImportError:
pass
with open(os.path.join(root_dir, 'README.md'), 'r') as f:
# Read from the file and strip out the badges.
long_desc = re.sub(r'(^# mopack)\n\n(.+\n)*', r'\1', f.read())
setup(
name='mopack',
version=version,
description='A multiple-origin package manager',
long_description=long_desc,
long_description_content_type='text/markdown',
keywords='package manager',
url='https://github.com/jimporter/mopack',
author='Jim Porter',
author_email='itsjimporter@gmail.com',
license='BSD-3-Clause',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
packages=find_packages(exclude=['test', 'test.*']),
package_data={'': ['defaults/*.yml']},
install_requires=['colorama', 'pyparsing >= 3.0', 'pyyaml', 'setuptools'],
extras_require={
'dev': ['bfg9000', 'conan', 'coverage', 'flake8 >= 3.6',
'flake8-quotes', 'mike >= 2.0.0',
'mkdocs-bootswatch-classic >= 1.0', 'verspec', 'shtab'],
'test': ['bfg9000', 'conan', 'coverage', 'flake8 >= 3.6',
'flake8-quotes', 'shtab'],
},
entry_points={
'console_scripts': [
'mopack=mopack.driver:main'
],
'mopack.origins': [
'apt=mopack.origins.apt:AptPackage',
'conan=mopack.origins.conan:ConanPackage',
'directory=mopack.origins.sdist:DirectoryPackage',
'git=mopack.origins.sdist:GitPackage',
'system=mopack.origins.system:SystemPackage',
'tarball=mopack.origins.sdist:TarballPackage',
],
'mopack.builders': [
'bfg9000=mopack.builders.bfg9000:Bfg9000Builder',
'cmake=mopack.builders.cmake:CMakeBuilder',
'custom=mopack.builders.custom:CustomBuilder',
'ninja=mopack.builders.ninja:NinjaBuilder',
'none=mopack.builders.none:NoneBuilder',
],
'mopack.linkages': [
'path=mopack.linkages.path_system:PathLinkage',
'pkg_config=mopack.linkages.pkg_config:PkgConfigLinkage',
'system=mopack.linkages.path_system:SystemLinkage',
],
},
test_suite='test',
cmdclass=custom_cmds,
)