Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit 8c6ec1b

Browse files
committed
Prepare release.
1 parent feb23b5 commit 8c6ec1b

File tree

4 files changed

+108
-66
lines changed

4 files changed

+108
-66
lines changed

NEWS

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
* Version 2.0.0 (unreleased)
2-
** New major release: Now targets the U2FVAL REST API V2, which is not compatible with V1.
1+
* Version 2.0.0 (released 2017-04-07)
2+
** New major release: Now targets the U2FVAL REST API V2, which is not
3+
compatible with V1.
34

45
* Version 1.0.1 (released 2015-10-27)
56
** Fix package so it installs.

release.py

+103-47
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,109 @@
1-
# Copyright (C) 2014 Yubico AB
1+
# Copyright (c) 2013 Yubico AB
2+
# All rights reserved.
23
#
3-
# This program is free software: you can redistribute it and/or modify
4-
# it under the terms of the GNU General Public License as published by
5-
# the Free Software Foundation, either version 3 of the License, or
6-
# (at your option) any later version.
4+
# Redistribution and use in source and binary forms, with or
5+
# without modification, are permitted provided that the following
6+
# conditions are met:
77
#
8-
# This program is distributed in the hope that it will be useful,
9-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-
# GNU General Public License for more details.
8+
# 1. Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
# 2. Redistributions in binary form must reproduce the above
11+
# copyright notice, this list of conditions and the following
12+
# disclaimer in the documentation and/or other materials provided
13+
# with the distribution.
1214
#
13-
# You should have received a copy of the GNU General Public License
14-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15-
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19+
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
# POSSIBILITY OF SUCH DAMAGE.
27+
28+
from __future__ import absolute_import
29+
30+
31+
from setuptools import setup as _setup, find_packages, Command
32+
from setuptools.command.sdist import sdist
1633
from distutils import log
17-
from distutils.core import Command
1834
from distutils.errors import DistutilsSetupError
35+
from datetime import date
36+
from glob import glob
1937
import os
2038
import re
21-
from datetime import date
39+
40+
VERSION_PATTERN = re.compile(r"(?m)^__version__\s*=\s*['\"](.+)['\"]$")
41+
42+
base_module = __name__.rsplit('.', 1)[0]
43+
44+
45+
def get_version(module_name_or_file=None):
46+
"""Return the current version as defined by the given module/file."""
47+
48+
if module_name_or_file is None:
49+
parts = base_module.split('.')
50+
module_name_or_file = parts[0] if len(parts) > 1 else \
51+
find_packages(exclude=['test', 'test.*'])[0]
52+
53+
if os.path.isdir(module_name_or_file):
54+
module_name_or_file = os.path.join(module_name_or_file, '__init__.py')
55+
56+
with open(module_name_or_file, 'r') as f:
57+
match = VERSION_PATTERN.search(f.read())
58+
return match.group(1)
59+
60+
61+
def setup(**kwargs):
62+
if 'version' not in kwargs:
63+
kwargs['version'] = get_version()
64+
kwargs.setdefault('packages', find_packages(exclude=['test', 'test.*']))
65+
cmdclass = kwargs.setdefault('cmdclass', {})
66+
cmdclass.setdefault('release', release)
67+
cmdclass.setdefault('build_man', build_man)
68+
cmdclass.setdefault('sdist', custom_sdist)
69+
return _setup(**kwargs)
70+
71+
72+
class custom_sdist(sdist):
73+
def run(self):
74+
self.run_command('build_man')
75+
76+
sdist.run(self)
77+
78+
79+
class build_man(Command):
80+
description = "create man pages from asciidoc source"
81+
user_options = []
82+
boolean_options = []
83+
84+
def initialize_options(self):
85+
pass
86+
87+
def finalize_options(self):
88+
self.cwd = os.getcwd()
89+
self.fullname = self.distribution.get_fullname()
90+
self.name = self.distribution.get_name()
91+
self.version = self.distribution.get_version()
92+
93+
def run(self):
94+
if os.getcwd() != self.cwd:
95+
raise DistutilsSetupError("Must be in package root!")
96+
97+
for fname in glob(os.path.join('man', '*.adoc')):
98+
self.announce("Converting: " + fname, log.INFO)
99+
self.execute(os.system,
100+
('a2x -d manpage -f manpage "%s"' % fname,))
22101

23102

24103
class release(Command):
25104
description = "create and release a new version"
26105
user_options = [
27-
('keyid=', None, "GPG key to sign with"),
106+
('keyid', None, "GPG key to sign with"),
28107
('skip-tests', None, "skip running the tests"),
29108
('pypi', None, "publish to pypi"),
30109
]
@@ -54,6 +133,10 @@ def _verify_tag(self):
54133
raise DistutilsSetupError(
55134
"Tag '%s' already exists!" % self.fullname)
56135

