diff --git a/covimerage/__init__.py b/covimerage/__init__.py index b028f3e0..044a06e9 100755 --- a/covimerage/__init__.py +++ b/covimerage/__init__.py @@ -1,4 +1,6 @@ -"""The main covimerage module.""" +""" +Generate coverage information for Vim script. +""" import copy import itertools import os @@ -13,6 +15,9 @@ find_executable_files, get_fname_and_fobj_and_str, is_executable_line, ) +# Managed by setupmeta ("python setup.py version --bump patch" or similar). +__version__ = '0.1.4' + DEFAULT_COVERAGE_DATA_FILE = '.coverage_covimerage' RE_FUNC_PREFIX = re.compile( r'^\s*fu(?:n(?:(?:c(?:t(?:i(?:o(?:n)?)?)?)?)?)?)?!?\s+') @@ -21,11 +26,6 @@ RE_SNR_PREFIX = re.compile(r'^\d+_') -def get_version(): - from covimerage.__version__ import version - return version - - @attr.s class Line(object): """A source code line.""" diff --git a/covimerage/cli.py b/covimerage/cli.py index 7fb5b141..a4e29d28 100644 --- a/covimerage/cli.py +++ b/covimerage/cli.py @@ -4,7 +4,7 @@ import click -from . import DEFAULT_COVERAGE_DATA_FILE, MergedProfiles, Profile, get_version +from . import DEFAULT_COVERAGE_DATA_FILE, MergedProfiles, Profile, __version__ from .coveragepy import CoverageWrapper from .exceptions import CustomClickException from .logger import logger @@ -16,7 +16,7 @@ def default_loglevel(): @click.group(context_settings={'help_option_names': ['-h', '--help']}) -@click.version_option(get_version(), '-V', '--version', prog_name='covimerage') +@click.version_option(__version__, '-V', '--version', prog_name='covimerage') @click.option('-v', '--verbose', count=True, help='Increase verbosity.') @click.option('-q', '--quiet', count=True, help='Decrease verbosity.') @click.option('-l', '--loglevel', show_default=True, diff --git a/setup.py b/setup.py index 3375cb1e..b104d3b1 100755 --- a/setup.py +++ b/setup.py @@ -1,56 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Based on https://github.com/kennethreitz/setup.py. - -# Note: To use the 'upload' functionality of this file, you must: -# $ pip install twine - -import os -from shutil import rmtree -import sys - -from setuptools import Command, setup - -here = os.path.abspath(os.path.dirname(__file__)) - - -def read(fname): - with open(fname) as f: - return f.read() - - -class PublishCommand(Command): - """Support setup.py publish.""" - - description = 'Build and publish the package.' - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print('\033[1m{0}\033[0m'.format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status('Removing previous builds…') - rmtree(os.path.join(here, 'dist')) - except OSError: - pass - - self.status('Building Source and Wheel (universal) distribution…') - os.system('{0} setup.py sdist bdist_wheel --universal'.format( - sys.executable)) - - self.status('Uploading the package to PyPi via Twine…') - os.system('twine upload dist/*') - - sys.exit() +from setuptools import setup DEPS_QA = [ @@ -63,28 +11,21 @@ def run(self): 'pytest-mock', ] + setup( name='covimerage', - description='Generate coverage information for Vim scripts.', - long_description=read('README.md'), - long_description_content_type='text/markdown', author='Daniel Hahler', url='https://github.com/Vimjas/covimerage', - packages=['covimerage'], - entry_points={ - 'console_scripts': ['covimerage=covimerage.cli:main'], - }, - use_scm_version={ - 'write_to': 'covimerage/__version__.py', - }, - setup_requires=[ - 'setuptools_scm', - ], + + setup_requires=['setupmeta'], + versioning='post', + install_requires=[ 'attrs', 'click', 'coverage', ], + tests_require=DEPS_TESTING, extras_require={ 'testing': DEPS_TESTING, 'dev': DEPS_TESTING + DEPS_QA + [ @@ -93,8 +34,9 @@ def run(self): ], 'qa': DEPS_QA, }, - include_package_data=True, - license='MIT', + entry_points={ + 'console_scripts': ['covimerage=covimerage.cli:main'], + }, classifiers=[ # Trove classifiers # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -110,8 +52,4 @@ def run(self): 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy' ], - # $ setup.py publish support. - cmdclass={ - 'publish': PublishCommand, - }, ) diff --git a/tests/test_cli.py b/tests/test_cli.py index 641a0036..96542a0d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -9,7 +9,7 @@ import click import pytest -from covimerage import DEFAULT_COVERAGE_DATA_FILE, cli, get_version +from covimerage import DEFAULT_COVERAGE_DATA_FILE, cli, __version__ def test_dunder_main_run(capfd): @@ -21,7 +21,7 @@ def test_dunder_main_run(capfd): def test_dunder_main_run_help(capfd): assert call([sys.executable, '-m', 'covimerage', '--version']) == 0 out, err = capfd.readouterr() - assert out == 'covimerage, version %s\n' % get_version() + assert out == 'covimerage, version %s\n' % __version__ def test_cli(runner, tmpdir): @@ -46,7 +46,7 @@ def test_cli(runner, tmpdir): @pytest.mark.parametrize('arg', ('-V', '--version')) def test_cli_version(arg, runner): result = runner.invoke(cli.main, [arg]) - assert result.output == 'covimerage, version %s\n' % get_version() + assert result.output == 'covimerage, version %s\n' % __version__ assert result.exit_code == 0 @@ -282,7 +282,7 @@ def test_cli_run_report_fd(capfd, tmpdir, devnull): def test_cli_call(capfd): assert call(['covimerage', '--version']) == 0 out, err = capfd.readouterr() - assert out == 'covimerage, version %s\n' % get_version() + assert out == 'covimerage, version %s\n' % __version__ assert call(['covimerage', '--help']) == 0 out, err = capfd.readouterr()