Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
124 lines (104 loc) · 3.92 KB
/
Copy pathsetup.py
File metadata and controls
124 lines (104 loc) · 3.92 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
from setuptools import setup, find_packages
import os
import re
import subprocess
name = 'python-ipmi'
version_py = os.path.join(os.path.dirname(__file__), 'pyipmi', 'version.py')
# filled in by 'git archive' (see .gitattributes), e.g. for the tarballs of
# the GitHub releases that contain neither the git repository nor version.py
version_archive = os.path.join(os.path.dirname(__file__), 'version_archive.txt')
def pep440_version(describe):
"""Convert the output of 'git describe' to a PEP 440 version.
0.5.8-77-g7c853b0.dirty -> 0.5.8.dev77+g7c853b0.dirty
Without tags, e.g. in a shallow clone, 'git describe --always' prints
only the abbreviated commit:
7c853b0.dirty -> 0+g7c853b0.dirty
"""
m = re.match(r'^([0-9a-f]{7,40})(\.dirty)?$', describe)
if m:
commit, dirty = m.groups()
return '0+g' + commit + (dirty or '')
m = re.match(r'^(.+?)(?:-(\d+)-(g[0-9a-f]+))?(\.dirty)?$', describe)
tag, distance, commit, dirty = m.groups()
version = tag
if distance:
version += '.dev%s+%s' % (distance, commit)
if dirty:
version += ('.' if distance else '+') + dirty[1:]
return version
def git_version():
return subprocess.check_output(
['git', 'describe', '--tags', '--always', '--dirty=.dirty'],
stderr=subprocess.STDOUT).decode().strip()
def archive_version():
with open(version_archive) as f:
describe = f.read().strip()
# not substituted, the file is not part of a 'git archive'
if not describe or describe.startswith('$Format'):
raise OSError('version not available in %s' % version_archive)
return describe
def write_version_py(version):
with open(version_py, 'w') as f:
f.write('# This file was autogenerated by setup.py\n')
f.write('__version__ = \'%s\'\n' % (version,))
try:
version = pep440_version(git_version())
write_version_py(version)
except (OSError, subprocess.CalledProcessError):
try:
with open(version_py) as f:
d = dict()
exec(f.read(), d)
version = d['__version__']
except OSError:
try:
version = pep440_version(archive_version())
write_version_py(version)
except OSError:
# a valid PEP 440 version, otherwise setuptools refuses to build
version = '0+unknown'
with open('README.md') as f:
readme = f.read()
setup(name=name,
version=version,
description='Pure python IPMI library',
long_description=readme,
long_description_content_type='text/markdown',
url='https://github.com/kontron/python-ipmi',
download_url='https://github.com/kontron/python-ipmi/tarball/' + version,
author='Michael Walle, Heiko Thiery',
author_email='michael.walle@kontron.com, heiko.thiery@kontron.com',
packages=find_packages(exclude=['tests*']),
license='LGPLv2+',
platforms=["any"],
python_requires='>=3.10',
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Software Development :: Libraries :: Python Modules',
],
entry_points={
'console_scripts': [
'ipmitool.py = pyipmi.ipmitool:main',
]
},
test_suite='tests',
tests_require=[
'pytest',
],
install_requires=[
],
extras_require={
'rmcpplus': ['cryptography'],
},
)