Skip to content
Browse files

Convert setup script to pure distutils, add everything important to M…

…ANIFEST.in
  • Loading branch information...
1 parent c959a27 commit 9896a2ec6a4c29f5fe5398652f2e1a11bef7f2cf @matthiask matthiask committed
Showing with 78 additions and 10 deletions.
  1. +3 −1 MANIFEST.in
  2. +18 −9 setup.py
  3. +57 −0 setuplib.py
View
4 MANIFEST.in
@@ -1,2 +1,4 @@
-include LICENSE
+include LICENCE
+include MANIFEST.in
include README.rst
+include setuplib.py
View
27 setup.py 100644 → 100755
@@ -1,18 +1,27 @@
+#!/usr/bin/env python
+
from distutils.core import setup
-from setuptools import find_packages
+import os
+import setuplib
+
+packages, package_data = setuplib.find_packages('scaffolding')
setup(
name='django-scaffolding',
version='0.1.0',
author='Simon Baechler',
author_email='simon@stellanera.com',
- packages=find_packages(),
- url='https://github.com/sbaechler/django-scaffolding',
- license='LICENSE',
+ packages=packages,
+ package_data=package_data,
+ url='https://github.com/sbaechler/django-scaffolding/',
+ license='LICENCE',
description='Automatically generate reasonable database entries for your app',
- long_description=open('README.rst').read(),
- install_requires=[
- "Django >= 1.2",
+ long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(),
+ classifiers=[
+ 'Environment :: Web Environment',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
],
- zip_safe=False
-)
+)
View
57 setuplib.py
@@ -0,0 +1,57 @@
+import os
+
+
+__all__ = ['find_files']
+
+
+def fullsplit(path, result=None):
+ """
+ Split a pathname into components (the opposite of os.path.join) in a
+ platform-neutral way.
+ """
+ if result is None:
+ result = []
+ head, tail = os.path.split(path)
+ if head == '':
+ return [tail] + result
+ if head == path:
+ return result
+ return fullsplit(head, [tail] + result)
+
+
+def find_packages(package_dir):
+ """
+ Returns a tuple consisting of a ``packages`` list and a ``package_data``
+ dictionary suitable for passing on to ``distutils.core.setup``
+
+ Requires the folder name containing the package files; ``find_files``
+ assumes that ``setup.py`` is located in the same folder as the folder
+ containing those files.
+
+ Code lifted from Django's ``setup.py``, with improvements by PSyton.
+ """
+
+ # Compile the list of packages available, because distutils doesn't have
+ # an easy way to do this.
+ packages = []
+ package_data = {}
+ root_dir = os.path.dirname(__file__)
+ if root_dir != '':
+ os.chdir(root_dir)
+
+ for dirpath, dirnames, filenames in sorted(os.walk(package_dir)):
+ # Ignore dirnames that start with '.'
+ for i, dirname in enumerate(dirnames):
+ if dirname.startswith('.'): del dirnames[i]
+ if '__init__.py' in filenames:
+ packages.append('.'.join(fullsplit(dirpath)))
+ elif filenames:
+ cur_pack = packages[0] # Assign all data files to the toplevel package
+ if cur_pack not in package_data:
+ package_data[cur_pack] = []
+ package_dir = "/".join(cur_pack.split(".")) + "/"
+ for f in filenames:
+ package_data[cur_pack].append(os.path.join(dirpath.replace(package_dir, ""), f))
+
+ return packages, package_data
+

0 comments on commit 9896a2e

Please sign in to comment.
Something went wrong with that request. Please try again.