Skip to content

Commit

Permalink
Single-source package version string (#134)
Browse files Browse the repository at this point in the history
Single-source package version string, see also https://packaging.python.org/guides/single-sourcing-package-version/.
  • Loading branch information
RJ722 authored and jendrikseipp committed Jun 26, 2018
1 parent 544f960 commit fcd9df8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NEWS.rst
@@ -1,6 +1,11 @@
News
====

0.28 (unreleased)
-----------------
* Don't import any Vulture modules in setup.py.


0.27 (2018-06-05)
-----------------
* Report ``while (True): ... else: ...`` as unreachable (thanks @RJ722).
Expand Down
20 changes: 18 additions & 2 deletions setup.py
@@ -1,11 +1,27 @@
#! /usr/bin/env python

import codecs
import os.path
import re
import sys

import setuptools
from setuptools.command.test import test as TestCommand

from vulture import __version__

def read(*parts):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, *parts), 'r') as f:
return f.read()


def find_version(*file_parts):
version_file = read(*file_parts)
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]$", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to find version string.')


class PyTest(TestCommand):
Expand All @@ -24,7 +40,7 @@ def run_tests(self):

setuptools.setup(
name='vulture',
version=__version__,
version=find_version('vulture', 'core.py'),
description='Find dead code',
long_description='\n\n'.join(
[open('README.rst').read(), open('NEWS.rst').read()]),
Expand Down

0 comments on commit fcd9df8

Please sign in to comment.