diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-24 03:48:30 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-24 03:48:30 -0700 |
commit | b5a688920af19f74be8189150f4b8b7e27d9f416 (patch) | |
tree | bf0aa12cfc860fade8ba3531fce3c237cba8a4db /setup.py | |
parent | 0bf6ca1f6ce57d1ecfbfffd6c5e5ce9478ba7387 (diff) | |
parent | 8d02bb2560f72b35fd64753e8c7ce85a61003f20 (diff) | |
download | pystache-b5a688920af19f74be8189150f4b8b7e27d9f416.tar.gz |
Merge branch 'development' into 'master': staging version 0.5.1-rc for issue #109.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 171 |
1 files changed, 139 insertions, 32 deletions
@@ -2,7 +2,7 @@ # coding: utf-8 """ -This script supports installing and distributing pystache. +This script supports publishing Pystache to PyPI. Below are instructions to pystache maintainers on how to push a new version of pystache to PyPI-- @@ -38,11 +38,59 @@ as described here, for example: import os import sys +py_version = sys.version_info + +# Distribute works with Python 2.3.5 and above: +# http://packages.python.org/distribute/setuptools.html#building-and-distributing-packages-with-distribute +if py_version < (2, 3, 5): + # TODO: this might not work yet. + import distutils as dist + from distutils import core + setup = core.setup +else: + import setuptools as dist + setup = dist.setup + +# TODO: use the logging module instead of printing. +# TODO: include the following in a verbose mode. +# print("Using: version %s of %s" % (repr(dist.__version__), repr(dist))) + + +VERSION = '0.5.1-rc' # Also change in pystache/__init__.py. + +HISTORY_PATH = 'HISTORY.rst' +LICENSE_PATH = 'LICENSE' +README_PATH = 'README.rst' + +CLASSIFIERS = ( + 'Development Status :: 4 - Beta', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.4', + 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', +) + + +def read(path): + """ + Read and return the contents of a text file as a unicode string. -try: - from setuptools import setup -except ImportError: - from distutils.core import setup + """ + # This function implementation was chosen to be compatible across Python 2/3. + f = open(path, 'rb') + # We avoid use of the with keyword for Python 2.4 support. + try: + b = f.read() + finally: + f.close() + + return b.decode('utf-8') def publish(): @@ -58,37 +106,96 @@ def make_long_description(): Return the long description for the package. """ - long_description = open('README.rst').read() + '\n\n' + open('HISTORY.rst').read() + license = """\ +License +======= - return long_description +""" + read(LICENSE_PATH) + + sections = [read(README_PATH), read(HISTORY_PATH), license] + return '\n\n'.join(sections) if sys.argv[-1] == 'publish': publish() sys.exit() -long_description = make_long_description() - -setup(name='pystache', - version='0.5.0', - description='Mustache for Python', - long_description=long_description, - author='Chris Wanstrath', - author_email='chris@ozmm.org', - maintainer='Chris Jerdonek', - url='http://github.com/defunkt/pystache', - packages=['pystache'], - license='MIT', - entry_points = { - 'console_scripts': ['pystache=pystache.commands:main'], - }, - classifiers = ( - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.4', - 'Programming Language :: Python :: 2.5', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - ) -) +# We follow the guidance here for compatibility with using setuptools instead +# of Distribute under Python 2 (on the subject of new, unrecognized keyword +# arguments to setup()): +# +# http://packages.python.org/distribute/python3.html#note-on-compatibility-with-setuptools +# +if py_version < (3, ): + extra = {} +else: + extra = { + # Causes 2to3 to be run during the build step. + 'use_2to3': True, + } + +# We use the package simplejson for older Python versions since Python +# does not contain the module json before 2.6: +# +# http://docs.python.org/library/json.html +# +# Moreover, simplejson stopped officially support for Python 2.4 in version 2.1.0: +# +# https://github.com/simplejson/simplejson/blob/master/CHANGES.txt +# +requires = [] +if py_version < (2, 5): + requires.append('simplejson<2.1') +elif py_version < (2, 6): + requires.append('simplejson') + +INSTALL_REQUIRES = requires + +# TODO: decide whether to use find_packages() instead. I'm not sure that +# find_packages() is available with distutils, for example. +PACKAGES = [ + 'pystache', + 'pystache.commands', + # The following packages are only for testing. + 'pystache.tests', + 'pystache.tests.data', + 'pystache.tests.data.locator', + 'pystache.tests.examples', +] + + +def main(sys_argv): + + long_description = make_long_description() + template_files = ['*.mustache', '*.txt'] + + setup(name='pystache', + version=VERSION, + license='MIT', + description='Mustache for Python', + long_description=long_description, + author='Chris Wanstrath', + author_email='chris@ozmm.org', + maintainer='Chris Jerdonek', + url='http://github.com/defunkt/pystache', + install_requires=INSTALL_REQUIRES, + packages=PACKAGES, + package_data = { + # Include template files so tests can be run. + 'pystache.tests.data': template_files, + 'pystache.tests.data.locator': template_files, + 'pystache.tests.examples': template_files, + }, + entry_points = { + 'console_scripts': [ + 'pystache=pystache.commands.render:main', + 'pystache-test=pystache.commands.test:main', + ], + }, + classifiers = CLASSIFIERS, + **extra + ) + + +if __name__=='__main__': + main(sys.argv) |