File: setup.py

package info (click to toggle)
guiqwt 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,492 kB
  • sloc: python: 26,698; cpp: 1,673; makefile: 22
file content (261 lines) | stat: -rw-r--r-- 8,420 bytes parent folder | download
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# -*- coding: utf-8 -*-
#
# Copyright © 2009-2015 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guiqwt/__init__.py for details)

"""
guiqwt
======

Copyright © 2009-2015 CEA
Pierre Raybaut
Licensed under the terms of the CECILL License
(see guiqwt/__init__.py for details)
"""

# Building extensions:
# python setup.py build_ext -c mingw32 --inplace

import setuptools  # analysis:ignore
import numpy
import sys
import os
import os.path as osp
import subprocess
from numpy.distutils.core import setup, Extension
from guidata.utils import get_subpackages, get_package_data, cythonize_all


LIBNAME = "guiqwt"
__description__ = (
    "guiqwt is a set of tools for curve and image plotting (extension to PythonQwt)"
)

# Remove module from list to allow building doc from build dir
# del sys.modules["guiqwt"]

LONG_DESCRIPTION = """\
guiqwt: Python tools for curve and image plotting
=================================================

.. image:: https://raw.githubusercontent.com/PierreRaybaut/guiqwt/master/doc/images/panorama.png

See `documentation`_ for more details on the library and `changelog`_ for
recent history of changes.

Copyright © 2009-2020 CEA, Pierre Raybaut, licensed under the terms of the
`CECILL License`_.

.. _documentation: https://guiqwt.readthedocs.io/en/latest/
.. _changelog: https://github.com/PierreRaybaut/guiqwt/blob/master/CHANGELOG.md
.. _CECILL License: https://github.com/PierreRaybaut/guiqwt/blob/master/Licence_CeCILL_V2-en.txt


Overview
--------

Based on `PythonQwt`_ (a pure Python/PyQt reimplementation of the curve
plotting Qwt C++ library, included in guiqwt base source code) and on the
scientific modules NumPy and SciPy, ``guiqwt`` is a Python library providing
efficient 2D data-plotting features (curve/image visualization and related
tools) for interactive computing and signal/image processing application
development. It is based on Qt graphical user interfaces library, and
currently supports both ``PyQt5`` and ``PySide2``.

Extension to `PythonQwt`_:

* set of tools for curve and image plotting
* GUI-based application development helpers

.. _PythonQwt: https://pypi.python.org/pypi/PythonQwt


Building, installation, ...
---------------------------

The following packages are **required**: `PyQt5`_,
`PythonQwt`_, `guidata`_, `NumPy`_, `SciPy`_ and `Pillow`_.

.. _PyQt5: https://pypi.python.org/pypi/PyQt5
.. _PythonQwt: https://pypi.python.org/pypi/PythonQwt
.. _guidata: https://pypi.python.org/pypi/guidata
.. _NumPy: https://pypi.python.org/pypi/NumPy
.. _SciPy: https://pypi.python.org/pypi/SciPy
.. _Pillow: https://pypi.python.org/pypi/Pillow

See the `README`_ and `documentation`_ for more details.

.. _README: https://github.com/PierreRaybaut/guiqwt/blob/master/README.md
"""

KEYWORDS = ""


def build_chm_doc(libname):
    """Return CHM documentation file (on Windows only), which is copied under
    {PythonInstallDir}\Doc, hence allowing Spyder to add an entry for opening
    package documentation in "Help" menu. This has no effect on a source
    distribution."""
    args = "".join(sys.argv)
    if "--no-doc" in sys.argv:
        sys.argv.remove("--no-doc")
        return
    if (
        os.name == "nt"
        and ("bdist" in args or "build" in args)
        and "--inplace" not in args
    ):
        try:
            import sphinx  # analysis:ignore
        except ImportError:
            print(
                "Warning: `sphinx` is required to build documentation", file=sys.stderr
            )
            return
        hhc_base = r"C:\Program Files%s\HTML Help Workshop\hhc.exe"
        for hhc_exe in (hhc_base % "", hhc_base % " (x86)"):
            if osp.isfile(hhc_exe):
                break
        else:
            print(
                "Warning: `HTML Help Workshop` is required to build CHM "
                "documentation file",
                file=sys.stderr,
            )
            return
        doctmp_dir = osp.join("build", "doctmp")
        if not osp.isdir(doctmp_dir):
            os.makedirs(doctmp_dir)
        fname = osp.abspath(osp.join(doctmp_dir, "%s.chm" % libname))
        if osp.isfile(fname):
            # doc has already been built
            return fname
        subprocess.call("sphinx-build -b htmlhelp doc %s" % doctmp_dir, shell=True)
        subprocess.call('"%s" %s' % (hhc_exe, fname), shell=True)
        if osp.isfile(fname):
            return fname
        else:
            print("Warning: CHM building process failed", file=sys.stderr)


