From 4da2d373319ef03d62dd5b0bbd1a8e7609a6c483 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 29 Jul 2018 18:15:14 -0600 Subject: [PATCH 1/3] Use setuptools_scm for version numbers --- cmd2/__init__.py | 12 ++++++++++-- cmd2/cmd2.py | 2 -- docs/conf.py | 11 ++++++----- setup.py | 6 ++++-- tests/test_cmd2.py | 4 ---- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/cmd2/__init__.py b/cmd2/__init__.py index f61b7165f..2de297d3e 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 875cef592..7dffa4f80 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -116,8 +116,6 @@ def __subclasshook__(cls, C): 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 17f0d4c38..13a2dba28 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,17 +52,18 @@ # 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 40b482b6c..e67e14b6c 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ """ 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 @@ 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 @@ setup( name="cmd2", - version=VERSION, + use_scm_version=True, description=DESCRIPTION, long_description=LONG_DESCRIPTION, classifiers=CLASSIFIERS, @@ -91,6 +92,7 @@ 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 999aee8c7..6115c1cd6 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -28,10 +28,6 @@ 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('') From f3557f63d55287848c1bc4ef7cf7c2b182c68c24 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 29 Jul 2018 19:21:17 -0600 Subject: [PATCH 2/3] Add .eggs directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e1afc390a..9b5a5ba82 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__ build dist cmd2.egg-info +.eggs .cache *.pyc .tox From 2cc07ec8e739517992788dc8eb858a6d40eb24f3 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 29 Jul 2018 19:44:18 -0600 Subject: [PATCH 3/3] Add test to assert cmd2.__version__ exists --- tests/test_cmd2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 6115c1cd6..3324a1056 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -28,6 +28,9 @@ HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, StdOut +def test_version(base_app): + assert cmd2.__version__ + def test_empty_statement(base_app): out = run_cmd(base_app, '') expected = normalize('')