From 80949fe1e2c1488f4c0175c20c9c6cc1b3d6fe6f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 11 Feb 2019 16:52:07 +0100 Subject: [PATCH 1/3] WIP: setupmeta --- covimerage/__init__.py | 4 +- setup.py | 179 +++++++++++++++-------------------------- 2 files changed, 69 insertions(+), 114 deletions(-) diff --git a/covimerage/__init__.py b/covimerage/__init__.py index b028f3e0..7f7c981d 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 diff --git a/setup.py b/setup.py index 3375cb1e..9e43d623 100755 --- a/setup.py +++ b/setup.py @@ -1,117 +1,70 @@ -#!/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() - - -DEPS_QA = [ - 'flake8', - 'flake8-isort', - 'flake8-per-file-ignores', -] -DEPS_TESTING = [ - 'pytest>=3.3.0', - 'pytest-mock', -] +from setuptools import setup 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', - ], - install_requires=[ - 'attrs', - 'click', - 'coverage', - ], - extras_require={ - 'testing': DEPS_TESTING, - 'dev': DEPS_TESTING + DEPS_QA + [ - 'pdbpp', - 'pytest-pdb', - ], - 'qa': DEPS_QA, - }, - include_package_data=True, - license='MIT', - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy' - ], - # $ setup.py publish support. - cmdclass={ - 'publish': PublishCommand, - }, + versioning='post', + setup_requires='setupmeta', ) + +# DEPS_QA = [ +# 'flake8', +# 'flake8-isort', +# 'flake8-per-file-ignores', +# ] +# DEPS_TESTING = [ +# 'pytest>=3.3.0', +# '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', +# ], +# install_requires=[ +# 'attrs', +# 'click', +# 'coverage', +# ], +# extras_require={ +# 'testing': DEPS_TESTING, +# 'dev': DEPS_TESTING + DEPS_QA + [ +# 'pdbpp', +# 'pytest-pdb', +# ], +# 'qa': DEPS_QA, +# }, +# include_package_data=True, +# license='MIT', +# classifiers=[ +# # Trove classifiers +# # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers +# 'License :: OSI Approved :: MIT License', +# 'Programming Language :: Python', +# 'Programming Language :: Python :: 2.7', +# 'Programming Language :: Python :: 3', +# 'Programming Language :: Python :: 3.3', +# 'Programming Language :: Python :: 3.4', +# 'Programming Language :: Python :: 3.5', +# 'Programming Language :: Python :: 3.6', +# 'Programming Language :: Python :: 3.7', +# 'Programming Language :: Python :: Implementation :: CPython', +# 'Programming Language :: Python :: Implementation :: PyPy' +# ], +# # $ setup.py publish support. +# cmdclass={ +# 'publish': PublishCommand, +# }, +# ) From ec0d387ebc48f25df1ade332cf40dd5db6b276f6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 11 Feb 2019 17:52:44 +0100 Subject: [PATCH 2/3] version --- covimerage/__init__.py | 8 +++----- covimerage/cli.py | 4 ++-- tests/test_cli.py | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/covimerage/__init__.py b/covimerage/__init__.py index 7f7c981d..044a06e9 100755 --- a/covimerage/__init__.py +++ b/covimerage/__init__.py @@ -15,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+') @@ -23,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/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() From d9ce2138adb8149f8f5c1974775fcd242f721f54 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 11 Feb 2019 18:00:18 +0100 Subject: [PATCH 3/3] fixup! WIP: setupmeta --- setup.py | 113 ++++++++++++++++++++++++------------------------------- 1 file changed, 49 insertions(+), 64 deletions(-) diff --git a/setup.py b/setup.py index 9e43d623..b104d3b1 100755 --- a/setup.py +++ b/setup.py @@ -1,70 +1,55 @@ from setuptools import setup + +DEPS_QA = [ + 'flake8', + 'flake8-isort', + 'flake8-per-file-ignores', +] +DEPS_TESTING = [ + 'pytest>=3.3.0', + 'pytest-mock', +] + + setup( name='covimerage', + author='Daniel Hahler', + url='https://github.com/Vimjas/covimerage', + + setup_requires=['setupmeta'], versioning='post', - setup_requires='setupmeta', -) -# DEPS_QA = [ -# 'flake8', -# 'flake8-isort', -# 'flake8-per-file-ignores', -# ] -# DEPS_TESTING = [ -# 'pytest>=3.3.0', -# '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', -# ], -# install_requires=[ -# 'attrs', -# 'click', -# 'coverage', -# ], -# extras_require={ -# 'testing': DEPS_TESTING, -# 'dev': DEPS_TESTING + DEPS_QA + [ -# 'pdbpp', -# 'pytest-pdb', -# ], -# 'qa': DEPS_QA, -# }, -# include_package_data=True, -# license='MIT', -# classifiers=[ -# # Trove classifiers -# # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers -# 'License :: OSI Approved :: MIT License', -# 'Programming Language :: Python', -# 'Programming Language :: Python :: 2.7', -# 'Programming Language :: Python :: 3', -# 'Programming Language :: Python :: 3.3', -# 'Programming Language :: Python :: 3.4', -# 'Programming Language :: Python :: 3.5', -# 'Programming Language :: Python :: 3.6', -# 'Programming Language :: Python :: 3.7', -# 'Programming Language :: Python :: Implementation :: CPython', -# 'Programming Language :: Python :: Implementation :: PyPy' -# ], -# # $ setup.py publish support. -# cmdclass={ -# 'publish': PublishCommand, -# }, -# ) + install_requires=[ + 'attrs', + 'click', + 'coverage', + ], + tests_require=DEPS_TESTING, + extras_require={ + 'testing': DEPS_TESTING, + 'dev': DEPS_TESTING + DEPS_QA + [ + 'pdbpp', + 'pytest-pdb', + ], + 'qa': DEPS_QA, + }, + entry_points={ + 'console_scripts': ['covimerage=covimerage.cli:main'], + }, + classifiers=[ + # Trove classifiers + # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy' + ], +)