prevent double call of _cleanup, which harms usefiles (and is a bad idea in general)
[PyX.git] / pyx / __init__.py
blob50184867254486c6696a29b04fad41d96008cc9a
1 # -*- encoding: utf-8 -*-
4 # Copyright (C) 2002-2005 Jörg Lehmann <joergl@users.sourceforge.net>
5 # Copyright (C) 2002-2006 André Wobst <wobsta@users.sourceforge.net>
6 # Copyright (C) 2006 Michael Schindler <m-schindler@users.sourceforge.net>
8 # This file is part of PyX (http://pyx.sourceforge.net/).
10 # PyX is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # PyX is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with PyX; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 """Python graphics package
26 PyX is a Python package for the creation of PostScript and PDF files. It
27 combines an abstraction of the PostScript drawing model with a TeX/LaTeX
28 interface. Complex tasks like 2d and 3d plots in publication-ready quality are
29 built out of these primitives.
30 """
32 from . import version
33 __version__ = version.version
35 import sys
36 if sys.hexversion < 0x03020000:
37 sys.stderr.write("PyX {} requires Python 3.2 or higher.\n".format(__version__))
38 sys.exit()
39 del sys
41 __all__ = ["attr", "box", "bitmap", "canvas", "color", "connector", "deco", "deformer", "document",
42 "epsfile", "svgfile", "graph", "mesh", "metapost", "path", "pattern", "pdfextra", "style", "trafo", "text", "unit"]
44 import importlib
46 # automatically import main modules into pyx namespace
47 for module in __all__:
48 importlib.import_module('.' + module, package='pyx')
50 def pyxinfo():
51 """Make PyX a little verbose (for information or debugging)
53 This function enables info level on the ``"pyx"`` logger. It also adds some
54 general information about the Python interpreter, the PyX installation, and
55 the PyX configuration to the logger.
57 """
58 import logging, os, sys
59 from . import config
60 logging.lastResort.setLevel(logging.INFO)
61 logger = logging.getLogger("pyx")
62 logger.setLevel(logging.INFO)
63 logger.info("Platform name is: {}".format(os.name))
64 logger.info("Python executable: {}".format(sys.executable))
65 logger.info("Python version: %s", sys.version)
66 logger.info("PyX comes from: %s", __file__)
67 logger.info("PyX version: %s", __version__)
68 logger.info("pyxrc %s %s %s", "is" if os.path.isfile(config.user_pyxrc) else "would be" ,"loaded from:", config.user_pyxrc)
69 logger.info("pykpathsea: %s", "available" if config.has_pykpathsea else "not available")
70 logger.info("file locators in use: %s", ", ".join(method.__class__.__name__ for method in config.methods))
72 __all__.append("__version__")
73 __all__.append("pyxinfo")