diff setup.py @ 9:8f7ba2c95025

Add packaging and related files.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Aug 2014 23:30:26 -0700
parents
children e4a24512b814
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Sat Aug 16 23:30:26 2014 -0700
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import os.path
+import sys
+import time
+import subprocess
+from setuptools import setup, find_packages
+from setuptools.command.test import test
+
+
+def read(fname):
+    with open(os.path.join(os.path.dirname(__file__), fname)) as fp:
+        return fp.read()
+
+
+def runcmd(cmd):
+    with subprocess.Popen(cmd, stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE) as p:
+        out, err = p.communicate()
+    return out, err
+
+
+class PyTest(test):
+    def finalize_options(self):
+        super(PyTest, self).finalize_options()
+        self.test_args = ['tests']
+        self.test_suite = True
+
+    def run_tests(self):
+        import pytest
+        errno = pytest.main(self.test_args)
+        sys.exit(errno)
+
+
+# Figure out the version.
+# (this is loosely based on what Mercurial does)
+version = None
+try:
+    if os.path.isdir(os.path.join(os.path.dirname(__file__), '.hg')):
+        cmd = ['hg', 'log', '-r', '.', '--template', '{tags}\n']
+        tags, err = runcmd(cmd)
+        versions = [t for t in tags.decode('utf8').split() if t[0].isdigit()]
+
+        cmd = ['hg', 'id', '-i']
+        hgid, err = runcmd(cmd)
+        hgid = hgid.decode('utf8').strip()
+
+        if versions:
+            # Use tag found at the current revision. Add dirty flag if any.
+            version = versions[-1]
+            if hgid.endswith('+'):
+                version += '+'
+        else:
+            # Use latest tag.
+            cmd = ['hg', 'parents', '--template', '{latesttag}+{latesttagdistance}-']
+            version, err = runcmd(cmd)
+            version = version.decode('utf8') + hgid
+
+        if version.endswith('+'):
+            version += time.strftime('%Y%m%d')
+except OSError:
+    # Mercurial isn't installed, or not in the PATH.
+    version = None
+
+
+if version:
+    f = open("piecrust/__version__.py", "w")
+    f.write('# this file is autogenerated by setup.py\n')
+    f.write('version = "%s"\n' % version)
+    f.close()
+
+
+try:
+    from piecrust import __version__
+    version = __version__.version
+except ImportError:
+    version = 'unknown'
+
+
+setup(name="piecrust",
+        version=version,
+        description="A powerful static website generator and lightweight CMS.",
+        long_description=read('README.rst') + '\n\n' + read('CHANGELOG.rst'),
+        author="Ludovic Chabant",
+        author_email="ludovic@chabant.com",
+        license="Apache License 2.0",
+        url="http://github.com/ludovicchabant/piecrust2",
+        keywords=' '.join([
+            'python',
+            'website',
+            'generator',
+            'blog',
+            'portfolio',
+            'gallery',
+            'cms'
+            ]),
+        packages=find_packages(),
+        include_package_data=True,
+        zip_safe=False,
+        install_requires=[
+            'Jinja2==2.7.3',
+            'Markdown==2.4.1',
+            'MarkupSafe==0.23',
+            'PyYAML==3.11',
+            'Pygments==1.6',
+            'Werkzeug==0.9.6',
+            'colorama==0.3.1',
+            'mock==1.0.1',
+            'py==1.4.23',
+            'python-dateutil==2.2',
+            'repoze.lru==0.6',
+            'strict-rfc3339==0.4'
+            ],
+        tests_require=[
+            'pytest==2.6.1',
+            'pytest-mock==0.2.0'
+            ],
+        cmdclass={
+            'test': PyTest
+            },
+        classifiers=[
+            'Development Status :: 3 - Alpha',
+            'License :: OSI Approved :: Apache Software License',
+            'Environment :: Console',
+            'Intended Audience :: Developers',
+            'Intended Audience :: System Administrators',
+            'Natural Language :: English',
+            'Operating System :: MacOS :: MacOS X',
+            'Operating System :: POSIX :: Linux',
+            'Operating System :: Microsoft :: Windows',
+            'Programming Language :: Python',
+            'Programming Language :: Python :: 3'
+            ],
+        entry_points={'console_scripts': [
+            'chef = piecrust.main:main',
+            ]}
+        )
+