summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/__init__.py12
-rw-r--r--cmd2/cmd2.py2
-rw-r--r--docs/conf.py11
-rwxr-xr-xsetup.py6
-rw-r--r--tests/test_cmd2.py4
5 files changed, 20 insertions, 15 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index f61b7165..2de297d3 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -1,6 +1,14 @@
#
# -*- coding: utf-8 -*-
"""This simply imports certain things for backwards compatibility."""
-from .cmd2 import __version__, Cmd, Statement, EmptyStatement, categorize
+
+from pkg_resources import get_distribution, DistributionNotFound
+try:
+ __version__ = get_distribution(__name__).version
+except DistributionNotFound:
+ # package is not installed
+ pass
+
+from .cmd2 import Cmd, Statement, EmptyStatement, categorize
from .cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category
-from .pyscript_bridge import CommandResult \ No newline at end of file
+from .pyscript_bridge import CommandResult
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 875cef59..7dffa4f8 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -116,8 +116,6 @@ try:
except ImportError: # pragma: no cover
ipython_available = False
-__version__ = '0.9.4'
-
# optional attribute, when tagged on a function, allows cmd2 to categorize commands
HELP_CATEGORY = 'help_category'
diff --git a/docs/conf.py b/docs/conf.py
index 17f0d4c3..13a2dba2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -52,17 +52,18 @@ master_doc = 'index'
# General information about the project.
project = 'cmd2'
-copyright = '2010-2017, Catherine Devlin and Todd Leonhardt'
+copyright = '2010-2018, Catherine Devlin and Todd Leonhardt'
author = 'Catherine Devlin and Todd Leonhardt'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
-# The short X.Y version.
-version = '0.9'
-# The full version, including alpha/beta/rc tags.
-release = '0.9.4'
+from pkg_resources import get_distribution
+# version will look like x.y.z
+version = get_distribution('cmd2').version
+# release will look like x.y
+release = '.'.join(version.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/setup.py b/setup.py
index 40b482b6..e67e14b6 100755
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,6 @@ Setuptools setup file, used to install or test 'cmd2'
"""
from setuptools import setup
-VERSION = '0.9.4'
DESCRIPTION = "cmd2 - a tool for building interactive command line applications in Python"
LONG_DESCRIPTION = """cmd2 is a tool for building interactive command line applications in Python. Its goal is to make
it quick and easy for developers to build feature-rich and user-friendly interactive command line applications. It
@@ -60,6 +59,8 @@ Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
""".splitlines())))
+SETUP_REQUIRES = ['setuptools_scm']
+
INSTALL_REQUIRES = ['pyperclip >= 1.5.27', 'colorama', 'attrs']
EXTRAS_REQUIRE = {
@@ -79,7 +80,7 @@ EXTRAS_REQUIRE = {
setup(
name="cmd2",
- version=VERSION,
+ use_scm_version=True,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
classifiers=CLASSIFIERS,
@@ -91,6 +92,7 @@ setup(
packages=['cmd2'],
keywords='command prompt console cmd',
python_requires='>=3.4',
+ setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
)
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 999aee8c..6115c1cd 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -28,10 +28,6 @@ from .conftest import run_cmd, normalize, BASE_HELP, BASE_HELP_VERBOSE, \
HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, StdOut
-def test_ver():
- assert cmd2.__version__ == '0.9.4'
-
-
def test_empty_statement(base_app):
out = run_cmd(base_app, '')
expected = normalize('')