setup.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import sys
  3. from optparse import OptionParser
  4. from django.core import management
  5. def start_misago_project():
  6. parser = OptionParser(usage="usage: %prog project_name")
  7. (options, args) = parser.parse_args()
  8. if len(args) != 1:
  9. parser.error("project_name must be specified")
  10. project_name = args[0]
  11. if project_name.startswith("-"):
  12. parser.error("project_name cannot start with '-'")
  13. # Ensure the given directory name doesn't clash with an existing
  14. # Python package/module.
  15. try:
  16. __import__(project_name)
  17. except ImportError:
  18. pass
  19. else:
  20. parser.error("'%s' conflicts with the name of an existing "
  21. "Python module and cannot be used as a project "
  22. "name. Please try another name." % project_name)
  23. misago_base_dir = os.path.dirname(os.path.dirname(__file__))
  24. project_template_path = os.path.join(misago_base_dir, 'project_template')
  25. argv = ['start-misago.py', 'startproject', project_name,
  26. '--template=%s' % project_template_path]
  27. management.execute_from_command_line(argv)