-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
89 lines (77 loc) · 2.85 KB
/
Copy pathsetup.py
File metadata and controls
89 lines (77 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
import re
import subprocess
from setuptools import setup # type: ignore
from pathlib import Path
with open('README.md') as f:
long_description = f.read()
version_re = re.compile('^Version: (.+)$', re.M)
package_name = 'unittest-mocker'
def get_version():
"""
Reads version from git status or PKG-INFO
https://gist.github.com/pwithnall/7bc5f320b3bdf418265a
"""
d: Path = Path(__file__).absolute().parent
git_dir = d.joinpath('.git')
if git_dir.is_dir():
# Get the version using "git describe".
cmd = 'git describe --tags --match [0-9]*'.split()
try:
version = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
return None
# PEP 386 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
# Don't declare a version "dirty" merely because a time stamp has
# changed. If it is dirty, append a ".dev1" suffix to indicate a
# development revision after the release.
with open(os.devnull, 'w') as fd_devnull:
subprocess.call(['git', 'status'],
stdout=fd_devnull, stderr=fd_devnull)
cmd = 'git diff-index --name-only HEAD'.split()
try:
dirty = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
return None
if dirty != '':
version += '.dev1'
else:
# Extract the version from the PKG-INFO file.
try:
with open('PKG-INFO') as v:
version = version_re.search(v.read()).group(1)
except FileNotFoundError:
version = None
return version
setup(
name=package_name,
version=get_version() or 'dev',
long_description=long_description,
long_description_content_type='text/markdown',
packages=['unittest_mocker'],
url='https://github.com/vertliba/unittest-mocker',
license='MIT',
author='Slava Vertliba',
author_email='vertliba.vv@gmail.com',
description='A little facade for the standard python mocker library to make it user-friendly',
install_requires=[
'',
],
classifiers=[
'Development Status :: 4 - Beta',
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Testing :: Unit",
"Topic :: Software Development :: Testing :: Mocking",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
]
)