-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
95 lines (80 loc) · 2.51 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
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
from distutils.version import StrictVersion
from setuptools import find_packages
from setuptools import setup
from string import ascii_letters
from subprocess import check_output
import sys
import os
name = "master_exterior_ballistics"
# Fetch version from git tags, and write to version.py.
# When git is not available, use stored version.py.
git_tags = os.path.join(os.path.dirname(__file__), ".git", "refs", "tags")
version_py = os.path.join(os.path.dirname(__file__), name, 'version.py')
def get_git_tags():
tags = os.listdir(git_tags)
versions = [StrictVersion(t.lstrip(ascii_letters)) for t in tags]
versions.sort()
return versions
# try using git first
try:
v = check_output(["git", "describe"]).strip()
sections = v.split('-', 3)
version_git = sections.pop(0)
if sections:
incr = sections.pop(0)
version_git += "." + incr
git = ""
if sections:
git = sections.pop(0)
version_git += "+" + git
except:
# look for git tags and use those
try:
versions = get_git_tags()
version_git = str(versions[-1])
except:
# fall back to the existing version.py file
with open(version_py, 'r') as fh:
version_git = open(version_py).read().strip().split('=')[-1].replace('"', '')
version_msg = "# Do not edit this file, versioning is governed by git tags"
with open(version_py, 'w') as fh:
version_msg += os.linesep
version_msg += "__version__ = \"%s\"" % (version_git)
version_msg += os.linesep
fh.write(version_msg)
readme = open("README.md").read()
description = (
"An exterior ballistics tool aimed at historical naval artillery."
)
cmdclass = {}
scripts = []
setup_requires = []
if sys.platform == 'win32':
from install.bdist_wix import bdist_wix
cmdclass = {
'bdist_wix': bdist_wix
}
setup(
name="master_exterior_ballistics",
version="{ver}".format(ver=version_git),
description=description,
long_description=readme,
author="Simon Fowler",
author_email="sjjfowler@gmail.com",
url="https://github.com/sjjf/master_exterior_ballistics",
license="GPLv3",
packages=find_packages(exclude=['install']),
include_package_data=True,
setup_requires=setup_requires,
scripts=scripts,
entry_points={
'console_scripts': [
'meb = master_exterior_ballistics.cli:main',
],
'gui_scripts': [
'meb-gui = master_exterior_ballistics.gui:main',
],
},
cmdclass = cmdclass,
)