oops: remove reference to not yet existing module slipped in earlier
[PyX.git] / setup.py
blob4894fe6ef8e1d1343bf1fe45a91c9045a2596060
1 #!/usr/bin/env python
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
9 of these primitives.
10 """
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
15 import ConfigParser
16 import sys, os
17 import pyx
20 # build list of extension modules
23 ext_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()
32 cfg.read("setup.cfg")
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)
40 # data files
43 data_files = [# share/pyx is taken relative to "setup.py install --home=..."
44 ("share/pyx", ["pyx/lfs/10pt.lfs",
45 "pyx/lfs/11pt.lfs",
46 "pyx/lfs/12pt.lfs",
47 "pyx/lfs/10ptex.lfs",
48 "pyx/lfs/11ptex.lfs",
49 "pyx/lfs/12ptex.lfs",
50 "pyx/lfs/foils17pt.lfs",
51 "pyx/lfs/foils20pt.lfs",
52 "pyx/lfs/foils25pt.lfs",
53 "pyx/lfs/foils30pt.lfs",
54 "contrib/pyx.def"]),
55 # /etc is taken relative to "setup.py install --root=..."
56 ("/etc", ["pyxrc"])]
59 # pyx_build_py
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):
67 def run(self):
68 # siteconfig depends on install_data:
69 self.run_command('install_data')
70 build_py.run(self)
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)
77 self.mkpath(dir)
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)
86 f.close()
87 else:
88 return build_py.build_module(self, module, module_file, package)
91 # install_data
94 class pyx_install_data(install_data):
96 def run(self):
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" ],
116 "download_url":
117 "http://sourceforge.net/project/showfiles.php?group_id=45430",
118 "platforms":
119 "OS independent",
121 else:
122 addargs = {}
124 # We're using the module docstring as the distutils descriptions. (seen in Zope3 setup.py)
125 doclines = __doc__.split("\n")
127 setup(name="PyX",
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:]),
134 license="GPL",
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},
140 **addargs)