| 1 | |
|---|
| 2 | NAME = 'PyYAML' |
|---|
| 3 | VERSION = '3.06' |
|---|
| 4 | DESCRIPTION = "YAML parser and emitter for Python" |
|---|
| 5 | LONG_DESCRIPTION = """\ |
|---|
| 6 | YAML is a data serialization format designed for human readability and |
|---|
| 7 | interaction with scripting languages. PyYAML is a YAML parser and |
|---|
| 8 | emitter for Python. |
|---|
| 9 | |
|---|
| 10 | PyYAML features a complete YAML 1.1 parser, Unicode support, pickle |
|---|
| 11 | support, capable extension API, and sensible error messages. PyYAML |
|---|
| 12 | supports standard YAML tags and provides Python-specific tags that allow |
|---|
| 13 | to represent an arbitrary Python object. |
|---|
| 14 | |
|---|
| 15 | PyYAML is applicable for a broad range of tasks from complex |
|---|
| 16 | configuration files to object serialization and persistance.""" |
|---|
| 17 | AUTHOR = "Kirill Simonov" |
|---|
| 18 | AUTHOR_EMAIL = 'xi@resolvent.net' |
|---|
| 19 | LICENSE = "MIT" |
|---|
| 20 | PLATFORMS = "Any" |
|---|
| 21 | URL = "http://pyyaml.org/wiki/PyYAML" |
|---|
| 22 | DOWNLOAD_URL = "http://pyyaml.org/download/pyyaml/%s-%s.tar.gz" % (NAME, VERSION) |
|---|
| 23 | CLASSIFIERS = [ |
|---|
| 24 | "Development Status :: 5 - Production/Stable", |
|---|
| 25 | "Intended Audience :: Developers", |
|---|
| 26 | "License :: OSI Approved :: MIT License", |
|---|
| 27 | "Operating System :: OS Independent", |
|---|
| 28 | "Programming Language :: Python", |
|---|
| 29 | "Topic :: Software Development :: Libraries :: Python Modules", |
|---|
| 30 | "Topic :: Text Processing :: Markup", |
|---|
| 31 | ] |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | from distutils.core import setup, Command |
|---|
| 35 | from distutils.core import Distribution as _Distribution |
|---|
| 36 | from distutils.core import Extension as _Extension |
|---|
| 37 | from distutils.command.build_ext import build_ext as _build_ext |
|---|
| 38 | |
|---|
| 39 | try: |
|---|
| 40 | from Pyrex.Distutils import Extension as _Extension |
|---|
| 41 | from Pyrex.Distutils import build_ext as _build_ext |
|---|
| 42 | with_pyrex = True |
|---|
| 43 | except ImportError: |
|---|
| 44 | with_pyrex = False |
|---|
| 45 | |
|---|
| 46 | import sys, os.path |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | class Distribution(_Distribution): |
|---|
| 50 | |
|---|
| 51 | def __init__(self, attrs=None): |
|---|
| 52 | _Distribution.__init__(self, attrs) |
|---|
| 53 | if not self.ext_modules: |
|---|
| 54 | return |
|---|
| 55 | for ext in reversed(self.ext_modules): |
|---|
| 56 | if not isinstance(ext, Extension): |
|---|
| 57 | continue |
|---|
| 58 | setattr(self, ext.attr_name, None) |
|---|
| 59 | self.global_options = [ |
|---|
| 60 | (ext.option_name, None, |
|---|
| 61 | "include %s" % ext.feature_description), |
|---|
| 62 | (ext.neg_option_name, None, |
|---|
| 63 | "exclude %s (default)" % ext.feature_description), |
|---|
| 64 | ] + self.global_options |
|---|
| 65 | self.negative_opt = self.negative_opt.copy() |
|---|
| 66 | self.negative_opt[ext.neg_option_name] = ext.option_name |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | class Extension(_Extension): |
|---|
| 70 | |
|---|
| 71 | def __init__(self, name, sources, feature_name, feature_description, **kwds): |
|---|
| 72 | if not with_pyrex: |
|---|
| 73 | for filename in sources[:]: |
|---|
| 74 | base, ext = os.path.splitext(filename) |
|---|
| 75 | if ext == 'pyx': |
|---|
| 76 | sources.replace(filename, '%s.c' % base) |
|---|
| 77 | _Extension.__init__(self, name, sources, **kwds) |
|---|
| 78 | self.feature_name = feature_name |
|---|
| 79 | self.feature_description = feature_description |
|---|
| 80 | self.attr_name = 'with_' + feature_name.replace('-', '_') |
|---|
| 81 | self.option_name = 'with-' + feature_name |
|---|
| 82 | self.neg_option_name = 'without-' + feature_name |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | class build_ext(_build_ext): |
|---|
| 86 | |
|---|
| 87 | def get_source_files(self): |
|---|
| 88 | self.check_extensions_list(self.extensions) |
|---|
| 89 | filenames = [] |
|---|
| 90 | for ext in self.extensions: |
|---|
| 91 | if with_pyrex: |
|---|
| 92 | self.pyrex_sources(ext.sources, ext) |
|---|
| 93 | for filename in ext.sources: |
|---|
| 94 | filenames.append(filename) |
|---|
| 95 | base = os.path.splitext(filename)[0] |
|---|
| 96 | for ext in ['c', 'h', 'pyx', 'pxd']: |
|---|
| 97 | filename = '%s.%s' % (base, ext) |
|---|
| 98 | if filename not in filenames and os.path.isfile(filename): |
|---|
| 99 | filenames.append(filename) |
|---|
| 100 | return filenames |
|---|
| 101 | |
|---|
| 102 | def build_extensions(self): |
|---|
| 103 | self.check_extensions_list(self.extensions) |
|---|
| 104 | for ext in self.extensions: |
|---|
| 105 | if isinstance(ext, Extension): |
|---|
| 106 | if not getattr(self.distribution, ext.attr_name): |
|---|
| 107 | continue |
|---|
| 108 | if with_pyrex: |
|---|
| 109 | ext.sources = self.pyrex_sources(ext.sources, ext) |
|---|
| 110 | self.build_extension(ext) |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | class test(Command): |
|---|
| 114 | |
|---|
| 115 | user_options = [] |
|---|
| 116 | |
|---|
| 117 | def initialize_options(self): |
|---|
| 118 | pass |
|---|
| 119 | |
|---|
| 120 | def finalize_options(self): |
|---|
| 121 | pass |
|---|
| 122 | |
|---|
| 123 | def run(self): |
|---|
| 124 | build_cmd = self.get_finalized_command('build') |
|---|
| 125 | build_cmd.run() |
|---|
| 126 | sys.path.insert(0, build_cmd.build_lib) |
|---|
| 127 | sys.path.insert(0, 'tests') |
|---|
| 128 | import test_all |
|---|
| 129 | test_all.main() |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | if __name__ == '__main__': |
|---|
| 133 | |
|---|
| 134 | setup( |
|---|
| 135 | name=NAME, |
|---|
| 136 | version=VERSION, |
|---|
| 137 | description=DESCRIPTION, |
|---|
| 138 | long_description=LONG_DESCRIPTION, |
|---|
| 139 | author=AUTHOR, |
|---|
| 140 | author_email=AUTHOR_EMAIL, |
|---|
| 141 | license=LICENSE, |
|---|
| 142 | platforms=PLATFORMS, |
|---|
| 143 | url=URL, |
|---|
| 144 | download_url=DOWNLOAD_URL, |
|---|
| 145 | classifiers=CLASSIFIERS, |
|---|
| 146 | |
|---|
| 147 | package_dir={'': 'lib'}, |
|---|
| 148 | packages=['yaml'], |
|---|
| 149 | ext_modules=[ |
|---|
| 150 | Extension('yaml/_yaml', ['ext/_yaml.pyx'], |
|---|
| 151 | 'libyaml', "LibYAML bindings", |
|---|
| 152 | libraries=['yaml']), |
|---|
| 153 | ], |
|---|
| 154 | |
|---|
| 155 | distclass=Distribution, |
|---|
| 156 | cmdclass={ |
|---|
| 157 | 'build_ext': build_ext, |
|---|
| 158 | 'test': test, |
|---|
| 159 | }, |
|---|
| 160 | ) |
|---|
| 161 | |
|---|