|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright © 2014-2015 Pierre Raybaut |
| 4 | +# Licensed under the terms of the MIT License |
| 5 | +# (see qwt/LICENSE for details) |
| 6 | + |
| 7 | +""" |
| 8 | +qwt |
| 9 | +==== |
| 10 | +
|
| 11 | +Qt Widget Tools for Python |
| 12 | +""" |
| 13 | + |
| 14 | +from __future__ import print_function |
| 15 | + |
| 16 | +import os |
| 17 | +import sys |
| 18 | +import os.path as osp |
| 19 | + |
| 20 | +from distutils.core import setup |
| 21 | +from distutils.command.build import build |
| 22 | + |
| 23 | +LIBNAME = 'qwt' |
| 24 | +from guidata import __version__ as version |
| 25 | + |
| 26 | +DESCRIPTION = 'qwt is a pure Python implementation of Qwt C++ library, using PyQt and NumPy' |
| 27 | +LONG_DESCRIPTION = '' |
| 28 | +KEYWORDS = '' |
| 29 | +CLASSIFIERS = ['Development Status :: 5 - Production/Stable', |
| 30 | + 'Topic :: Scientific/Engineering'] |
| 31 | + |
| 32 | + |
| 33 | +def get_package_data(name, extlist): |
| 34 | + """Return data files for package *name* with extensions in *extlist*""" |
| 35 | + flist = [] |
| 36 | + # Workaround to replace os.path.relpath (not available until Python 2.6): |
| 37 | + offset = len(name)+len(os.pathsep) |
| 38 | + for dirpath, _dirnames, filenames in os.walk(name): |
| 39 | + for fname in filenames: |
| 40 | + if not fname.startswith('.') and osp.splitext(fname)[1] in extlist: |
| 41 | + flist.append(osp.join(dirpath, fname)[offset:]) |
| 42 | + return flist |
| 43 | + |
| 44 | + |
| 45 | +def get_subpackages(name): |
| 46 | + """Return subpackages of package *name*""" |
| 47 | + splist = [] |
| 48 | + for dirpath, _dirnames, _filenames in os.walk(name): |
| 49 | + if osp.isfile(osp.join(dirpath, '__init__.py')): |
| 50 | + splist.append(".".join(dirpath.split(os.sep))) |
| 51 | + return splist |
| 52 | + |
| 53 | + |
| 54 | +try: |
| 55 | + import sphinx |
| 56 | +except ImportError: |
| 57 | + sphinx = None |
| 58 | + |
| 59 | +from distutils.command.build import build as dftbuild |
| 60 | + |
| 61 | +class build(dftbuild): |
| 62 | + def has_doc(self): |
| 63 | + if sphinx is None: |
| 64 | + return False |
| 65 | + setup_dir = os.path.dirname(os.path.abspath(__file__)) |
| 66 | + return os.path.isdir(os.path.join(setup_dir, 'doc')) |
| 67 | + sub_commands = dftbuild.sub_commands + [('build_doc', has_doc)] |
| 68 | + |
| 69 | +cmdclass = {'build' : build} |
| 70 | + |
| 71 | +if sphinx: |
| 72 | + from sphinx.setup_command import BuildDoc |
| 73 | + class build_doc(BuildDoc): |
| 74 | + def run(self): |
| 75 | + # make sure the python path is pointing to the newly built |
| 76 | + # code so that the documentation is built on this and not a |
| 77 | + # previously installed version |
| 78 | + build = self.get_finalized_command('build') |
| 79 | + sys.path.insert(0, os.path.abspath(build.build_lib)) |
| 80 | + try: |
| 81 | + sphinx.setup_command.BuildDoc.run(self) |
| 82 | + except UnicodeDecodeError: |
| 83 | + print("ERROR: unable to build documentation because Sphinx do not handle source path with non-ASCII characters. Please try to move the source package to another location (path with *only* ASCII characters).", file=sys.stderr) |
| 84 | + sys.path.pop(0) |
| 85 | + |
| 86 | + cmdclass['build_doc'] = build_doc |
| 87 | + |
| 88 | + |
| 89 | +setup(name=LIBNAME, version=version, |
| 90 | + download_url='http://%s.googlecode.com/files/%s-%s.zip' % ( |
| 91 | + LIBNAME, LIBNAME, version), |
| 92 | + description=DESCRIPTION, long_description=LONG_DESCRIPTION, |
| 93 | + packages=get_subpackages(LIBNAME), |
| 94 | + package_data={LIBNAME: |
| 95 | + get_package_data(LIBNAME, ('.png', '.svg', '.mo'))}, |
| 96 | + requires=["PyQt4 (>4.3)",], |
| 97 | + author = "Pierre Raybaut", |
| 98 | + author_email = 'pierre.raybaut@gmail.com', |
| 99 | +# url = 'http://www.cea.fr', |
| 100 | + classifiers=CLASSIFIERS + [ |
| 101 | + 'Operating System :: MacOS', |
| 102 | + 'Operating System :: Microsoft :: Windows', |
| 103 | + 'Operating System :: OS Independent', |
| 104 | + 'Operating System :: POSIX', |
| 105 | + 'Operating System :: Unix', |
| 106 | + 'Programming Language :: Python :: 2.6', |
| 107 | + 'Programming Language :: Python :: 2.7', |
| 108 | + 'Programming Language :: Python :: 3', |
| 109 | + ], |
| 110 | + cmdclass=cmdclass) |
0 commit comments