2 # -*- coding: ISO-8859-1 -*-
4 """Python package for the generation of encapsulated PostScript figures
6 PyX is a Python package for the creation of encapsulated PostScript figures.
7 It provides both an abstraction of PostScript and a TeX/LaTeX interface.
8 Complex tasks like 2d and 3d plots in publication-ready quality are built out
12 from distutils
.core
import setup
, Extension
13 from distutils
.command
.build_py
import build_py
14 from distutils
.command
.install_data
import install_data
20 # build list of extension modules
24 pykpathsea_ext_module
= Extension("pyx.pykpathsea._pykpathsea",
25 sources
=["pyx/pykpathsea/pykpathsea.c"],
26 libraries
=["kpathsea"])
27 t1strip_ext_module
= Extension("pyx.t1strip._t1strip",
28 sources
=["pyx/t1strip/t1strip.c", "pyx/t1strip/writet1.c"])
30 # obtain information on which modules have to be built from setup.cfg file
31 cfg
= ConfigParser
.ConfigParser()
33 if cfg
.has_section("PyX"):
34 if cfg
.has_option("PyX", "build_pykpathsea") and cfg
.getboolean("PyX", "build_pykpathsea"):
35 ext_modules
.append(pykpathsea_ext_module
)
36 if cfg
.has_option("PyX", "build_t1strip") and cfg
.getboolean("PyX", "build_t1strip"):
37 ext_modules
.append(t1strip_ext_module
)
43 data_files
= [# share/pyx is taken relative to "setup.py install --home=..."
44 ("share/pyx", ["pyx/lfs/10pt.lfs",
50 "pyx/lfs/foils17pt.lfs",
51 "pyx/lfs/foils20pt.lfs",
52 "pyx/lfs/foils25pt.lfs",
53 "pyx/lfs/foils30pt.lfs",
55 # /etc is taken relative to "setup.py install --root=..."
61 # pyx/siteconfig.py is not copied from the source directory,
62 # but generated from the directory data obtained from install_data
65 class pyx_build_py(build_py
):
68 # siteconfig depends on install_data:
69 self
.run_command('install_data')
72 def build_module(self
, module
, module_file
, package
):
73 if package
== "pyx" and module
== "siteconfig":
74 # generate path information as the original build_module does it
75 outfile
= self
.get_module_outfile(self
.build_lib
, [package
], module
)
76 dir = os
.path
.dirname(outfile
)
79 # we do not copy pyx/siteconfig.py, but generate it
80 # using the pyx_install_data instance
81 install_data
= self
.distribution
.command_obj
["install_data"]
82 f
= open(outfile
, "w")
83 f
.write("lfsdir = %r\n" % install_data
.pyx_lfsdir
)
84 f
.write("sharedir = %r\n" % install_data
.pyx_sharedir
)
85 f
.write("pyxrc = %r\n" % install_data
.pyx_pyxrc
)
88 return build_py
.build_module(self
, module
, module_file
, package
)
94 class pyx_install_data(install_data
):
97 install_data
.run(self
)
98 self
.pyx_lfsdir
= self
.pyx_sharedir
= os
.path
.join(self
.install_dir
, "share", "pyx")
99 self
.pyx_pyxrc
= os
.path
.join(self
.root
or "/", "etc", "pyxrc")
102 # additional package metadata (only available in Python 2.3 and above)
105 if sys
.version_info
>= (2, 3):
106 addargs
= { "classifiers":
107 [ "Development Status :: 3 - Alpha",
108 "Intended Audience :: Developers",
109 "Intended Audience :: End Users/Desktop",
110 "License :: OSI Approved :: GNU General Public License (GPL)",
111 "Operating System :: OS Independent",
112 "Programming Language :: Python",
113 "Topic :: Multimedia :: Graphics",
114 "Topic :: Scientific/Engineering :: Visualization",
115 "Topic :: Software Development :: Libraries :: Python Modules" ],
117 "http://sourceforge.net/project/showfiles.php?group_id=45430",
124 # We're using the module docstring as the distutils descriptions. (seen in Zope3 setup.py)
125 doclines
= __doc__
.split("\n")
128 version
=pyx
.__version
__,
129 author
="Jörg Lehmann, André Wobst",
130 author_email
="pyx-devel@lists.sourceforge.net",
131 url
="http://pyx.sourceforge.net/",
132 description
=doclines
[0],
133 long_description
="\n".join(doclines
[2:]),
135 packages
=["pyx", "pyx/graph", "pyx/graph/axis", "pyx/t1strip", "pyx/pykpathsea"],
136 ext_modules
=ext_modules
,
137 data_files
=data_files
,
138 cmdclass
= {"build_py": pyx_build_py
,
139 "install_data": pyx_install_data
},