mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
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:
parent
09caf49f6f
commit
6fbcb5db65
|
@ -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
|
|
@ -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
|
69
rest_framework/tools/preparedevenv.py
Normal file
69
rest_framework/tools/preparedevenv.py
Normal 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)
|
0
rest_framework/runtests/runcoverage.py → rest_framework/tools/runcoverage.py
Executable file → Normal file
0
rest_framework/runtests/runcoverage.py → rest_framework/tools/runcoverage.py
Executable file → Normal file
2
rest_framework/runtests/runtests.py → rest_framework/tools/runtests.py
Executable file → Normal file
2
rest_framework/runtests/runtests.py → rest_framework/tools/runtests.py
Executable file → Normal 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)
|
Loading…
Reference in New Issue
Block a user