This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpavement.py
174 lines (146 loc) · 4.46 KB
/
pavement.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import os
import sys
from paver.easy import *
from paver.setuputils import setup
try:
set
except NameError:
from sets import Set as set
try:
# Import for dev tasks
from paver.virtual import bootstrap
from github.tools.task import (
gh_pages_build,
gh_pages_clean,
gh_pages_create,
gh_register)
from git import Git
ALL_TASKS_LOADED = True
except ImportError, e:
info("some tasks could not not be imported.")
debug(str(e))
ALL_TASKS_LOADED = False
def read_file(file_path):
return open(file_path).read()
def write_file(file_path, content=()):
f = open(file_path, 'w')
try:
f.writelines(content)
finally:
f.close()
version='0.2rc1+1'
long_description = read_file('README.rst') + '\n\n' + read_file('CHANGES.rst')
classifiers = [
# Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
"Programming Language :: Python :: 2.5", # not yet tested on python 2.6
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux", # Not tested yet on osx or Windows
"Topic :: Documentation",
"Topic :: Software Development :: Version Control"
]
install_requires = [
'setuptools>=0.6c9',
'GitPython==0.1.7',
'Sphinx',
'simplejson',
]
extras_require = {
'template': ['paver-templates>=0.1.0b3'],
}
entry_points="""
# -*- Entry points: -*-
[paste.paster_create_template]
gh_package = github.tools.template:GithubTemplate
"""
setup(name='github-tools',
version=version,
description='Helpers for Python package hosting at GitHub',
long_description=long_description,
classifiers=classifiers,
keywords='sphinx github paster',
author='Damien Lebrun',
author_email='[email protected]',
url='http://dinoboff.github.com/github-tools/',
license='BSD',
packages = ['github', 'github.tools',],
package_dir = {'': 'src'},
namespace_packages=['github'],
include_package_data=True,
test_suite='nose.collector',
zip_safe=False,
install_requires=install_requires,
extras_require=extras_require,
entry_points=entry_points,
)
options(
minilib=Bunch(
extra_files=[
'doctools',
'virtual'
]
),
virtualenv=Bunch(
script_name='bootstrap.py',
dest_dir='./virtual-env/',
packages_to_install=[
'virtualenv>=1.3.3',
'Nose>=0.10.4',
'Mock>=0.5.0',
]
),
sphinx=Bunch(
docroot='docs',
builddir='build',
sourcedir='source',
),
)
@task
def test_sphinx():
sh("sphinx-build -d docs/build/doctrees -b html docs/source docs/build/html")
if ALL_TASKS_LOADED:
@task
def pip_requirements():
"""Create a pip requirement file."""
req = set()
for d in (
options.virtualenv.get('packages_to_install', [])
+ options.setup.get('install_requires', [])
):
req.add(d+'\n')
write_file('dev-requirements.txt', req)
@task
def manifest():
"""Generate a Manifest using 'git ls-files'"""
includes = (
"include %s\n" % f
for f in Git('.').ls_files().splitlines()
if not os.path.basename(f).startswith('.') and f != 'docs/build/html'
)
write_file('MANIFEST.in', includes)
@task
@needs('pip_requirements', 'generate_setup', 'manifest', 'minilib',
'setuptools.command.sdist')
def sdist():
"""Overrides sdist to make sure that our setup.py is generated."""
@task
@needs('gh_pages_build', 'github.tools.task.gh_pages_update')
def gh_pages_update():
"""Overrides github.tools.task to rebuild the doc (with sphinx)."""
tag_name = 'v%s' % version
@task
def tag():
"""tag a new version of this distribution"""
git = Git('.')
git.pull('origin', 'master')
git.tag(tag_name)
@task
@needs('sdist', 'tag', 'setuptools.command.upload',)
def upload():
"""Upload the distribution to pypi, the new tag and the doc to Github"""
options.update(
gh_pages_update=Bunch(commit_message='Update doc to %s' % version))
gh_pages_update()
Git('.').push('origin', 'master', tag_name)