diff --git a/.travis.yml b/.travis.yml index 32b18b2..f8b48b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ notifications: secure: Mi4B2z6X0tE2vyfuF359/eXAxu8IgnOWT6REHBGYTGfB+baKtowBmQeMBTXe6aZFUuQ4vgnZAiq7KWgBwkpv4RuaP1BO9XkPwlnfXQOv6u4nIECGJcTiE4XTMl6zX1r4Km0X6kD9jP+Rvm6YCE6eiDf+xqLsMwECQstXYehwrT53fXnOYXhqP2girK+BFhJ5M2OYvz/K+kC+rMOGQjddic9SkNDYczTo22kVJ3OhIBkEC95UkfcFBEGE5/LP25zON9ptXv73aiuWjCNeaO/YBKog/hRJyYPdlwdaY7ENYiJHFCz/dRqDv32cNy28TTzdDOuE5Jic1OTMfvG2xnSjBZA/7R+msHqoVJ6Wn+IGlKvHCc4/etVoNpGyv7/tuXwAIY8s6ied4bLEvpSs/cEK0FMidZRcUoZ1+a2j28/rY7aqYef4sA0DwzplWMEoA680AAA4e0nGXIBbM6eb6aldd4oiIlW2F1PX0wGOXhdKYh7/rb2OxJ27rJTKsW8gbRN2OT3M9P5pdTAj5P7MmNIjKbJSxSemGhcfQIRl3FWn6oKIgQNbtWSkLEVh09JhjZJhnVlRtsPYr8rQQaMSc1EyQqDLicEB4lt0+Oe+Qq82HYWl6XfnzpTYc71mKrtjckdlDxBcAS9Rv1XNmBwQH9AbwcmifM0wOPJ5jiYXLmi4ucw= before_deploy: - - echo $TRAVIS_TAG > VERSION + - echo "__version__ = '$TRAVIS_TAG'" > predicthq/version.py deploy: provider: pypi diff --git a/VERSION b/VERSION deleted file mode 100644 index 9beca35..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.15 \ No newline at end of file diff --git a/predicthq/__init__.py b/predicthq/__init__.py index cd735b3..b6ed90b 100644 --- a/predicthq/__init__.py +++ b/predicthq/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals, absolute_import, print_function -from .client import Client +from .client import Client, __version__ assert Client diff --git a/predicthq/client.py b/predicthq/client.py index 6ddcaf4..e6e2cfe 100644 --- a/predicthq/client.py +++ b/predicthq/client.py @@ -10,7 +10,7 @@ from .config import config from .exceptions import ClientError, ServerError - +from .version import __version__ class Client(object): @@ -35,7 +35,7 @@ def initialize_endpoints(self): self.places = endpoints.PlacesEndpoint(proxy(self)) def get_headers(self, headers): - _headers = {"Accept": "application/json",} + _headers = {"Accept": "application/json", "x-user-agent": "PHQ-Python-SDK/{}".format(__version__)} if self.access_token: _headers.update({"Authorization": "Bearer {}".format(self.access_token),}) _headers.update(**headers) diff --git a/predicthq/version.py b/predicthq/version.py new file mode 100644 index 0000000..8db2f72 --- /dev/null +++ b/predicthq/version.py @@ -0,0 +1 @@ +__version__ = '0.0.15' diff --git a/setup.py b/setup.py index c6a49ce..f85e67c 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,8 @@ import codecs from setuptools import setup, find_packages +here = os.path.abspath(os.path.dirname(__file__)) + def read(*parts): filename = os.path.join(os.path.dirname(__file__), *parts) @@ -11,7 +13,11 @@ def read(*parts): return fp.read() -VERSION = read("VERSION").strip() +about = {} + +# Load version number dynamically +with open(os.path.join(here, 'predicthq', 'version.py'), 'r') as f: + exec(f.read(), about) REPO_URL = "https://github.com/predicthq/sdk-py" @@ -26,7 +32,7 @@ def read(*parts): setup( name="predicthq", - version=VERSION, + version=about['__version__'], description="PredictHQ Event Intelligence", long_description=LONG_DESCRIPTION, license="MIT",