forked from pympler/pympler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
105 lines (80 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
"""Setup script for Pympler.
To build, install and test Pympler and to try Pympler
before building and installing it.
The HTML documentation is in the doc/ directory. Point
your browser to the ./doc/html/index.html file.
"""
import sys
def _not_supported(why):
print('NotImplementedError: ' + why + '.')
sys.exit(1)
if sys.hexversion < 0x3060000:
_not_supported('Pympler requires Python 3.6 or newer')
import os
from setuptools import Command
from setuptools import setup
from setuptools import Distribution
from subprocess import run
class BaseTestCommand(Command):
"""Base class for the pre and the post installation commands. """
user_options = []
def initialize_options(self):
self.param = None
def finalize_options(self):
pass
def run(self):
args = [sys.executable, # this Python binary
os.path.join('test', 'runtest.py'),
self.param, '-verbose', '3']
args.extend(sys.argv[2:])
sys.exit(run(args).returncode)
class PreinstallTestCommand(BaseTestCommand):
description = "run pre-installation tests"
def initialize_options(self):
self.param = '-pre-install'
class PostinstallTestCommand(BaseTestCommand):
description = "run post-installation tests"
def initialize_options(self):
self.param = '-post-install'
def run_setup(include_tests=0):
tests = []
if include_tests:
tests = ['test', 'test.asizeof', 'test.tracker', 'test.muppy',
'test.gui']
setup(packages=['pympler', 'pympler.util'] + tests,
package_data={'pympler': ['templates/*.html',
'templates/*.tpl',
'templates/*.js',
'templates/*.css',
'static/*.js',
'py.typed']},
platforms=['any'],
classifiers=['Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'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',
'Topic :: Software Development :: Bug Tracking',
],
cmdclass={'try': PreinstallTestCommand,
'test': PostinstallTestCommand,
}
)
try: # hack Pympler commands into setup.py help output
Distribution.common_usage += """
Pympler commands
setup.py try try Pympler before installation
setup.py test test Pympler after installation
"""
except AttributeError:
pass
# Only include tests if creating a distribution package
# (i.e. do not install the tests).
run_setup('sdist' in sys.argv)