use with open() in unit tests
[PyX.git] / setup.py
blobf29a226004ef3b652b36f0cf788d7ac3cea2b69b
1 #!/usr/bin/env python
2 # -*- encoding: utf-8 -*-
4 """Python package for the generation of PostScript and PDF files
6 PyX is a Python package for the creation of PostScript and PDF files. It
7 combines an abstraction of the PostScript drawing model with a TeX/LaTeX
8 interface. Complex tasks like 2d and 3d plots in publication-ready quality are
9 built out of these primitives."""
11 import sys
13 if sys.version_info[0] == 2:
14 print("""*** Sorry, this version of PyX runs on Python 3 only. ***
15 If you want to use PyX on Python 2, please use one of our
16 old releases up to PyX 0.12.x, i.e. execute something like:
18 pip install pyx==0.12.1
19 """)
20 exit()
23 import configparser
24 import pyx.version
26 cfg = configparser.ConfigParser()
27 cfg.read("setup.cfg")
29 # obtain information on which modules have to be built and whether to use setuptools
30 # instead of distutils from setup.cfg file
32 if cfg.has_section("PyX"):
33 if cfg.has_option("PyX", "use_setuptools") and cfg.getboolean("PyX", "use_setuptools"):
34 from setuptools import setup, Extension
35 import pkgutil
36 try:
37 pkgutil.get_data
38 except AttributeError:
39 setuptools_args={"zip_safe": False}
40 else:
41 setuptools_args={"zip_safe": True}
42 else:
43 from distutils.core import setup, Extension
44 setuptools_args={}
47 # build list of extension modules
49 ext_modules = []
50 pykpathsea_ext_module = Extension("pyx.pykpathsea",
51 sources=["pyx/pykpathsea.c"],
52 libraries=["kpathsea"])
53 t1code_ext_module = Extension("pyx.font._t1code",
54 sources=["pyx/font/_t1code.c"])
55 if cfg.has_option("PyX", "build_pykpathsea") and cfg.getboolean("PyX", "build_pykpathsea"):
56 ext_modules.append(pykpathsea_ext_module)
57 if cfg.has_option("PyX", "build_t1code") and cfg.getboolean("PyX", "build_t1code"):
58 ext_modules.append(t1code_ext_module)
61 description, long_description = __doc__.split("\n\n", 1)
63 setup(name="PyX",
64 version=pyx.version.version,
65 author="Jörg Lehmann, André Wobst",
66 author_email="pyx-devel@lists.sourceforge.net",
67 url="http://pyx.sourceforge.net/",
68 description=description,
69 long_description=long_description,
70 license="GPL",
71 packages=["pyx", "pyx/graph", "pyx/graph/axis", "pyx/font", "pyx/dvi", "pyx/metapost"],
72 package_data={"pyx": ["data/afm/*", "data/lfs/*", "data/def/*", "data/pyxrc"]},
73 ext_modules=ext_modules,
74 classifiers=["Development Status :: 3 - Alpha",
75 "Intended Audience :: Developers",
76 "Intended Audience :: End Users/Desktop",
77 "License :: OSI Approved :: GNU General Public License (GPL)",
78 "Operating System :: OS Independent",
79 "Programming Language :: Python :: 3",
80 "Topic :: Multimedia :: Graphics",
81 "Topic :: Scientific/Engineering :: Visualization",
82 "Topic :: Software Development :: Libraries :: Python Modules"],
83 download_url="https://downloads.sourceforge.net/project/pyx/pyx/%(version)s/PyX-%(version)s.tar.gz" % {"version": pyx.version.version},
84 platforms="OS independent",
85 **setuptools_args)