Browse Source

Some moving around.

Rafał Pitoń 11 years ago
parent
commit
282264d793
3 changed files with 41 additions and 1 deletions
  1. 34 0
      misago/core/setup.py
  2. 1 1
      setup.py
  3. 6 0
      start-misago.py

+ 34 - 0
misago/core/setup.py

@@ -0,0 +1,34 @@
+import os
+import sys
+from optparse import OptionParser
+from django.core import management
+
+
+def start_misago_project():
+    parser = OptionParser(usage="usage: %prog project_name")
+    (options, args) = parser.parse_args()
+
+    if len(args) != 1:
+        parser.error("project_name must be specified")
+    project_name = args[0]
+    if project_name.startswith("-"):
+        parser.error("project_name cannot start with '-'")
+
+
+    # Ensure the given directory name doesn't clash with an existing
+    # Python package/module.
+    try:
+        __import__(project_name)
+    except ImportError:
+        pass
+    else:
+        parser.error("'%s' conflicts with the name of an existing "
+                     "Python module and cannot be used as a project "
+                     "name. Please try another name." % project_name)
+
+    misago_base_dir = os.path.dirname(os.path.dirname(__file__))
+    project_template_path = os.path.join(misago_base_dir, 'project_template')
+
+    argv = ['start-misago.py', 'startproject', project_name,
+            '--template=%s' % project_template_path]
+    management.execute_from_command_line(argv)

+ 1 - 1
setup.py

@@ -27,7 +27,7 @@ setup(
     install_requires=REQUIREMENTS,
     scripts=['misago/bin/misago-start.py'],
     entry_points={'console_scripts': [
-        'misago-start = misago.bin.misago-start:start_misago_project',
+        'misago-start = misago.core.setup:start_misago_project',
     ]},
     classifiers=[
         'Development Status :: 2 - Pre-Alpha',

+ 6 - 0
start-misago.py

@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+from misago.core.setup import start_misago_project
+
+
+if __name__ == "__main__":
+    start_misago_project()