source: pysyck/trunk/setup.py @ 124

Revision 124, 3.5 KB checked in by xi, 8 years ago (diff)

Preparing the next release.

Line 
1
2NAME = 'PySyck'
3VERSION = '0.61.2'
4DESCRIPTION = "Python bindings for the Syck YAML parser and emitter"
5LONG_DESCRIPTION = """\
6YAML is a data serialization format designed for human readability
7and interaction with scripting languages. Syck is an extension for
8reading and writing YAML in scripting languages. PySyck is aimed to
9update the current Python bindings for Syck."""
10AUTHOR = "Kirill Simonov"
11AUTHOR_EMAIL = 'xi@resolvent.net'
12LICENSE = "BSD"
13PLATFORMS = "Any"
14URL = "http://pyyaml.org/wiki/PySyck"
15DOWNLOAD_URL = "http://pyyaml.org/download/pysyck/%s-%s.tar.gz" % (NAME, VERSION)
16CLASSIFIERS = [
17    "Development Status :: 5 - Production/Stable",
18    "Intended Audience :: Developers",
19    "License :: OSI Approved :: BSD License",
20    "Programming Language :: Python",
21    "Topic :: Software Development :: Libraries :: Python Modules",
22    "Topic :: Text Processing :: Markup",
23]
24
25from distutils.core import setup, Extension
26
27from distutils import log
28from distutils.command.build_ext import build_ext
29from distutils.errors import CCompilerError, CompileError, LinkError
30
31import os
32
33CHECK_SYCK = """
34#include <syck.h>
35#include <stdio.h>
36int main(void) {
37    syck_free_parser(syck_new_parser());
38    syck_free_emitter(syck_new_emitter());
39    puts(SYCK_VERSION);
40    return 0;
41}
42"""
43CHECK_SYCK_PROG = './_check_syck'
44
45class PySyckBuildExt(build_ext):
46
47    def build_extensions(self):
48        if not self.force:
49            self.check_syck()
50        build_ext.build_extensions(self)
51
52    def _clean(self, *filenames):
53        for filename in filenames:
54            try:
55                os.remove(filename)
56            except OSError:
57                pass
58
59    def check_syck(self):
60        prog = CHECK_SYCK_PROG
61        src = prog + '.c'
62        file(src, 'w').write(CHECK_SYCK)
63        [obj] = self.compiler.object_filenames([src])
64        log.info("checking for syck.h")
65        try:
66            self.compiler.compile([src])
67        except CompileError:
68            self._clean(src, obj)
69            raise CompileError, "syck.h is not found, " \
70                    "try to uncomment the include_dirs parameter in setup.cfg"
71        log.info("checking for libsyck.a")
72        try:
73            self.compiler.link_executable([obj], prog, libraries=['syck'])
74        except LinkError:
75            self._clean(src, obj, prog)
76            raise LinkError, "libsyck.a is not found, " \
77                    "try to uncomment the library_dirs parameter in setup.cfg"
78        if self.compiler.exe_extension:
79            prog += self.compiler.exe_extension
80        log.info("checking syck version")
81        pipe = os.popen(prog, 'r')
82        data = pipe.read().strip()
83        pipe.close()
84        version = float(data)
85        log.info("syck version: %s" % version)
86        if version < 0.55:
87            self._clean(src, obj, prog)
88            raise CCompilerError, "syck 0.55 or higher is required"
89        self._clean(src, obj, prog)
90           
91
92setup(
93    name=NAME,
94    version=VERSION,
95    description=DESCRIPTION,
96    long_description=LONG_DESCRIPTION,
97    author=AUTHOR,
98    author_email=AUTHOR_EMAIL,
99    license=LICENSE,
100    platforms=PLATFORMS,
101    url=URL,
102    download_url=DOWNLOAD_URL,
103    classifiers=CLASSIFIERS,
104
105    package_dir={'': 'lib'},
106    packages=['syck'],
107    ext_modules=[
108        Extension('_syck', ['ext/_syckmodule.c'],
109#            include_dirs=[],   # do not uncomment this, edit setup.cfg instead.
110#            library_dirs=[],   # do not uncomment this, edit setup.cfg instead.
111            libraries=['syck'],
112        ),
113    ],
114    cmdclass={
115        'build_ext': PySyckBuildExt,
116    },
117)
118
Note: See TracBrowser for help on using the repository browser.