136+
def _verify_not_dirty(self):
137+
if os.system('git diff --shortstat | grep -q "."') == 0:
138+
raise DistutilsSetupError("Git has uncommitted changes!")
139+
57140
def _sign(self):
58141
if os.path.isfile('dist/%s.tar.gz.asc' % self.fullname):
59142
# Signature exists from upload, re-use it:
@@ -75,51 +158,26 @@ def _tag(self):
75158
tag_opts[0] = '-u ' + self.keyid
76159
self.execute(os.system, ('git tag ' + (' '.join(tag_opts)),))
77160

78-
def _do_call_publish(self, cmd):
79-
self._published = os.system(cmd) == 0
80-
81-
def _publish(self):
82-
web_repo = os.getenv('YUBICO_GITHUB_REPO')
83-
if web_repo and os.path.isdir(web_repo):
84-
artifacts = [
85-
'dist/%s.tar.gz' % self.fullname,
86-
'dist/%s.tar.gz.sig' % self.fullname
87-
]
88-
cmd = '%s/publish %s %s %s' % (
89-
web_repo, self.name, self.version, ' '.join(artifacts))
90-
91-
self.execute(self._do_call_publish, (cmd,))
92-
if self._published:
93-
self.announce("Release published! Don't forget to:", log.INFO)
94-
self.announce("")
95-
self.announce(" (cd %s && git push)" % web_repo, log.INFO)
96-
self.announce("")
97-
else:
98-
self.warn("There was a problem publishing the release!")
99-
else:
100-
self.warn("YUBICO_GITHUB_REPO not set or invalid!")
101-
self.warn("This release will not be published!")
102-
103161
def run(self):
104162
if os.getcwd() != self.cwd:
105163
raise DistutilsSetupError("Must be in package root!")
106164

107165
self._verify_version()
108166
self._verify_tag()
167+
self._verify_not_dirty()
168+
self.run_command('check')
109169

110170
self.execute(os.system, ('git2cl > ChangeLog',))
111171

172+
self.run_command('sdist')
173+
112174
if not self.skip_tests:
113-
self.run_command('check')
114-
# Nosetests calls sys.exit(status)
115175
try:
116-
self.run_command('nosetests')
176+
self.run_command('test')
117177
except SystemExit as e:
118178
if e.code != 0:
119179
raise DistutilsSetupError("There were test failures!")
120180

121-
self.run_command('sdist')
122-
123181
if self.pypi:
124182
cmd_obj = self.distribution.get_command_obj('upload')
125183
cmd_obj.sign = True
@@ -130,8 +188,6 @@ def run(self):
130188
self._sign()
131189
self._tag()
132190

133-
self._publish()
134-
135191
self.announce("Release complete! Don't forget to:", log.INFO)
136192
self.announce("")
137193
self.announce(" git push && git push --tags", log.INFO)

setup.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,23 @@
2525
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2626
# POSSIBILITY OF SUCH DAMAGE.
2727

28-
from setuptools import setup
29-
from release import release
30-
import re
31-
32-
VERSION_PATTERN = re.compile(r"(?m)^__version__\s*=\s*['\"](.+)['\"]$")
33-
34-
35-
def get_version():
36-
"""Return the current version as defined by u2fval_client/__init__.py."""
37-
38-
with open('u2fval_client/__init__.py', 'r') as f:
39-
match = VERSION_PATTERN.search(f.read())
40-
return match.group(1)
28+
from release import setup
4129

4230

4331
setup(
4432
name='u2fval-client',
45-
version=get_version(),
4633
author='Dain Nilsson',
4734
author_email='[email protected]',
4835
description='Python based U2FVAL connector library',
4936
maintainer='Yubico Open Source Maintainers',
5037
maintainer_email='[email protected]',
5138
url='https://github.com/Yubico/u2fval-client-python',
5239
license='BSD 2 clause',
53-
packages=['u2fval_client'],
5440
install_requires=['requests'],
5541
test_suite='test',
5642
tests_require=[
5743
'httpretty',
5844
],
59-
cmdclass={'release': release},
6045
classifiers=[
6146
'License :: OSI Approved :: BSD License',
6247
'Programming Language :: Python :: 2',

u2fval_client/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2626
# POSSIBILITY OF SUCH DAMAGE.
2727

28-
__version__ = '2.0.0-dev0'
28+
__version__ = '2.0.0'

0 commit comments

Comments
 (0)