-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabfile.py
126 lines (102 loc) · 3.69 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
from fabric.api import *
from fabric.tasks import Task
@task
def doctests():
"""Run the doctests found in GuessIt classes"""
local('nosetests --with-doctest -vv pygoo')
class TestTask(Task):
name = 'testtask'
def __init__(self, testname, docstring):
super(Task, self).__init__()
self.name = 'test_' + testname
self.__doc__ = 'Run the unittests for %s' % docstring
def run(self):
local('PYTHONPATH=. python tests/%s.py' % self.name)
test_objectnode = TestTask('objectnode', 'object node functionality')
test_baseobject = TestTask('baseobject', 'BaseObject functionality')
test_datamodel = TestTask('datamodel', 'ORM functionality')
test_advancedgraph = TestTask('advancedgraph', 'advanced graph operations')
test_inheritance = TestTask('inheritance', 'inheritance')
test_memory = TestTask('memory', 'memory-backed graphs')
test_ontology = TestTask('ontology', 'basic ontology functionality')
@task
def unittests():
"""Run all the unittests"""
EXCLUDE = ['test_pypi_sdist']
def is_unittest(t):
return t[0].startswith('test_') and t[0] not in EXCLUDE
alltests = filter(is_unittest, globals().items())
for name, testcase in alltests:
testcase.run()
@task
def tests():
"""Run both the doctests and the unittests"""
unittests()
doctests()
@task
def clean_pyc():
"""Removes all the *.pyc files found in the repository"""
local('find . -iname "*.pyc" -delete')
@task
def pylint():
"""Runs pylint on PyGoo's source code. Only show problems, no report"""
local('pylint --reports=n --include-ids=y --disable=C,I,W0703 pygoo')
@task
def pylint_report():
"""Runs pylint on PyGoo's source code, full report"""
local('pylint --include-ids=y --disable=C0103,C0111 pygoo')
def open_file(filename):
"""Open the given file using the OS's native programs"""
if sys.platform.startswith('linux'):
local('xdg-open "%s"' % filename)
elif sys.platform == 'darwin':
local('open "%s"' % filename)
else:
print 'Platform not supported:', sys.platform
@task
def doc():
"""Build the Sphinx documentation and open it in a web browser"""
with lcd('docs'):
local('make html')
open_file('_build/html/index.html')
@task
def pypi_doc():
"""Builds the main page that will be uploaded to PyPI and open it in a
web browser"""
local('python setup.py --long-description | rst2html.py > /tmp/pygoo_pypi_doc.html')
open_file('/tmp/pygoo_pypi_doc.html')
# Release management functions
@task
def set_version(version):
"""Set the version in the pygoo/__init__.py file"""
initfile = open('pygoo/__init__.py').read()
initfile = re.sub(r"__version__ = '\S*'",
r"__version__ = '%s'" % version,
initfile)
open('pygoo/__init__.py', 'w').write(initfile)
@task
def upload_pypi():
"""Build and upload the package on PyPI"""
local('python setup.py register sdist upload')
@task
def test_pypi_sdist():
"""Build the PyPI package and test whether it is installable and passes
the tests"""
d = '_tmp_pypi_pygoo'
local('rm -fr dist %s' % d)
local('python setup.py sdist')
local('virtualenv %s' % d)
with lcd(d):
with prefix('source bin/activate'):
local('pip install ../dist/*')
#local('pip install PyYaml') # to be able to run the tests
#local('cp ../tests/*.py ../tests/*.yaml ../tests/*.txt .')
#local('python test_autodetect.py')
#local('python test_movie.py')
#local('python test_episode.py')
#local('python test_language.py')
local('rm -fr %s' % d)