setup   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 21
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_version() 0 16 2
1
import os
2
import re
3
from setuptools import setup, find_packages
4
5
6
def get_version(source):
7
    """
8
    Retrieve the version of a python distribution.
9
10
    version_file default is the <project_root>/_version.py
11
12
    :param source: Path to project root
13
    :return: Version string
14
    """
15
    version_str_lines = open(os.path.join(source, '_version.py'), "rt").read()
16
    version_str_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
17
    mo = re.search(version_str_regex, version_str_lines, re.M)
18
    if mo:
19
        return mo.group(1)
20
    else:
21
        raise RuntimeError("Unable to find version string in %s." % os.path.join(source, os.path.basename(source)))
22
23
24
setup(name='looptools',
25
      version=get_version('looptools'),
26
      packages=find_packages(),
27
      install_requires=[],
28
      url='https://github.com/sfneal/looptools',
29
      license='MIT Licence',
30
      author='Stephen Neal',
31
      author_email='[email protected]',
32
      description='Lightweight Python help utility.',
33
      long_description='Helper utility functions for logging output, timing processes and counting iterations.')
34