from jinja2 import Template

__version__ = "0.0.1"

SETUP_FILE_TEMPLATE = Template("""
import os
import itertools
from setuptools import setup

from {{projname}} import __version__ as VERSION

def _find_all_subpackages(*packages):
    for root_package in packages:
        root_dir = os.path.dirname(__file__)
        package_root = os.path.abspath(os.path.join(root_dir, root_package))
        yield root_package
        for directory, dirnames, filenames in os.walk(package_root):
            if "__init__.py" not in filenames:
                del dirnames[:]
                continue
            relative_package = os.path.relpath(directory, package_root).replace(os.path.sep, ".")
            if relative_package == '.':
                continue
            yield root_package + "." + relative_package


setup(name="{{projname}}",
      classifiers = [
          "Development Status :: 4 - Beta",
          "Intended Audience :: Developers",
          "License :: OSI Approved :: BSD License",
          "Programming Language :: Python :: {{pyversion}}",
          ],
      description="{{description}}",
      #license="Proprietary",
      author="{{author}}",
      author_email="{{author_email}}",
      #url="your.url.here",
      version=VERSION,
      packages=list(_find_all_subpackages("{{projname}}")),
      install_requires=[],
      scripts=[],
      )

""")

DOCTEST_TEST_FILE_TEMPLATE = Template("""from unittest import TestCase
import os
import doctest

class ReadMeDocTest(TestCase):
    def test__readme_doctests(self):
        readme_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "README.rst"))
        self.assertTrue(os.path.exists(readme_path))
        result = doctest.testfile(readme_path, module_relative=False)
        self.assertEquals(result.failed, 0, "%s tests failed!" % result.failed)
""")

@@ -135,17 +135,32 @@
 rt setup
+, find_packages
 %0A
-
 %0Afrom %7B%7B
@@ -205,623 +205,8 @@
 ON%0A%0A
-def _find_all_subpackages(*packages):%0A    for root_package in packages:%0A        root_dir = os.path.dirname(__file__)%0A        package_root = os.path.abspath(os.path.join(root_dir, root_package))%0A        yield root_package%0A        for directory, dirnames, filenames in os.walk(package_root):%0A            if %22__init__.py%22 not in filenames:%0A                del dirnames%5B:%5D%0A                continue%0A            relative_package = os.path.relpath(directory, package_root).replace(os.path.sep, %22.%22)%0A            if relative_package == '.':%0A                continue%0A            yield root_package + %22.%22 + relative_package%0A%0A%0A
 setu
@@ -673,45 +673,25 @@
 ist(
-_find_all_subpackages(%22%7B%7Bprojname%7D%7D%22)
+exclude=%5B%22tests%22%5D
 ),%0A 

Move to setuptools