-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpavement.py
176 lines (148 loc) · 5.25 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
175
176
# -*- coding: utf-8 -*-
""" PyroBase - General Python Helpers and Utilities.
Copyright (c) 2011-2018 The PyroScope Project <pyroscope.project@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
from __future__ import with_statement, print_function
import os
import re
import sys
import webbrowser
from setuptools import find_packages
from paver.easy import *
from paver.setuputils import setup
# Bootstrap our own tasks, projects using us don't need this!
if os.path.abspath("src") not in sys.path:
sys.path.insert(0, os.path.abspath("src"))
from pyrobase.paver.easy import *
#
# Project Metadata
#
changelog = path("debian/changelog")
name, version = open(changelog).readline().split(" (", 1)
version, _ = version.split(")", 1)
project = dict(
# egg
name = "pyrobase",
version = version,
package_dir = {"": "src"},
packages = find_packages("src", exclude = ["tests"]),
include_package_data = True,
zip_safe = True,
data_files = [
("EGG-INFO", [
"README.rst", "LICENSE", "debian/changelog",
]),
],
# dependencies
install_requires = [
'six',
],
setup_requires = [
],
extras_require={
'imgur': ['imgurpython', 'requests'],
'imgur_ssl': ['imgurpython', 'requests[security]'],
},
# tests
test_suite = "nose.collector",
# cheeseshop
author = "The PyroScope Project",
author_email = "pyroscope.project@gmail.com",
description = __doc__.split('.', 1)[0].strip(),
long_description = __doc__.split('.', 1)[1].strip(),
license = [line.strip() for line in __doc__.splitlines()
if line.strip().startswith("Copyright")][0],
url = "https://github.com/pyroscope/pyrobase",
keywords = "python utility library paver unittests",
classifiers = [
# see http://pypi.python.org/pypi?:action=list_classifiers
#"Development Status :: 3 - Alpha",
#"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
)
#
# Build
#
@task
@needs(["setuptools.command.egg_info"])
def bootstrap():
"initialize project"
#
# Testing
#
@task
@needs("setuptools.command.build")
def functest():
"functional test of the command line tools"
from pyrobase.paver.support import vsh
venv = path("build/venv")
venv.exists() and venv.rmtree()
sh("git clone --local '%s' '%s'" % (os.getcwd(), venv))
with pushd(venv) as basedir:
sh("virtualenv", ".")
vsh("pip", "install", "-q", "-U", "setuptools")
vsh("pip", "install", "-q", "paver")
vsh("paver", "bootstrap")
#
# Release Management
#
@task
@needs(["dist_clean", "minilib", "generate_setup", "sdist"])
def release():
"check release before upload to PyPI"
sh("paver bdist_wheel")
wheels = path("dist").files("*.whl")
if not wheels:
error("\n*** ERROR: No release wheel was built!")
sys.exit(1)
if any(".dev" in i for i in wheels):
error("\n*** ERROR: You're still using a 'dev' version!")
sys.exit(1)
# Check that source distribution can be built and is complete
print('')
print("~" * 78)
print("TESTING SOURCE BUILD")
sh( "{ command cd dist/ && unzip -q %s-%s.zip && command cd %s-%s/"
" && /usr/bin/python setup.py sdist >/dev/null"
" && if { unzip -ql ../%s-%s.zip; unzip -ql dist/%s-%s.zip; }"
" | cut -b26- | sort | uniq -c| egrep -v '^ +2 +' ; then"
" echo '^^^ Difference in file lists! ^^^'; false;"
" else true; fi; } 2>&1"
% tuple([project["name"], version] * 4)
)
path("dist/%s-%s" % (project["name"], version)).rmtree()
print("~" * 78)
print('')
print("Created", " ".join([str(i) for i in path("dist").listdir()]))
print("Use 'paver sdist bdist_wheel' to build the release and")
print(" 'twine upload dist/*.{zip,whl}' to upload to PyPI")
print("Use 'paver dist_docs' to prepare an API documentation upload")
#
# Main
#
setup(**project)