Skip to content

Commit 0be088c

Browse files
committed
use setuptools_scm to extract version from Git
1 parent 7b46bca commit 0be088c

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

databox/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import requests
2+
import pkg_resources
23
from requests.auth import HTTPBasicAuth
34
from os import getenv
45
from json import dumps as json_dumps
56

6-
__version__ = "2.1.0"
7+
_name = "databox"
8+
_version = pkg_resources.get_distribution(_name).version
79

810

911
class Client(object):
@@ -59,8 +61,8 @@ def _push_json(self, data=None, path="/"):
5961
auth=HTTPBasicAuth(self.push_token, ''),
6062
headers={
6163
'Content-Type': 'application/json',
62-
'User-Agent': 'databox-python/' + __version__,
63-
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
64+
'User-Agent': 'databox-python/' + _version,
65+
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
6466
},
6567
data=data
6668
)
@@ -73,8 +75,8 @@ def _get_json(self, path):
7375
auth=HTTPBasicAuth(self.push_token, ''),
7476
headers={
7577
'Content-Type': 'application/json',
76-
'User-Agent': 'databox-python/' + __version__,
77-
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
78+
'User-Agent': 'databox-python/' + _version,
79+
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
7880
}
7981
)
8082

@@ -86,8 +88,8 @@ def _delete_json(self, path):
8688
auth=HTTPBasicAuth(self.push_token, ''),
8789
headers={
8890
'Content-Type': 'application/json',
89-
'User-Agent': 'databox-python/' + __version__,
90-
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
91+
'User-Agent': 'databox-python/' + _version,
92+
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
9193
}
9294
)
9395

setup.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# -*- coding: utf-8 -*-
22
from setuptools import setup, find_packages
3-
from databox import __version__ as version
3+
import pkg_resources
4+
5+
_name = "databox"
6+
_version = pkg_resources.get_distribution(_name).version
47

58
setup(
6-
name="databox",
7-
version=version,
9+
use_scm_version=True,
10+
setup_requires=['setuptools_scm'],
11+
name=_name,
12+
version=_version,
813
author="Databox",
914
author_email="[email protected]",
1015
description="Python wrapper for Databox - Mobile Executive Dashboard.",
1116
url="https://github.com/databox/databox-python",
12-
download_url="https://github.com/databox/databox-python/tarball/"+version,
17+
download_url="https://github.com/databox/databox-python/tarball/"+_version,
1318
keywords=['databox', 'sdk', 'bi'],
1419
license='MIT',
1520
packages=find_packages(exclude=('databox test',)),

0 commit comments

Comments
 (0)