This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
executable file
·89 lines (74 loc) · 2.5 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
#!/usr/bin/env python
import os
import os.path
import subprocess
from setuptools import setup, find_namespace_packages
HERE = os.path.abspath(os.path.dirname(__file__))
# gets the version from the latest tag via git describe
# so we don't have to do anything to manage version number
# aside from tagging releases
def git_version(gitdir, default='0.0.0'):
try:
desc = subprocess.run(
[
'git',
'--git-dir',
gitdir,
'describe',
'--long',
'--tags',
'--dirty',
],
capture_output=True,
)
except Exception:
return default
if desc.returncode != 0:
return default
# example output: v0.5.1-8-gb38722d-dirty
# parts are:
# 0 - last tag
# 1 - commits since last tag (0 if same commit as tag)
# 2 - short hash of current commit
# 3 - dirty (if repo state is dirty)
parts = desc.stdout.decode().strip().lstrip('v').split('-', maxsplit=2)
if int(parts[1]) > 0 or 'dirty' in parts[2]:
return f'{parts[0]}+{parts[1]}.{parts[2].replace("-",".")}'
else:
return parts[0]
# in the case of a tagged release, we
# are passed a version in an env var
VERSION = os.environ.get(
'CIRRUS_VERSION',
git_version(os.path.join(HERE, '.git')),
)
with open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f:
readme = f.read()
with open(os.path.join(HERE, 'requirements.txt'), encoding='utf-8') as f:
reqs = f.read().split('\n')
install_requires = [x.strip() for x in reqs if 'git+' not in x]
dependency_links = [x.strip().replace('git+', '') for x in reqs if 'git+' not in x]
setup(
name='cirrus-lib',
author='Matthew Hanson (matthewhanson), Element 84',
version=VERSION,
description='Cirrus Library',
long_description=readme,
long_description_content_type='text/markdown',
url='https://github.com/cirrus-geo/cirrus-lib.git',
license='Apache-2.0',
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
keywords='',
packages=find_namespace_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
install_requires=install_requires,
dependency_links=dependency_links,
)