forked from esynr3z/corsair
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
83 lines (75 loc) · 2.35 KB
/
setup.py
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
import setuptools
from pkg_resources import parse_version
VERSION = "1.0.4"
# Based on https://github.com/tulip-control/dd/blob/885a716a56e82bfee54b0178d0ce38298b85eb6a/setup.py#L68
def git_version(version):
"""Return version with local version identifier."""
import git
repo = git.Repo('.git')
repo.git.status()
# assert versions are increasing
latest_tag = repo.git.describe(
match='v[0-9]*', tags=True, abbrev=0)
assert parse_version(latest_tag) <= parse_version(version), (
latest_tag, version)
sha = repo.head.commit.hexsha[:8]
if repo.is_dirty():
return '{v}.dev0+{sha}.dirty'.format(
v=version, sha=sha)
# commit is clean
# is it release of `version` ?
try:
tag = repo.git.describe(
match='v[0-9]*', exact_match=True,
tags=True, dirty=True)
except git.GitCommandError:
return '{v}.dev0+{sha}'.format(
v=version, sha=sha)
assert tag == 'v' + version, (tag, version)
return version
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
# Get version
VERSION_FILE = 'corsair/_version.py'
try:
version = git_version(VERSION)
except AssertionError:
print('No git info: Assume release.')
version = VERSION
with open(VERSION_FILE, 'w') as f:
f.write("version = '%s'\n" % version)
# Install package
setuptools.setup(
name="corsair",
version=version,
author="esynr3z",
author_email="[email protected]",
description="Control and Status Register map generator for FPGA/ASIC projects",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/esynr3z/corsair",
project_urls={
'Documentation': 'https://corsair.readthedocs.io'
},
packages=setuptools.find_packages(exclude='tests'),
package_data={'corsair': ['templates/*.j2']},
entry_points={
'console_scripts': [
'corsair = corsair.__main__:main',
],
},
install_requires=[
'pyyaml>=5.1',
'jinja2',
'wavedrom',
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
# Clear version info
with open(VERSION_FILE, 'w') as f:
f.write("")