setup.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. import os
  3. import os.path
  4. import re
  5. from distutils.core import setup
  6. def find_package_data(basedir):
  7. pkgdata = {}
  8. pkgdir = {}
  9. EXCLUDE_FROM_DATA=('.py', '.pyc', '.pyo')
  10. for directory, _, files in os.walk(basedir):
  11. package = '.'.join(directory.split(os.sep))
  12. if '__init__.py' in files:
  13. # Record real packages and their directories
  14. pkgdata[package] = [
  15. f for f in files
  16. if not f.endswith(EXCLUDE_FROM_DATA)
  17. ]
  18. pkgdir[package] = directory
  19. else:
  20. # Find parent package
  21. while package not in pkgdata and package:
  22. package = ".".join(package.split(".")[:-1])
  23. # Add data files relative to their parent package
  24. reldir = os.path.relpath(directory, pkgdir[package])
  25. pkgdata[package].extend(
  26. os.path.join(reldir, f)
  27. for f in files
  28. if not f.endswith(EXCLUDE_FROM_DATA)
  29. )
  30. return pkgdata
  31. with open('debian/changelog') as f:
  32. res = re.search('\((\d.*)\)', f.readline())
  33. version = res.group(1)
  34. setup(name='DistroTracker',
  35. version=version,
  36. description='Synoptic view of all packages of a Debian-based distribution',
  37. author='Distro Tracker Developers',
  38. author_email='debian-qa@lists.debian.org',
  39. url='https://wiki.debian.org/qa.debian.org/distro-tracker',
  40. packages=[
  41. '.'.join(directory.split(os.sep))
  42. for directory, _, files in os.walk('distro_tracker')
  43. if '__init__.py' in files
  44. ],
  45. package_data=find_package_data('distro_tracker'),
  46. )
  47. setup(name='DjangoEmailAccounts',
  48. version=version,
  49. description='User registration app for Django',
  50. author='Distro Tracker Developers',
  51. author_email='debian-qa@lists.debian.org',
  52. url='https://wiki.debian.org/qa.debian.org/distro-tracker',
  53. packages=[
  54. '.'.join(directory.split(os.sep))
  55. for directory, _, files in os.walk('django_email_accounts')
  56. if '__init__.py' in files
  57. ],
  58. package_data=find_package_data('django_email_accounts'),
  59. )