2006-03-04 22:43:48 +00:00
|
|
|
|
2006-04-23 18:07:52 +00:00
|
|
|
NAME = 'PyYAML'
|
2008-09-30 11:45:18 +00:00
|
|
|
VERSION = '3.06'
|
2006-04-23 18:07:52 +00:00
|
|
|
DESCRIPTION = "YAML parser and emitter for Python"
|
|
|
|
LONG_DESCRIPTION = """\
|
|
|
|
YAML is a data serialization format designed for human readability and
|
2006-05-07 14:36:42 +00:00
|
|
|
interaction with scripting languages. PyYAML is a YAML parser and
|
|
|
|
emitter for Python.
|
2006-04-23 18:07:52 +00:00
|
|
|
|
2006-05-07 14:36:42 +00:00
|
|
|
PyYAML features a complete YAML 1.1 parser, Unicode support, pickle
|
|
|
|
support, capable extension API, and sensible error messages. PyYAML
|
|
|
|
supports standard YAML tags and provides Python-specific tags that allow
|
|
|
|
to represent an arbitrary Python object.
|
2006-04-23 18:07:52 +00:00
|
|
|
|
2006-05-07 14:36:42 +00:00
|
|
|
PyYAML is applicable for a broad range of tasks from complex
|
|
|
|
configuration files to object serialization and persistance."""
|
2006-03-04 22:43:48 +00:00
|
|
|
AUTHOR = "Kirill Simonov"
|
|
|
|
AUTHOR_EMAIL = 'xi@resolvent.net'
|
|
|
|
LICENSE = "MIT"
|
2006-04-23 18:07:52 +00:00
|
|
|
PLATFORMS = "Any"
|
|
|
|
URL = "http://pyyaml.org/wiki/PyYAML"
|
|
|
|
DOWNLOAD_URL = "http://pyyaml.org/download/pyyaml/%s-%s.tar.gz" % (NAME, VERSION)
|
|
|
|
CLASSIFIERS = [
|
2008-09-30 11:45:18 +00:00
|
|
|
"Development Status :: 5 - Production/Stable",
|
2006-04-23 18:07:52 +00:00
|
|
|
"Intended Audience :: Developers",
|
|
|
|
"License :: OSI Approved :: MIT License",
|
|
|
|
"Operating System :: OS Independent",
|
|
|
|
"Programming Language :: Python",
|
|
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
|
|
"Topic :: Text Processing :: Markup",
|
|
|
|
]
|
|
|
|
|
2008-09-30 13:29:34 +00:00
|
|
|
|
2008-10-02 00:24:42 +00:00
|
|
|
LIBYAML_CHECK = """
|
|
|
|
#include <yaml.h>
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
yaml_parser_t parser;
|
|
|
|
yaml_emitter_t emitter;
|
|
|
|
|
|
|
|
yaml_parser_initialize(&parser);
|
|
|
|
yaml_parser_delete(&parser);
|
|
|
|
|
|
|
|
yaml_emitter_initialize(&emitter);
|
|
|
|
yaml_emitter_delete(&emitter);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from distutils import log
|
2008-10-01 23:16:09 +00:00
|
|
|
from distutils.core import setup, Command
|
|
|
|
from distutils.core import Distribution as _Distribution
|
|
|
|
from distutils.core import Extension as _Extension
|
2008-10-02 00:24:42 +00:00
|
|
|
from distutils.dir_util import mkpath
|
2008-10-01 23:16:09 +00:00
|
|
|
from distutils.command.build_ext import build_ext as _build_ext
|
2008-10-02 00:24:42 +00:00
|
|
|
from distutils.errors import CompileError, LinkError
|
2008-10-01 23:16:09 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from Pyrex.Distutils import Extension as _Extension
|
|
|
|
from Pyrex.Distutils import build_ext as _build_ext
|
|
|
|
with_pyrex = True
|
|
|
|
except ImportError:
|
|
|
|
with_pyrex = False
|
|
|
|
|
|
|
|
import sys, os.path
|
|
|
|
|
|
|
|
|
|
|
|
class Distribution(_Distribution):
|
|
|
|
|
|
|
|
def __init__(self, attrs=None):
|
|
|
|
_Distribution.__init__(self, attrs)
|
|
|
|
if not self.ext_modules:
|
|
|
|
return
|
|
|
|
for ext in reversed(self.ext_modules):
|
|
|
|
if not isinstance(ext, Extension):
|
|
|
|
continue
|
|
|
|
setattr(self, ext.attr_name, None)
|
|
|
|
self.global_options = [
|
|
|
|
(ext.option_name, None,
|
2008-10-02 00:24:42 +00:00
|
|
|
"include %s (default if %s is available)"
|
|
|
|
% (ext.feature_description, ext.feature_name)),
|
2008-10-01 23:16:09 +00:00
|
|
|
(ext.neg_option_name, None,
|
2008-10-02 00:24:42 +00:00
|
|
|
"exclude %s" % ext.feature_description),
|
2008-10-01 23:16:09 +00:00
|
|
|
] + self.global_options
|
|
|
|
self.negative_opt = self.negative_opt.copy()
|
|
|
|
self.negative_opt[ext.neg_option_name] = ext.option_name
|
|
|
|
|
|
|
|
|
|
|
|
class Extension(_Extension):
|
|
|
|
|
2008-10-02 00:24:42 +00:00
|
|
|
def __init__(self, name, sources, feature_name, feature_description,
|
|
|
|
feature_check, **kwds):
|
2008-10-01 23:16:09 +00:00
|
|
|
if not with_pyrex:
|
|
|
|
for filename in sources[:]:
|
|
|
|
base, ext = os.path.splitext(filename)
|
|
|
|
if ext == 'pyx':
|
|
|
|
sources.replace(filename, '%s.c' % base)
|
|
|
|
_Extension.__init__(self, name, sources, **kwds)
|
|
|
|
self.feature_name = feature_name
|
|
|
|
self.feature_description = feature_description
|
2008-10-02 00:24:42 +00:00
|
|
|
self.feature_check = feature_check
|
2008-10-01 23:16:09 +00:00
|
|
|
self.attr_name = 'with_' + feature_name.replace('-', '_')
|
|
|
|
self.option_name = 'with-' + feature_name
|
|
|
|
self.neg_option_name = 'without-' + feature_name
|
|
|
|
|
|
|
|
|
|
|
|
class build_ext(_build_ext):
|
|
|
|
|
|
|
|
def get_source_files(self):
|
|
|
|
self.check_extensions_list(self.extensions)
|
|
|
|
filenames = []
|
|
|
|
for ext in self.extensions:
|
|
|
|
if with_pyrex:
|
|
|
|
self.pyrex_sources(ext.sources, ext)
|
|
|
|
for filename in ext.sources:
|
|
|
|
filenames.append(filename)
|
|
|
|
base = os.path.splitext(filename)[0]
|
|
|
|
for ext in ['c', 'h', 'pyx', 'pxd']:
|
|
|
|
filename = '%s.%s' % (base, ext)
|
|
|
|
if filename not in filenames and os.path.isfile(filename):
|
|
|
|
filenames.append(filename)
|
|
|
|
return filenames
|
|
|
|
|
|
|
|
def build_extensions(self):
|
|
|
|
self.check_extensions_list(self.extensions)
|
|
|
|
for ext in self.extensions:
|
|
|
|
if isinstance(ext, Extension):
|
2008-10-02 00:24:42 +00:00
|
|
|
with_ext = getattr(self.distribution, ext.attr_name)
|
|
|
|
if with_ext is None:
|
|
|
|
with_ext = self.check_extension_availability(ext)
|
|
|
|
if not with_ext:
|
2008-10-01 23:16:09 +00:00
|
|
|
continue
|
|
|
|
if with_pyrex:
|
|
|
|
ext.sources = self.pyrex_sources(ext.sources, ext)
|
|
|
|
self.build_extension(ext)
|
|
|
|
|
2008-10-02 00:24:42 +00:00
|
|
|
def check_extension_availability(self, ext):
|
|
|
|
cache = os.path.join(self.build_temp, 'check_%s.out' % ext.feature_name)
|
|
|
|
if not self.force and os.path.isfile(cache):
|
|
|
|
data = open(cache).read().strip()
|
|
|
|
if data == '1':
|
|
|
|
return True
|
|
|
|
elif data == '0':
|
|
|
|
return False
|
|
|
|
mkpath(self.build_temp)
|
|
|
|
src = os.path.join(self.build_temp, 'check_%s.c' % ext.feature_name)
|
|
|
|
open(src, 'w').write(ext.feature_check)
|
|
|
|
log.info("checking if %s compiles" % ext.feature_name)
|
|
|
|
try:
|
|
|
|
[obj] = self.compiler.compile([src],
|
|
|
|
macros=ext.define_macros+[(undef,) for undef in ext.undef_macros],
|
|
|
|
include_dirs=ext.include_dirs,
|
|
|
|
extra_postargs=(ext.extra_compile_args or []),
|
|
|
|
depends=ext.depends)
|
|
|
|
except CompileError:
|
|
|
|
log.warn("%s appears not to be installed" % ext.feature_name)
|
|
|
|
log.warn("(if %s is installed, you may need to specify"
|
|
|
|
% ext.feature_name)
|
|
|
|
log.warn(" the option --include-dirs or uncomment and modify")
|
|
|
|
log.warn(" the parameter include_dirs in setup.cfg)")
|
|
|
|
open(cache, 'w').write('0\n')
|
|
|
|
return False
|
|
|
|
prog = 'check_%s' % ext.feature_name
|
|
|
|
log.info("checking if %s links" % ext.feature_name)
|
|
|
|
try:
|
|
|
|
self.compiler.link_executable([obj], prog,
|
|
|
|
output_dir=self.build_temp,
|
|
|
|
libraries=ext.libraries,
|
|
|
|
library_dirs=ext.library_dirs,
|
|
|
|
runtime_library_dirs=ext.runtime_library_dirs,
|
|
|
|
extra_postargs=(ext.extra_link_args or []))
|
|
|
|
except LinkError:
|
|
|
|
log.warn("unable to link against %s" % ext.feature_name)
|
|
|
|
log.warn("(if %s is installed correctly, you may need to specify"
|
|
|
|
% ext.feature_name)
|
|
|
|
log.warn(" the option --library-dirs or uncomment and modify")
|
|
|
|
log.warn(" the parameter library_dirs in setup.cfg)")
|
|
|
|
open(cache, 'w').write('0\n')
|
|
|
|
return False
|
|
|
|
open(cache, 'w').write('1\n')
|
|
|
|
return True
|
|
|
|
|
2008-10-01 23:16:09 +00:00
|
|
|
|
|
|
|
class test(Command):
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
build_cmd = self.get_finalized_command('build')
|
|
|
|
build_cmd.run()
|
|
|
|
sys.path.insert(0, build_cmd.build_lib)
|
|
|
|
sys.path.insert(0, 'tests')
|
|
|
|
import test_all
|
|
|
|
test_all.main()
|
|
|
|
|
2006-03-04 22:43:48 +00:00
|
|
|
|
2006-08-19 19:37:57 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name=NAME,
|
|
|
|
version=VERSION,
|
|
|
|
description=DESCRIPTION,
|
|
|
|
long_description=LONG_DESCRIPTION,
|
|
|
|
author=AUTHOR,
|
|
|
|
author_email=AUTHOR_EMAIL,
|
|
|
|
license=LICENSE,
|
|
|
|
platforms=PLATFORMS,
|
|
|
|
url=URL,
|
|
|
|
download_url=DOWNLOAD_URL,
|
|
|
|
classifiers=CLASSIFIERS,
|
|
|
|
|
|
|
|
package_dir={'': 'lib'},
|
|
|
|
packages=['yaml'],
|
2008-10-01 23:16:09 +00:00
|
|
|
ext_modules=[
|
|
|
|
Extension('yaml/_yaml', ['ext/_yaml.pyx'],
|
2008-10-02 00:24:42 +00:00
|
|
|
'libyaml', "LibYAML bindings", LIBYAML_CHECK,
|
2008-10-01 23:16:09 +00:00
|
|
|
libraries=['yaml']),
|
|
|
|
],
|
2008-09-30 11:45:18 +00:00
|
|
|
|
2008-10-01 23:16:09 +00:00
|
|
|
distclass=Distribution,
|
|
|
|
cmdclass={
|
|
|
|
'build_ext': build_ext,
|
|
|
|
'test': test,
|
2008-09-30 11:45:18 +00:00
|
|
|
},
|
2006-08-19 19:37:57 +00:00
|
|
|
)
|
2006-03-04 22:43:48 +00:00
|
|
|
|