Skip to content

Commit 34adfe4

Browse files
authored
Merge pull request #481 from python-cmd2/version_number
Use setuptools_scm for version number
2 parents 2cfeac8 + 2cc07ec commit 34adfe4

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ __pycache__
33
build
44
dist
55
cmd2.egg-info
6+
.eggs
67
.cache
78
*.pyc
89
.tox

cmd2/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#
22
# -*- coding: utf-8 -*-
33
"""This simply imports certain things for backwards compatibility."""
4-
from .cmd2 import __version__, Cmd, Statement, EmptyStatement, categorize
4+
5+
from pkg_resources import get_distribution, DistributionNotFound
6+
try:
7+
__version__ = get_distribution(__name__).version
8+
except DistributionNotFound:
9+
# package is not installed
10+
pass
11+
12+
from .cmd2 import Cmd, Statement, EmptyStatement, categorize
513
from .cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category
6-
from .pyscript_bridge import CommandResult
14+
from .pyscript_bridge import CommandResult

cmd2/cmd2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ def __subclasshook__(cls, C):
116116
except ImportError: # pragma: no cover
117117
ipython_available = False
118118

119-
__version__ = '0.9.4'
120-
121119

122120
# optional attribute, when tagged on a function, allows cmd2 to categorize commands
123121
HELP_CATEGORY = 'help_category'

docs/conf.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@
5252

5353
# General information about the project.
5454
project = 'cmd2'
55-
copyright = '2010-2017, Catherine Devlin and Todd Leonhardt'
55+
copyright = '2010-2018, Catherine Devlin and Todd Leonhardt'
5656
author = 'Catherine Devlin and Todd Leonhardt'
5757

5858
# The version info for the project you're documenting, acts as replacement for
5959
# |version| and |release|, also used in various other places throughout the
6060
# built documents.
6161
#
62-
# The short X.Y version.
63-
version = '0.9'
64-
# The full version, including alpha/beta/rc tags.
65-
release = '0.9.4'
62+
from pkg_resources import get_distribution
63+
# version will look like x.y.z
64+
version = get_distribution('cmd2').version
65+
# release will look like x.y
66+
release = '.'.join(version.split('.')[:2])
6667

6768
# The language for content autogenerated by Sphinx. Refer to documentation
6869
# for a list of supported languages.

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66
from setuptools import setup
77

8-
VERSION = '0.9.4'
98
DESCRIPTION = "cmd2 - a tool for building interactive command line applications in Python"
109
LONG_DESCRIPTION = """cmd2 is a tool for building interactive command line applications in Python. Its goal is to make
1110
it quick and easy for developers to build feature-rich and user-friendly interactive command line applications. It
@@ -60,6 +59,8 @@
6059
Topic :: Software Development :: Libraries :: Python Modules
6160
""".splitlines())))
6261

62+
SETUP_REQUIRES = ['setuptools_scm']
63+
6364
INSTALL_REQUIRES = ['pyperclip >= 1.5.27', 'colorama', 'attrs']
6465

6566
EXTRAS_REQUIRE = {
@@ -79,7 +80,7 @@
7980

8081
setup(
8182
name="cmd2",
82-
version=VERSION,
83+
use_scm_version=True,
8384
description=DESCRIPTION,
8485
long_description=LONG_DESCRIPTION,
8586
classifiers=CLASSIFIERS,
@@ -91,6 +92,7 @@
9192
packages=['cmd2'],
9293
keywords='command prompt console cmd',
9394
python_requires='>=3.4',
95+
setup_requires=SETUP_REQUIRES,
9496
install_requires=INSTALL_REQUIRES,
9597
extras_require=EXTRAS_REQUIRE,
9698
)

tests/test_cmd2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, StdOut
2929

3030

31-
def test_ver():
32-
assert cmd2.__version__ == '0.9.4'
33-
31+
def test_version(base_app):
32+
assert cmd2.__version__
3433

3534
def test_empty_statement(base_app):
3635
out = run_cmd(base_app, '')

0 commit comments

Comments
 (0)