From 3332a4da8d3ebfbda6dca7934d01061c0132a039 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Wed, 26 May 2010 19:03:30 -0400 Subject: Adding devserver convenience command. --- README | 12 +++--------- setup.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 10 deletions(-) mode change 100644 => 100755 setup.py diff --git a/README b/README index bb30a5d..0414c56 100644 --- a/README +++ b/README @@ -10,19 +10,13 @@ Install dependencies:: $ python setup.py install -Initial configuration ---------------------- -:: +Initial configuration:: $ $EDITOR chishop/settings.py - $ export DJANGO_SETTINGS_FILE="chishop.settings" - $ django-admin.py syncdb -Run the PyPI server -------------------- -:: +Run the PyPI server:: - $ django-admin.py runserver + $ python setup.py devserver Please note that ``chishop/media/dists`` has to be writable by the user the web-server is running as. diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index cb03934..626484e --- a/setup.py +++ b/setup.py @@ -1,9 +1,35 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import os import codecs import djangopypi from setuptools import setup, find_packages +from distutils.core import Command +from subprocess import call + + +class devserver(Command): + """ + Convenience command to sync the database and run a + development server. + + $ python setup.py runserver + """ + + description = "run the django development server" + + # Must be overridden even though we don't need them + user_options = [] + initialize_options = finalize_options = lambda self: None + + def run(self): + environ = os.environ.copy() + environ['DJANGO_SETTINGS_MODULE'] = 'chishop.settings' + + call(['django-admin.py', 'syncdb'], env=environ) + call(['django-admin.py', 'runserver'], env=environ) + setup( name='chishop', @@ -13,7 +39,6 @@ setup( author='Ask Solem', author_email='askh@opera.com', url="http://ask.github.com/chishop", - zip_safe=False, install_requires=[ 'django>=1.0', 'docutils', @@ -22,6 +47,9 @@ setup( dependency_links=[ 'http://bitbucket.org/ubernostrum/django-registration/downloads', ], + cmdclass={ + 'devserver': devserver, + }, classifiers=[ "Development Status :: 3 - Alpha", "Environment :: Web Environment", -- cgit v1.2.3