source: pysyck/tags/0.61.1/setup.py @ 115

Revision 115, 3.7 KB checked in by xi, 8 years ago (diff)

Make the tag for 0.61.1.

Line 
1
2NAME = 'PySyck'
3VERSION = '0.61.1'
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 :: 3 - Alpha",
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 sys
32if sys.version < '2.2.4':
33    from distutils.dist import DistributionMetadata
34    DistributionMetadata.classifiers = None
35    DistributionMetadata.download_url = None
36
37import os
38
39CHECK_SYCK = """
40#include <syck.h>
41#include <stdio.h>
42int main(void) {
43    syck_free_parser(syck_new_parser());
44    syck_free_emitter(syck_new_emitter());
45    puts(SYCK_VERSION);
46    return 0;
47}
48"""
49CHECK_SYCK_PROG = './_check_syck'
50
51class PySyckBuildExt(build_ext):
52
53    def build_extensions(self):
54        if not self.force:
55            self.check_syck()
56        build_ext.build_extensions(self)
57
58    def _clean(self, *filenames):
59        for filename in filenames:
60            try:
61                os.remove(filename)
62            except OSError:
63                pass
64
65    def check_syck(self):
66        prog = CHECK_SYCK_PROG
67        src = prog + '.c'
68        file(src, 'w').write(CHECK_SYCK)
69        [obj] = self.compiler.object_filenames([src])
70        log.info("checking for syck.h")
71        try:
72            self.compiler.compile([src])
73        except CompileError:
74            self._clean(src, obj)
75            raise CompileError, "syck.h is not found, " \
76                    "try to uncomment the include_dirs parameter in setup.cfg"
77        log.info("checking for libsyck.a")
78        try:
79            self.compiler.link_executable([obj], prog, libraries=['syck'])
80        except LinkError:
81            self._clean(src, obj, prog)
82            raise LinkError, "libsyck.a is not found, " \
83                    "try to uncomment the library_dirs parameter in setup.cfg"
84        if self.compiler.exe_extension:
85            prog += self.compiler.exe_extension
86        log.info("checking syck version")
87        pipe = os.popen(prog, 'r')
88        data = pipe.read().strip()
89        pipe.close()
90        version = float(data)
91        log.info("syck version: %s" % version)
92        if version < 0.55:
93            self._clean(src, obj, prog)
94            raise CCompilerError, "syck 0.55 or higher is required"
95        self._clean(src, obj, prog)
96           
97
98setup(
99    name=NAME,
100    version=VERSION,
101    description=DESCRIPTION,
102    long_description=LONG_DESCRIPTION,
103    author=AUTHOR,
104    author_email=AUTHOR_EMAIL,
105    license=LICENSE,
106    platforms=PLATFORMS,
107    url=URL,
108    download_url=DOWNLOAD_URL,
109    classifiers=CLASSIFIERS,
110
111    package_dir={'': 'lib'},
112    packages=['syck'],
113    ext_modules=[
114        Extension('_syck', ['ext/_syckmodule.c'],
115#            include_dirs=[],   # do not uncomment this, edit setup.cfg instead.
116#            library_dirs=[],   # do not uncomment this, edit setup.cfg instead.
117            libraries=['syck'],
118        ),
119    ],
120    cmdclass={
121        'build_ext': PySyckBuildExt,
122    },
123)
124
Note: See TracBrowser for help on using the repository browser.