Author: tomaz
Date: Mon Jun 27 21:45:55 2011
New Revision: 1140337
URL: http://svn.apache.org/viewvc?rev=1140337&view=rev
Log:
1. Print an error if mock library cannot be found
2. Add pep8 target
Modified:
libcloud/trunk/setup.py
Modified: libcloud/trunk/setup.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/setup.py?rev=1140337&r1=1140336&r2=1140337&view=diff
==============================================================================
--- libcloud/trunk/setup.py (original)
+++ libcloud/trunk/setup.py Mon Jun 27 21:45:55 2011
@@ -20,17 +20,20 @@ from distutils.core import setup
from distutils.core import Command
from unittest import TextTestRunner, TestLoader
from glob import glob
+from subprocess import call
from os.path import splitext, basename, join as pjoin
import libcloud.utils
libcloud.utils.SHOW_DEPRECATION_WARNING = False
+
HTML_VIEWSOURCE_BASE = 'https://svn.apache.org/viewvc/libcloud/trunk'
PROJECT_BASE_DIR = 'http://libcloud.apache.org'
TEST_PATHS = [ 'test', 'test/compute', 'test/storage' , 'test/loadbalancer']
DOC_TEST_MODULES = [ 'libcloud.compute.drivers.dummy',
'libcloud.storage.drivers.dummy' ]
+
def read_version_string():
version = None
sys.path.insert(0, pjoin(os.getcwd()))
@@ -54,6 +57,15 @@ class TestCommand(Command):
pass
def run(self):
+ try:
+ import mock
+ mock
+ except ImportError:
+ print 'Missing "mock" library. mock is library is needed ' + \
+ 'to run the tests. You can install it using pip: ' + \
+ 'pip install mock'
+ sys.exit(1)
+
status = self._run_tests()
sys.exit(status)
@@ -101,6 +113,32 @@ class TestCommand(Command):
res = t.run(tests)
return not res.wasSuccessful()
+
+class Pep8Command(Command):
+ description = "run pep8 script"
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ try:
+ import pep8
+ pep8
+ except ImportError:
+ print 'Missing "pep8" library. You can install it using pip: ' + \
+ 'pip install pep8'
+ sys.exit(1)
+
+ cwd = os.getcwd()
+ retcode = call(('/usr/local/bin/pep8 %s/libcloud/ %s/test/' %
+ (cwd, cwd)).split(' '))
+ sys.exit(retcode)
+
+
class ApiDocsCommand(Command):
description = "generate API documentation"
user_options = []
@@ -176,6 +214,7 @@ setup(
url='http://libcloud.apache.org/',
cmdclass={
'test': TestCommand,
+ 'pep8': Pep8Command,
'apidocs': ApiDocsCommand,
'coverage': CoverageCommand
},