setup.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from distutils.core import setup
  2. from distutils.command.install import INSTALL_SCHEMES
  3. import os
  4. import sys
  5. def fullsplit(path, result=None):
  6. """
  7. Split a pathname into components (the opposite of os.path.join) in a
  8. platform-neutral way.
  9. """
  10. if result is None:
  11. result = []
  12. head, tail = os.path.split(path)
  13. if head == '':
  14. return [tail] + result
  15. if head == path:
  16. return result
  17. return fullsplit(head, [tail] + result)
  18. # Tell distutils to put the data_files in platform-specific installation
  19. # locations. See here for an explanation:
  20. # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
  21. for scheme in INSTALL_SCHEMES.values():
  22. scheme['data'] = scheme['purelib']
  23. # Compile the list of packages available, because distutils doesn't have
  24. # an easy way to do this.
  25. packages, data_files = [], []
  26. root_dir = os.path.dirname(__file__)
  27. if root_dir != '':
  28. os.chdir(root_dir)
  29. django_dir = 'django'
  30. for dirpath, dirnames, filenames in os.walk(django_dir):
  31. # Ignore dirnames that start with '.'
  32. for i, dirname in enumerate(dirnames):
  33. if dirname.startswith('.'): del dirnames[i]
  34. if '__init__.py' in filenames:
  35. packages.append('.'.join(fullsplit(dirpath)))
  36. elif filenames:
  37. data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
  38. # Dynamically calculate the version based on django.VERSION.
  39. version_tuple = __import__('django').VERSION
  40. if version_tuple[2] is not None:
  41. version = "%d.%d_%s" % version_tuple
  42. else:
  43. version = "%d.%d" % version_tuple[:2]
  44. setup(
  45. name = "Django",
  46. version = version,
  47. url = 'http://www.djangoproject.com/',
  48. author = 'Django Software Foundation',
  49. author_email = 'foundation@djangoproject.com',
  50. description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
  51. packages = packages,
  52. data_files = data_files,
  53. scripts = ['django/bin/django-admin.py'],
  54. )