forked from pyqtgraph/pyqtgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
148 lines (123 loc) · 5.03 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
DESCRIPTION = """\
PyQtGraph is a pure-python graphics and GUI library built on PyQt4/PySide and
numpy.
It is intended for use in mathematics / scientific / engineering applications.
Despite being written entirely in python, the library is very fast due to its
heavy leverage of numpy for number crunching, Qt's GraphicsView framework for
2D display, and OpenGL for 3D display.
"""
setupOpts = dict(
name='pyqtgraph',
description='Scientific Graphics and GUI Library for Python',
long_description=DESCRIPTION,
license='MIT',
url='https://www.pyqtgraph.org',
author='Luke Campagnola',
author_email='[email protected]',
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",
"Environment :: Other Environment",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Software Development :: User Interfaces",
],
)
import distutils.dir_util
from distutils.command import build
import os, sys, re
try:
import setuptools
from setuptools import setup
from setuptools.command import install
except ImportError:
sys.stderr.write("Warning: could not import setuptools; falling back to distutils.\n")
from distutils.core import setup
from distutils.command import install
# Work around mbcs bug in distutils.
# https://bugs.python.org/issue10945
import codecs
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
codecs.register(func)
path = os.path.split(__file__)[0]
sys.path.insert(0, os.path.join(path, 'tools'))
import setupHelpers as helpers
## generate list of all sub-packages
allPackages = (helpers.listAllPackages(pkgroot='pyqtgraph') +
['pyqtgraph.'+x for x in helpers.listAllPackages(pkgroot='examples')])
## Decide what version string to use in the build
version, forcedVersion, gitVersion, initVersion = helpers.getVersionStrings(pkg='pyqtgraph')
class Build(build.build):
"""
* Clear build path before building
"""
def run(self):
global path
## Make sure build directory is clean
buildPath = os.path.join(path, self.build_lib)
if os.path.isdir(buildPath):
distutils.dir_util.remove_tree(buildPath)
ret = build.build.run(self)
class Install(install.install):
"""
* Check for previously-installed version before installing
* Set version string in __init__ after building. This helps to ensure that we
know when an installation came from a non-release code base.
"""
def run(self):
global path, version, initVersion, forcedVersion, installVersion
name = self.config_vars['dist_name']
path = os.path.join(self.install_libbase, 'pyqtgraph')
if os.path.exists(path):
raise Exception("It appears another version of %s is already "
"installed at %s; remove this before installing."
% (name, path))
print("Installing to %s" % path)
rval = install.install.run(self)
# If the version in __init__ is different from the automatically-generated
# version string, then we will update __init__ in the install directory
if initVersion == version:
return rval
try:
initfile = os.path.join(path, '__init__.py')
data = open(initfile, 'r').read()
open(initfile, 'w').write(re.sub(r"__version__ = .*", "__version__ = '%s'" % version, data))
installVersion = version
except:
sys.stderr.write("Warning: Error occurred while setting version string in build path. "
"Installation will use the original version string "
"%s instead.\n" % (initVersion)
)
if forcedVersion:
raise
installVersion = initVersion
sys.excepthook(*sys.exc_info())
return rval
setup(
version=version,
cmdclass={'build': Build,
'install': Install,
'deb': helpers.DebCommand,
'test': helpers.TestCommand,
'debug': helpers.DebugCommand,
'mergetest': helpers.MergeTestCommand,
'style': helpers.StyleCommand},
packages=allPackages,
package_dir={'pyqtgraph.examples': 'examples'}, ## install examples along with the rest of the source
package_data={'pyqtgraph.examples': ['optics/*.gz', 'relativity/presets/*.cfg']},
install_requires = [
'numpy',
],
**setupOpts
)