Passed
Push — dev ( 9d64c8...509a39 )
by Konstantinos
05:06 queued 03:44
created

setup.run()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
import os
2
import re
3
import sys
4
from setuptools import setup
5
import subprocess
6
from collections import OrderedDict
7
8
9
my_dir = os.path.dirname(os.path.realpath(__file__))
10
11
12
# Modify based on your project
13
project_slug = 'so-magic'
14
changelog_filename = 'CHANGELOG.rst'
15
source_code_repo = f'https://github.com/boromir674/{project_slug}'
16
changelog = f'{source_code_repo}/blob/dev/CHANGELOG.rst'
17
18
19
def run(cmd):
20
    os.environ['PYTHONUNBUFFERED'] = "1"
21
    proc = subprocess.Popen(cmd,
22
                            stdout=subprocess.PIPE,
23
                            stderr=subprocess.STDOUT,
24
                            )
25
    _stdout, _stderr = proc.communicate()
26
27
    return proc.returncode, _stdout, _stderr
28
29
exit_code, stdout, stderr = run([sys.executable, os.path.join(my_dir, 'scripts', 'parse_package_version.py')])
30
if exit_code == 0:
31
    _version = stdout.decode('utf-8').replace('\n', '')
32
    print(f'Parsed version: {_version}')
33
else:
34
    print(stdout)
35
    print('Failed to automatically parse the package version. Either set it manually in setup.py (or stup.cfg) or'
36
          'fix the automation.')
37
    sys.exit(1)
38
39
setup(
40
    name=project_slug,
41
    version=_version,
0 ignored issues
show
introduced by
The variable _version does not seem to be defined for all execution paths.
Loading history...
42
    long_description_content_type='text/x-rst',
43
    test_suite='tests',
44
    install_requires=['attrs', 'numpy', 'scikit-learn', 'pandas', 'somoclu'],
45
    project_urls=OrderedDict([
46
        ('Issue Tracker', f'{source_code_repo}/issues'),
47
        ('Changelog', changelog),
48
        ('Source', source_code_repo),
49
        ('Documentation', f'https://{project_slug}.readthedocs.io/en/dev/'), # "https://blahblah.readthedocs.io/en/v{}/".format(_version)
50
    ]),
51
    download_url=f'https://github.com/boromir674/so-magic/archive/v{_version}.tar.gz',  # help easy_install do its tricks
52
    # extras_require={},
53
    # setup_requires=[],
54
)
55
# py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
56