source: trunk/setup.py @ 50

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

Commented the include_dirs and library_dirs. Instead add a hint to the error message.

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