Added a script to ease start of development. Changed the name of the runtests folder to tools to reflect that it is no longer only for test running purposes but for development purposes.

This commit is contained in:
Omer Katz 2013-01-25 23:17:15 +03:00
parent 09caf49f6f
commit 6fbcb5db65
7 changed files with 74 additions and 4 deletions

View File

@ -17,5 +17,5 @@ install:
before-script:
- pep8 --exclude=migrations --ignore="E501,E255,E261,W191,E101" .
script:
- python rest_framework/runtests/runtests.py
- python rest_framework/runtests/runcoverage.py
- python rest_framework/tools/tools.py
- python rest_framework/tools/runcoverage.py

View File

@ -1,4 +1,5 @@
autopep8>=0.8.5
pep>=1.4.1
pep8>=1.4.1
coverage>=3.6
django-discover-runner>=0.2.2
tox

View File

@ -0,0 +1,69 @@
"""
This script prepares all the required components in order to start developing django-rest-framework.
Installs virtualenv to the global site packages if it does not exist.
Installs all the necessary dependencies into a virtualenv at the specified path.
usage: ./preparedevenv.py [path-to-virtual-env]
"""
import subprocess
import os
import sys
def install(home):
print("Installing dependencies into virtualenv at %s" % home)
requirements_path = os.path.abspath(os.path.dirname(__file__))
os.chdir(home)
pip = './Scripts/pip-script.py'
python = './Scripts/python'
execfile('./Scripts/activate_this.py')
subprocess.call(
[python, pip, 'install', '-r', os.path.join(requirements_path, "../..", 'requirements.txt'), '-M'])
subprocess.call(
[python, pip, 'install', '-r', os.path.join(requirements_path, "../..", 'optionals.txt'), '-M'])
subprocess.call(
[python, pip, 'install', '-r', os.path.join(requirements_path, "../..", 'development.txt'), '-M'])
def after_install(home):
install(home)
try:
import pip
except ImportError:
print("pip in not installed. Aborting...")
exit(1)
def install_virtualenv():
subprocess.call(['pip', 'install', 'virtualenv'])
def install_tox():
subprocess.call(['pip', 'install', 'tox'])
try:
import virtualenv
except ImportError:
try:
install_virtualenv()
except:
print("virtualenv installation has failed. Aborting...")
exit(1)
install_tox()
from virtualenv import create_environment
if len(sys.argv) < 2:
print("usage: ./preparedevenv.py [path-to-virtual-env]")
exit(1)
path = sys.argv[1]
if not os.path.isdir(path):
print("Creating virtualenv at %s" % path)
create_environment(path, use_distribute=True, clear=True)
else:
print("virtualenv at path %s seems to exist. Attempting to install dependencies." % path)
after_install(path)

View File

@ -8,5 +8,5 @@ os.environ.setdefault(
from django.core.management import execute_from_command_line
sys.argv.append('test')
sys.argv.append(1, 'test')
execute_from_command_line(sys.argv)