diff --git a/.travis.yml b/.travis.yml index 935fae559..263a93a44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 \ No newline at end of file + - python rest_framework/tools/tools.py + - python rest_framework/tools/runcoverage.py \ No newline at end of file diff --git a/development.txt b/development.txt index 206d2f860..8a8391615 100644 --- a/development.txt +++ b/development.txt @@ -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 \ No newline at end of file diff --git a/rest_framework/runtests/__init__.py b/rest_framework/tools/__init__.py similarity index 100% rename from rest_framework/runtests/__init__.py rename to rest_framework/tools/__init__.py diff --git a/rest_framework/tools/preparedevenv.py b/rest_framework/tools/preparedevenv.py new file mode 100644 index 000000000..0d7ea9861 --- /dev/null +++ b/rest_framework/tools/preparedevenv.py @@ -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) \ No newline at end of file diff --git a/rest_framework/runtests/runautopep8.py b/rest_framework/tools/runautopep8.py similarity index 100% rename from rest_framework/runtests/runautopep8.py rename to rest_framework/tools/runautopep8.py diff --git a/rest_framework/runtests/runcoverage.py b/rest_framework/tools/runcoverage.py old mode 100755 new mode 100644 similarity index 100% rename from rest_framework/runtests/runcoverage.py rename to rest_framework/tools/runcoverage.py diff --git a/rest_framework/runtests/runtests.py b/rest_framework/tools/runtests.py old mode 100755 new mode 100644 similarity index 91% rename from rest_framework/runtests/runtests.py rename to rest_framework/tools/runtests.py index 36228eb53..6ba913900 --- a/rest_framework/runtests/runtests.py +++ b/rest_framework/tools/runtests.py @@ -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)