Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Switch to setupmeta #70

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions covimerage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""The main covimerage module."""
"""
Generate coverage information for Vim script.
"""
import copy
import itertools
import os
Expand All @@ -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+')
Expand All @@ -21,11 +26,6 @@
RE_SNR_PREFIX = re.compile(r'^<SNR>\d+_')


def get_version():
from covimerage.__version__ import version
return version


@attr.s
class Line(object):
"""A source code line."""
Expand Down
4 changes: 2 additions & 2 deletions covimerage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
82 changes: 10 additions & 72 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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 + [
Expand All @@ -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
Expand All @@ -110,8 +52,4 @@ def run(self):
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
],
# $ setup.py publish support.
cmdclass={
'publish': PublishCommand,
},
)
8 changes: 4 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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


Expand Down Expand Up @@ -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()
Expand Down