Skip to content

Commit a6f09ff

Browse files
committed
🚧 Using setuptools-scm versioning tool instead of custom
Signed-off-by: Guyzmo <[email protected]>
1 parent 4d61ccb commit a6f09ff

File tree

1 file changed

+4
-61
lines changed

1 file changed

+4
-61
lines changed

setup.py

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -46,63 +46,6 @@ def run(self):
4646
shutil.rmtree(os.path.join(path, '.installed.cfg'), ignore_errors=True)
4747
print("Repository is now clean!")
4848

49-
class VersionInfo(type):
50-
@property
51-
def info(cls):
52-
if not cls._info:
53-
try:
54-
cls._info = list(int(x) for x in open(cls.path, 'r').read().strip().split('.'))
55-
except ValueError:
56-
print('Version parts shall all be integers')
57-
sys.exit(1)
58-
if len(cls._info) != 3:
59-
print('Version number is not conform, there should be exactly three parts')
60-
sys.exit(1)
61-
return cls._info
62-
63-
def __str__(cls):
64-
return '.'.join(map(str, cls.info))
65-
66-
# Hack for metaclass support in both Py2 and Py3
67-
class VersionInfo_metaclass(VersionInfo):
68-
def __new__(cls, *bases):
69-
return VersionInfo('version_info', bases, {})
70-
71-
class Version(VersionInfo_metaclass(Command)):
72-
description = 'Bump version number'
73-
user_options = [
74-
('major', 'M', 'Bump major part of version number'),
75-
('minor', 'm', 'Bump minor part of version number'),
76-
('patch', 'p', 'Bump patch part of version number')]
77-
path = os.path.join(os.path.dirname(__file__), 'VERSION')
78-
_info = None
79-
80-
def finalize_options(self, *args, **kwarg): pass
81-
def initialize_options(self, *args, **kwarg):
82-
self.major = None
83-
self.minor = None
84-
self.patch = None
85-
86-
def run(self):
87-
MAJOR, MINOR, PATCH = (0,1,2)
88-
prev = str(Version)
89-
if self.major:
90-
Version.info[MAJOR] += 1
91-
Version.info[MINOR] = 0
92-
Version.info[PATCH] = 0
93-
if self.minor:
94-
Version.info[MINOR] += 1
95-
Version.info[PATCH] = 0
96-
if self.patch:
97-
Version.info[PATCH] += 1
98-
if self.major or self.minor or self.patch:
99-
with open(self.path, 'w') as f:
100-
f.write(str(Version))
101-
print("Bumped version from {} to {}".format(prev, str(Version)))
102-
else:
103-
print("Please choose at least one part to bump: --major, --minor or --patch!")
104-
sys.exit(1)
105-
10649

10750
class PyTest(TestCommand):
10851
user_options = [
@@ -192,8 +135,7 @@ def requirements(spec=None):
192135

193136

194137
setup(name='git-repo',
195-
version=str(Version),
196-
description='Tool for managing remote repositories from your git CLI!',
138+
description='Tool for managing repository services from your git CLI tool',
197139
classifiers=[
198140
# 'Development Status :: 2 - Pre-Alpha',
199141
# 'Development Status :: 3 - Alpha',
@@ -217,10 +159,12 @@ def requirements(spec=None):
217159
author='Bernard `Guyzmo` Pratz',
218160
author_email='[email protected]',
219161
setup_requires=[
162+
'setuptools_scm',
220163
'setuptools-markdown',
221-
'wheel>=0.25.0'
164+
'wheel>=0.25.0',
222165
],
223166
long_description_markdown_filename='README.md',
167+
use_scm_version={'version_scheme':'guess-next-dev'},
224168
include_package_data = True,
225169
install_requires=requirements(),
226170
tests_require=requirements('test'),
@@ -229,7 +173,6 @@ def requirements(spec=None):
229173
'buildout': Buildout,
230174
'dist_clean': DistClean,
231175
'test': PyTest,
232-
'bump': Version,
233176
},
234177
entry_points="""
235178
# -*- Entry points: -*-

0 commit comments

Comments
 (0)