2012-09-10 22:00:59 +00:00
|
|
|
from distutils.core import setup
|
2012-12-27 04:35:23 +00:00
|
|
|
import distutils.dir_util
|
2013-12-15 18:17:26 +00:00
|
|
|
import os, sys, re
|
2013-12-01 15:23:45 +00:00
|
|
|
from subprocess import check_output
|
2012-09-13 14:12:59 +00:00
|
|
|
|
|
|
|
## generate list of all sub-packages
|
2012-12-27 04:35:23 +00:00
|
|
|
path = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
n = len(path.split(os.path.sep))
|
|
|
|
subdirs = [i[0].split(os.path.sep)[n:] for i in os.walk(os.path.join(path, 'pyqtgraph')) if '__init__.py' in i[2]]
|
2012-12-26 22:51:52 +00:00
|
|
|
all_packages = ['.'.join(p) for p in subdirs] + ['pyqtgraph.examples']
|
2012-09-10 22:00:59 +00:00
|
|
|
|
2012-12-27 04:35:23 +00:00
|
|
|
|
|
|
|
## Make sure build directory is clean before installing
|
|
|
|
buildPath = os.path.join(path, 'build')
|
|
|
|
if os.path.isdir(buildPath):
|
|
|
|
distutils.dir_util.remove_tree(buildPath)
|
|
|
|
|
2013-12-01 15:23:45 +00:00
|
|
|
|
|
|
|
## Determine current version string
|
2013-12-15 18:17:26 +00:00
|
|
|
initfile = os.path.join(path, 'pyqtgraph', '__init__.py')
|
|
|
|
init = open(initfile).read()
|
2013-12-01 15:23:45 +00:00
|
|
|
m = re.search(r'__version__ = (\S+)\n', init)
|
2013-12-15 18:17:26 +00:00
|
|
|
if m is None or len(m.groups()) != 1:
|
|
|
|
raise Exception("Cannot determine __version__ from init file: '%s'!" % initfile)
|
2013-12-01 15:23:45 +00:00
|
|
|
version = m.group(1).strip('\'\"')
|
2013-12-15 18:01:37 +00:00
|
|
|
initVersion = version
|
2013-12-01 15:23:45 +00:00
|
|
|
|
2013-12-15 18:17:26 +00:00
|
|
|
# If this is a git checkout, try to generate a more decriptive version string
|
|
|
|
try:
|
|
|
|
if os.path.isdir(os.path.join(path, '.git')):
|
|
|
|
def gitCommit(name):
|
|
|
|
commit = check_output(['git', 'show', name], universal_newlines=True).split('\n')[0]
|
|
|
|
assert commit[:7] == 'commit '
|
|
|
|
return commit[7:]
|
2013-12-01 15:23:45 +00:00
|
|
|
|
2013-12-15 18:17:26 +00:00
|
|
|
# Find last tag matching "pyqtgraph-.*"
|
|
|
|
tagNames = check_output(['git', 'tag'], universal_newlines=True).strip().split('\n')
|
|
|
|
while True:
|
|
|
|
if len(tagNames) == 0:
|
|
|
|
raise Exception("Could not determine last tagged version.")
|
|
|
|
lastTagName = tagNames.pop()
|
|
|
|
if re.match(r'pyqtgraph-.*', lastTagName):
|
|
|
|
break
|
|
|
|
|
|
|
|
# is this commit an unchanged checkout of the last tagged version?
|
|
|
|
lastTag = gitCommit(lastTagName)
|
|
|
|
head = gitCommit('HEAD')
|
|
|
|
if head != lastTag:
|
2013-12-16 08:25:38 +00:00
|
|
|
branch = re.search(r'\* (.*)', check_output(['git', 'branch'], universal_newlines=True)).group(1)
|
2013-12-15 18:17:26 +00:00
|
|
|
version = version + "-%s-%s" % (branch, head[:10])
|
|
|
|
|
|
|
|
# any uncommitted modifications?
|
|
|
|
modified = False
|
|
|
|
status = check_output(['git', 'status', '-s'], universal_newlines=True).strip().split('\n')
|
|
|
|
for line in status:
|
|
|
|
if line[:2] != '??':
|
|
|
|
modified = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if modified:
|
|
|
|
version = version + '+'
|
|
|
|
sys.stderr.write("Detected git commit; will use version string: '%s'\n" % version)
|
|
|
|
except:
|
|
|
|
version = initVersion
|
|
|
|
sys.stderr.write("This appears to be a git checkout, but an error occurred "
|
|
|
|
"while attempting to determine a version string for the "
|
|
|
|
"current commit.\nUsing the unmodified version string "
|
|
|
|
"instead: '%s'\n" % version)
|
|
|
|
sys.excepthook(*sys.exc_info())
|
2013-12-01 15:23:45 +00:00
|
|
|
|
|
|
|
|
2013-12-15 18:01:37 +00:00
|
|
|
import distutils.command.build
|
|
|
|
|
|
|
|
class Build(distutils.command.build.build):
|
|
|
|
def run(self):
|
|
|
|
ret = distutils.command.build.build.run(self)
|
|
|
|
|
|
|
|
# If the version in __init__ is different from the automatically-generated
|
|
|
|
# version string, then we will update __init__ in the build directory
|
|
|
|
global path, version, initVersion
|
|
|
|
if initVersion == version:
|
|
|
|
return ret
|
|
|
|
|
|
|
|
initfile = os.path.join(path, self.build_lib, 'pyqtgraph', '__init__.py')
|
2013-12-15 18:17:26 +00:00
|
|
|
if not os.path.isfile(initfile):
|
|
|
|
sys.stderr.write("Warning: setup detected a git install and attempted "
|
|
|
|
"to generate a descriptive version string; however, "
|
|
|
|
"the expected build file at %s was not found. "
|
|
|
|
"Installation will use the original version string "
|
|
|
|
"%s instead.\n" % (initfile, initVersion)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
data = open(initfile, 'r').read()
|
|
|
|
open(initfile, 'w').write(re.sub(r"__version__ = .*", "__version__ = '%s'" % version, data))
|
2013-12-15 18:01:37 +00:00
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2012-09-10 22:00:59 +00:00
|
|
|
setup(name='pyqtgraph',
|
2013-12-01 15:23:45 +00:00
|
|
|
version=version,
|
2013-12-15 18:01:37 +00:00
|
|
|
cmdclass={'build': Build},
|
2012-09-10 22:00:59 +00:00
|
|
|
description='Scientific Graphics and GUI Library for Python',
|
2012-12-07 14:31:21 +00:00
|
|
|
long_description="""\
|
2013-11-24 16:06:53 +00:00
|
|
|
PyQtGraph is a pure-python graphics and GUI library built on PyQt4/PySide and
|
|
|
|
numpy.
|
2012-12-07 14:31:21 +00:00
|
|
|
|
2013-11-24 16:06:53 +00:00
|
|
|
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.
|
2012-12-07 14:31:21 +00:00
|
|
|
""",
|
2012-09-10 22:00:59 +00:00
|
|
|
license='MIT',
|
2012-12-05 02:02:05 +00:00
|
|
|
url='http://www.pyqtgraph.org',
|
2012-09-10 22:00:59 +00:00
|
|
|
author='Luke Campagnola',
|
|
|
|
author_email='luke.campagnola@gmail.com',
|
2012-09-13 14:12:59 +00:00
|
|
|
packages=all_packages,
|
2012-12-26 22:51:52 +00:00
|
|
|
package_dir={'pyqtgraph.examples': 'examples'}, ## install examples along with the rest of the source
|
|
|
|
#package_data={'pyqtgraph': ['graphicsItems/PlotItem/*.png']},
|
2012-12-07 14:31:21 +00:00
|
|
|
classifiers = [
|
|
|
|
"Programming Language :: Python",
|
2012-12-27 04:35:23 +00:00
|
|
|
"Programming Language :: Python :: 2",
|
|
|
|
"Programming Language :: Python :: 2.6",
|
|
|
|
"Programming Language :: Python :: 2.7",
|
2012-12-07 14:31:21 +00:00
|
|
|
"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",
|
|
|
|
],
|
2012-12-27 15:31:08 +00:00
|
|
|
install_requires = [
|
2012-12-26 22:51:52 +00:00
|
|
|
'numpy',
|
|
|
|
'scipy',
|
|
|
|
],
|
2012-09-10 22:00:59 +00:00
|
|
|
)
|
|
|
|
|