Source

Pak / setup.py

import os
import re
import sys
from distutils.core import setup, Command
from distutils.command.sdist import sdist


HERE = os.path.dirname(os.path.abspath(__file__))


class _StubCommand(Command):
    user_options = []
    description = ''
    initialize_options = lambda self: None
    finalize_options = lambda self: None
    run = lambda self: None


class BuildDocsCommand(_StubCommand):
    description = 'build the Sphinx docs'

    def run(self):
        os.chdir('docs')
        os.system('make html')
        os.chdir(HERE)


class CustomSdistCommand(sdist):

    def run(self):
        self.run_command('build_docs')
        sdist.run(self)


class DevelopCommand(_StubCommand):
    description = 'cheap version of the setuptools `develop` command'

    def run(self):
        site_packages = os.path.join(
            os.path.dirname(os.path.abspath(os.__file__)),
            'site-packages'
        )
        egg_link = os.path.join(site_packages, 'Pak.egg-link')

        self.announce('Creating %s (link to .)' % egg_link)

        outfile = open(egg_link, 'w')
        outfile.write(HERE + '\n')
        outfile.close()


class TestCommand(_StubCommand):
    description = 'run all tests with nose'

    def run(self):
        import warnings

        warnings.simplefilter('ignore')

        import nose
        ret = nose.run(argv=[
            'nosetests',
            '-v',
            '--with-doctest',
            '-i',
            '^itest',
            '-e',
            '.*testfiles.*',
            'pak',
        ])

        if not ret:
            sys.exit(1)


VERSION = '0.1.0'
LONG_DESCRIPTION = """\
This is a pluggable command-line tool.

It includes some built-in features;

* Create file layouts for packages.  For instance, ``paste create
  --template=basic_package MyPackage`` will create a `setuptools
  <http://peak.telecommunity.com/DevCenter/setuptools>`_-ready
  file layout.

* Serving up web applications, with configuration based on
  `paste.deploy <http://pythonpaste.org/deploy/paste-deploy.html>`_.

The latest version is available in a `Mercurial repository
<http://bitbucket.org/ianb/pastescript/>`_.

For the latest changes see the `news file
<http://pythonpaste.org/script/news.html>`_.
"""


SETUP_ARGS = dict(
    name="Pak",
    version=VERSION,
    description="A pluggable command-line frontend, including commands " \
                "to setup package file layouts",
    long_description=LONG_DESCRIPTION,
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python",
        "Topic :: Internet :: WWW/HTTP",
        "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
        "Topic :: Software Development :: Libraries :: Python Modules",
        "Framework :: Paste",
    ],
    keywords='web wsgi setuptools framework command-line setup',
    author="Dan Buch",
    author_email="daniel.buch@gmail.com",
    url="http://meatballhat.com/pak/",
    license='MIT',
    packages=['pak'],
    package_data={
        'pak': [
            'paster-templates/basic_package/setup.*',
            'paster-templates/basic_package/tests/*.py',
            # @@: docs/ doesn't have any files :(
            'paster-templates/basic_package/+package+/*.py',
        ],
    },
    scripts=['scripts/pak'],
    cmdclass={
        'build_docs': BuildDocsCommand,
        'develop': DevelopCommand,
        'sdist': CustomSdistCommand,
        'test': TestCommand,
    },
#     test_suite='nose.collector',
#     tests_require=['nose>=0.11'],
#     entry_points={
#         'pak.paster_create_template': [
#             'basic_package = pak.templates:BasicPackage',
#         ],
#         'console_scripts': [
#             'pak = pak.command:run',
#         ],
#     }
)


def main():
    setup(**SETUP_ARGS)

    return 0


if __name__ == '__main__':
    sys.exit(main())