diff options
author | Anthon van der Neut <anthon@mnt.org> | 2014-11-22 23:29:43 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2014-11-22 23:29:43 +0100 |
commit | 259d7c875079984ed502912fe77868f5b435e36b (patch) | |
tree | 3faf9a028a1049d4eb1a39919a3d5bb9b0994f38 /setup.py | |
download | ruamel.yaml-259d7c875079984ed502912fe77868f5b435e36b.tar.gz |
- merge py2 and py3 code bases
- remove support for 2.5/3.0/3.1/3.2 (this merge relies on u"" as
available in 3.3 and . imports not available in 2.5)
- tox.ini for 2.7/3.4/2.6/3.3
- remove lib3/ and tests/lib3 directories and content
- commit
- correct --verbose for test application
- DATA=changed to be relative to __file__ of code
- DATA using os.sep
- remove os.path from imports as os is already imported
- have test_yaml.py exit with value 0 on success, 1 on failures, 2 on
error
- added support for octal integers starting with '0o'
keep support for 01234 as well as 0o1234
- commit
- added test_roundtrip_data:
requirest a .data file and .roundtrip (empty), yaml_load .data
and compare dump against original.
- fix grammar as per David Pursehouse:
https://bitbucket.org/xi/pyyaml/pull-request/5/fix-grammar-in-error-messages/diff
- http://www.json.org/ extra escaped char \/
add .skip-ext as libyaml is not updated
- David Fraser: Extract a method to represent keys in mappings, so that
a subclass can choose not to quote them, used in repesent_mapping
https://bitbucket.org/davidfraser/pyyaml/
- add CommentToken and percolate through parser and composer and constructor
- add Comments to wrapped mapping and sequence constructs (not to scalars)
- generate YAML with comments
- initial README
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..493b5b6 --- /dev/null +++ b/setup.py @@ -0,0 +1,157 @@ +#! /usr/bin/env python +# coding: utf-8 + +from __future__ import print_function + +import sys +import os +from textwrap import dedent + +name_space = 'ruamel' +package_name = 'yaml' +full_package_name = name_space + '.' + package_name + +exclude_files = [ + 'setup.py', +] + + +def get_version(): + v_i = 'version_info = ' + for line in open('__init__.py'): + if not line.startswith(v_i): + continue + s_e = line[len(v_i):].strip()[1:-1].split(', ') + els = [x.strip()[1:-1] if x[0] in '\'"' else int(x) for x in s_e] + return els + + +def _check_convert_version(tup): + """create a PEP 386 pseudo-format conformant string from tuple tup""" + ret_val = str(tup[0]) # first is always digit + next_sep = "." # separator for next extension, can be "" or "." + nr_digits = 0 # nr of adjacent digits in rest, to verify + post_dev = False # are we processig post/dev + for x in tup[1:]: + if isinstance(x, int): + nr_digits += 1 + if nr_digits > 2: + raise ValueError("to many consecutive digits " + ret_val) + ret_val += next_sep + str(x) + next_sep = '.' + continue + first_letter = x[0].lower() + next_sep = '' + if first_letter in 'abcr': + if post_dev: + raise ValueError("release level specified after " + "post/dev:" + x) + nr_digits = 0 + ret_val += 'rc' if first_letter == 'r' else first_letter + elif first_letter in 'pd': + nr_digits = 1 # only one can follow + post_dev = True + ret_val += '.post' if first_letter == 'p' else '.dev' + else: + raise ValueError('First letter of "' + x + '" not recognised') + return ret_val + + +version_info = get_version() +version_str = _check_convert_version(version_info) + +if __name__ == '__main__': + # put here so setup.py can be imported more easily + from setuptools import setup, find_packages, Extension + from setuptools.command import install_lib + + +class MyInstallLib(install_lib.install_lib): + "create __init__.py on the fly" + def run(self): + install_lib.install_lib.run(self) + init_txt = dedent('''\ + # coding: utf-8 + # Copyright © 2013-2014 Anthon van der Neut, RUAMEL bvba + "generated __init__.py " + try: + __import__('pkg_resources').declare_namespace(__name__) + except ImportError: + pass + ''') + init_path = full_package_name.split('.')[:-1] + for product_init in [ + os.path.join( + *([self.install_dir] + init_path[:p+1] + ['__init__.py'])) + for p in range(len(init_path)) + ]: + if not os.path.exists(product_init): + print('creating %s' % product_init) + with open(product_init, "w") as fp: + fp.write(init_txt) + setup = os.path.join(self.install_dir, 'setup.py') + + def install(self): + fpp = full_package_name.split('.') # full package path + full_exclude_files = [os.path.join(*(fpp + [x])) + for x in exclude_files] + alt_files = [] + outfiles = install_lib.install_lib.install(self) + for x in outfiles: + for full_exclude_file in full_exclude_files: + if full_exclude_file in x: + os.remove(x) + break + else: + alt_files.append(x) + return alt_files + + +def main(): + install_requires = [ + ] + # use fast ordereddict for !!omap + install_requires = ['ruamel.ordereddict'] \ + if sys.version_info[0] == 2 else [] + # if sys.version_info < (3, 4): + # install_requires.append("") + packages = [full_package_name] + [(full_package_name + '.' + x) for x + in find_packages(exclude=['tests'])] + setup( + name=full_package_name, + version=version_str, + description=full_package_name + " is a YAML parser/emitter that " + "supports comment preservation", + install_requires=install_requires, + long_description=open('README.rst').read(), + url='https://bitbucket.org/ruamel/' + package_name, + author='Anthon van der Neut', + author_email='a.van.der.neut@ruamel.eu', + license="MIT license", + package_dir={full_package_name: '.'}, + namespace_packages=[name_space], + packages=packages, + entry_points=mk_entry_points(full_package_name), + cmdclass={'install_lib': MyInstallLib}, + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + ] + ) + + +def mk_entry_points(package_name): + script_name = package_name.replace('.', '_') + return {'console_scripts': [ + '{0} = {1}:main'.format(script_name, package_name), + ]} + +if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == 'sdist': + assert full_package_name == os.path.abspath(os.path.dirname( + __file__)).split('site-packages' + os.path.sep)[1].replace( + os.path.sep, '.') + main() |