CHM_DOC = build_chm_doc(LIBNAME)


def _create_script_list(basename):
    scripts = ["%s-py%d" % (basename, sys.version_info.major)]
    if os.name == "nt":
        scripts.append("%s.bat" % scripts[0])
    return [osp.join("scripts", name) for name in scripts]


SCRIPTS = _create_script_list("guiqwt-tests") + _create_script_list("sift")


try:
    import sphinx
except ImportError:
    sphinx = None  # analysis:ignore


def is_msvc():
    """Detect if Microsoft Visual C++ compiler was chosen to build package"""
    # checking if mingw is the compiler
    # mingw32 compiler configured in %USERPROFILE%\pydistutils.cfg
    # or distutils\distutils.cfg
    from distutils.dist import Distribution

    dist = Distribution()
    dist.parse_config_files()
    bld = dist.get_option_dict("build")
    if bld:
        comp = bld.get("compiler")
        if comp is not None and "mingw32" in comp:
            return False  # mingw is the compiler
    return os.name == "nt" and "mingw" not in "".join(sys.argv)


CFLAGS = ["-Wall"]
if is_msvc():
    CFLAGS.insert(0, "/EHsc")
for arg, compile_arg in (
    ("--sse2", "-msse2"),
    ("--sse3", "-msse3"),
):
    if arg in sys.argv:
        sys.argv.pop(sys.argv.index(arg))
        CFLAGS.insert(0, compile_arg)

# Compiling Cython modules to C source code: this is the only way I found to
# be able to build both Fortran and Cython extensions together
# (this could be changed now as there is no longer Fortran extensions here...)
cythonize_all("src")

setup(
    name=LIBNAME,
    version="4.3.1",  # Update here *AND* in __init__.py!
    # (Until setup.py has been fully retrofitted, this manual sync is mandatory)
    description=__description__,
    long_description=LONG_DESCRIPTION,
    packages=get_subpackages(LIBNAME),
    package_data={
        LIBNAME: get_package_data(LIBNAME, (".png", ".svg", ".mo", ".dcm", ".ui"))
    },
    data_files=[(r"Doc", [CHM_DOC])] if CHM_DOC else [],
    install_requires=[
        "NumPy>=1.3",
        "SciPy>=0.7",
        "guidata>=2.3",
        "PythonQwt>=0.10",
        "Pillow",
        "QtPy>=1.3",
    ],
    extras_require={
        "Doc": ["Sphinx>=1.1"],
        "DICOM": ["pydicom>=0.9.3"],
    },
    entry_points={
        "gui_scripts": [
            "guiqwt-tests = guiqwt.tests:run",
            "sift = guiqwt.tests.sift:run",
        ]
    },
    ext_modules=[
        Extension(
            LIBNAME + ".histogram2d",
            [osp.join("src", "histogram2d.c")],
            include_dirs=[numpy.get_include()],
        ),
        Extension(
            LIBNAME + ".mandelbrot",
            [osp.join("src", "mandelbrot.c")],
            include_dirs=[numpy.get_include()],
        ),
        Extension(
            LIBNAME + "._scaler",
            [osp.join("src", "scaler.cpp"), osp.join("src", "pcolor.cpp")],
            extra_compile_args=CFLAGS,
            depends=[
                osp.join("src", "traits.hpp"),
                osp.join("src", "points.hpp"),
                osp.join("src", "arrays.hpp"),
                osp.join("src", "scaler.hpp"),
                osp.join("src", "debug.hpp"),
            ],
        ),
    ],
    author="Pierre Raybaut",
    author_email="pierre.raybaut@gmail.com",
    url="https://github.com/PierreRaybaut/%s" % LIBNAME,
    license="CeCILL V2",
    classifiers=["Topic :: Scientific/Engineering"]
    + [
        "Operating System :: MacOS",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: OS Independent",
        "Operating System :: POSIX",
        "Operating System :: Unix",
        "Programming Language :: Python :: 3",
    ],
)