Skip to content

Commit

Permalink
cleanup versioning system
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLudwig committed Mar 13, 2021
1 parent 836fa0e commit 6f47441
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 42 deletions.
4 changes: 1 addition & 3 deletions hbmqtt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.

VERSION = (0, 10, 0)
__version__ = "0.10.0a0"
4 changes: 2 additions & 2 deletions hbmqtt/plugins/sys/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# See the file license.txt for copying permission.
from datetime import datetime
import hbmqtt
from hbmqtt.mqtt.packet import PUBLISH
from hbmqtt.codecs import int_to_bytes_str
import asyncio
Expand Down Expand Up @@ -58,8 +59,7 @@ async def on_broker_pre_start(self, *args, **kwargs):

async def on_broker_post_start(self, *args, **kwargs):
self._stats[STAT_START_TIME] = datetime.now()
from hbmqtt.version import get_version
version = 'HBMQTT version ' + get_version()
version = f'HBMQTT version {hbmqtt.__version__}'
self.context.retain_message(DOLLAR_SYS_ROOT + 'version', version.encode())

# Start $SYS topics management
Expand Down
5 changes: 3 additions & 2 deletions hbmqtt/scripts/broker_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import logging
import asyncio
import os

import hbmqtt
from hbmqtt.broker import Broker
from hbmqtt.version import get_version
from docopt import docopt
from hbmqtt.utils import read_yaml_config

Expand Down Expand Up @@ -54,7 +55,7 @@ def main(*args, **kwargs):
logger.fatal("Error: Python 3.4+ is required")
sys.exit(-1)

arguments = docopt(__doc__, version=get_version())
arguments = docopt(__doc__, version=hbmqtt.__version__)
formatter = "[%(asctime)s] :: %(levelname)s - %(message)s"

if arguments['-d']:
Expand Down
5 changes: 3 additions & 2 deletions hbmqtt/scripts/pub_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
import asyncio
import os
import json

import hbmqtt
from hbmqtt.client import MQTTClient, ConnectException
from hbmqtt.version import get_version
from docopt import docopt
from hbmqtt.utils import read_yaml_config

Expand Down Expand Up @@ -130,7 +131,7 @@ def main(*args, **kwargs):
logger.fatal("Error: Python 3.4+ is required")
sys.exit(-1)

arguments = docopt(__doc__, version=get_version())
arguments = docopt(__doc__, version=hbmqtt.__version__)
#print(arguments)
formatter = "[%(asctime)s] :: %(levelname)s - %(message)s"

Expand Down
5 changes: 3 additions & 2 deletions hbmqtt/scripts/sub_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
import asyncio
import os
import json

import hbmqtt
from hbmqtt.client import MQTTClient, ConnectException
from hbmqtt.errors import MQTTException
from hbmqtt.version import get_version
from docopt import docopt
from hbmqtt.mqtt.constants import QOS_0
from hbmqtt.utils import read_yaml_config
Expand Down Expand Up @@ -110,7 +111,7 @@ def main(*args, **kwargs):
logger.fatal("Error: Python 3.4+ is required")
sys.exit(-1)

arguments = docopt(__doc__, version=get_version())
arguments = docopt(__doc__, version=hbmqtt.__version__)
#print(arguments)
formatter = "[%(asctime)s] :: %(levelname)s - %(message)s"

Expand Down
34 changes: 5 additions & 29 deletions hbmqtt/version.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.
import datetime
import os
import subprocess
import warnings

import hbmqtt

# Version Management from https://gist.github.com/gilsondev/2790884
def get_version(version=None):
"Returns a PEP 386-compliant version number from VERSION."
if version is None:
from hbmqtt import VERSION as version
else:
assert len(version) == 5
assert version[3] in ('alpha', 'beta', 'rc', 'final')

# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub = .devN - for pre-alpha releases
# | {a|b|c}N - for alpha, beta and rc releases

parts = 2 if version[2] == 0 else 3
main = '.'.join(str(x) for x in version[:parts])

sub = ''
if version[3] == 'alpha' and version[4] == 0:
git_changeset = get_git_changeset()
if git_changeset:
sub = '.dev%s' % git_changeset

elif version[3] != 'final':
mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
sub = mapping[version[3]] + str(version[4])

return str(main + sub)
def get_version():
warnings.warn("hbmqtt.version.get_version() is deprecated, use hbmqtt.__version__ instead")
return hbmqtt.__version__


def get_git_changeset():
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# See the file license.txt for copying permission.

from setuptools import setup, find_packages
from hbmqtt.version import get_version

setup(
name="amqtt",
version=get_version(),
version="0.10.0a0",
description="MQTT client/broker using Python asyncio",
author="Nicolas Jouanin",
author_email='[email protected]',
Expand Down

0 comments on commit 6f47441

Please sign in to comment.