This repository has been archived by the owner on Aug 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathsetup.py
139 lines (113 loc) · 4.17 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
# -*- coding: utf-8 -*-
"""
profiling
~~~~~~~~~
.. image:: https://img.shields.io/travis/what-studio/profiling.svg
:target: https://travis-ci.org/what-studio/profiling
.. image:: https://img.shields.io/coveralls/what-studio/profiling.svg
:target: https://coveralls.io/r/what-studio/profiling
The profiling package is an interactive continuous Python profiler. It is
inspired from `Unity 3D <http://unity3d.com/>`_ profiler. This package
provides these features:
- Profiling statistics keep the frame stack.
- An interactive TUI profiling statistics viewer.
- Provides both of statistical and deterministic profiling.
- Utilities for remote profiling.
- Thread or greenlet aware CPU timer.
- Supports Python 2.7, 3.3, 3.4 and 3.5.
- Currently supports only Linux.
Links
'''''
GitHub:
https://github.com/what-studio/profiling
Demo:
https://asciinema.org/a/25394
"""
from __future__ import with_statement
import os
import sys
from textwrap import dedent
from setuptools import find_packages, setup
from setuptools.command.install import install
from setuptools.command.test import test
from setuptools.extension import Extension
try:
import __pypy__
except ImportError:
__pypy__ = False
# include __about__.py.
__dir__ = os.path.dirname(__file__)
about = {}
with open(os.path.join(__dir__, 'profiling', '__about__.py')) as f:
exec(f.read(), about)
# these files require specific python version or later. they will be replaced
# with a placeholder which raises a runtime error on installation.
PYTHON_VERSION_REQUIREMENTS = {
'profiling/remote/asyncio.py': (3, 4),
}
INCOMPATIBLE_PYTHON_VERSION_PLACEHOLDER = dedent('''
# -*- coding: utf-8 -*-
raise RuntimeError('Python {version} or later required.')
''').strip()
def requirements(filename):
"""Reads requirements from a file."""
with open(filename) as f:
return [x.strip() for x in f.readlines() if x.strip()]
# use pytest instead.
def run_tests(self):
raise SystemExit(__import__('pytest').main(['-v']))
# replace files which are incompatible with the current python version.
def replace_incompatible_files():
for filename, version_info in PYTHON_VERSION_REQUIREMENTS.items():
if sys.version_info >= version_info:
continue
version = '.'.join(str(v) for v in version_info)
code = INCOMPATIBLE_PYTHON_VERSION_PLACEHOLDER.format(version=version)
with open(filename, 'w') as f:
f.write(code)
test.run_tests = run_tests
run_install = install.run
install.run = lambda x: (replace_incompatible_files(), run_install(x))
# build profiling.speedup on cpython.
if __pypy__:
ext_modules = []
else:
ext_modules = [Extension('profiling.speedup', ['profiling/speedup.c'])]
setup(
name='profiling',
version=about['__version__'],
license=about['__license__'],
author=about['__author__'],
maintainer=about['__maintainer__'],
maintainer_email=about['__maintainer_email__'],
url=about['__url__'],
description=about['__description__'],
long_description=dedent(__doc__),
platforms='linux',
packages=find_packages(),
ext_modules=ext_modules,
entry_points={
'console_scripts': ['profiling = profiling.__main__:cli']
},
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Debuggers',
],
install_requires=requirements('requirements.txt'),
tests_require=requirements('test/requirements.txt'),
test_suite='...',
)