From 86ed2aa6796f38c2210eea0b4a624013acd1feeb Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Tue, 9 Jul 2019 17:46:11 +0300 Subject: [PATCH] Package metadata This commit moves all the package metadata, such as author, license, description, among others into a dedicated file. This approach allows us to remove the necessity of protecting module and requirement imports found in __init__.py. --- python_transport/Pipfile | 14 ------ python_transport/setup.py | 38 ++++++--------- python_transport/wirepas_gateway/__about__.py | 23 ++++++++++ python_transport/wirepas_gateway/__init__.py | 46 ++++++++----------- 4 files changed, 56 insertions(+), 65 deletions(-) delete mode 100644 python_transport/Pipfile create mode 100644 python_transport/wirepas_gateway/__about__.py diff --git a/python_transport/Pipfile b/python_transport/Pipfile deleted file mode 100644 index 19a59cea..00000000 --- a/python_transport/Pipfile +++ /dev/null @@ -1,14 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[dev-packages] - -[packages] -paho-mqtt = ">=1.3.1" -PyGObject = "==3.30.1" -PyYAML = ">=3.13" - -[requires] -python_version = "3.6" diff --git a/python_transport/setup.py b/python_transport/setup.py index da1a8197..0ba7b795 100644 --- a/python_transport/setup.py +++ b/python_transport/setup.py @@ -13,20 +13,15 @@ import os import re -from wirepas_gateway import __title__ -from wirepas_gateway import __version__ - from setuptools import setup, find_packages, Extension +here = os.path.abspath(os.path.dirname(__file__)) readme_file = "README.md" license_file = "LICENSE" with open(readme_file) as f: long_description = f.read() -with open(license_file) as f: - license = f.read() - def get_list_files(root, flist=None): if flist is None: @@ -40,8 +35,7 @@ def get_list_files(root, flist=None): def get_absolute_path(*args): """ Transform relative pathnames into absolute pathnames """ - directory = os.path.dirname(os.path.abspath(__file__)) - return os.path.join(directory, *args) + return os.path.join(here, *args) def get_requirements(*args): @@ -57,23 +51,21 @@ def get_requirements(*args): return sorted(requirements) +about = {} +with open(get_absolute_path("./wirepas_gateway/__about__.py")) as f: + exec(f.read(), about) + setup( - name=__title__, - version=__version__, - description="Wirepas gateway transport service", + name=about["__pkg_name__"], + version=about["__version__"], + description=about["__description__"], long_description=long_description, - author="Wirepas Oy", - author_email="opensource@wirepas.com", - url="https://github.com/wirepas/gateway", - license="Apache-2", - classifiers=[ - "Development Status :: 5 - Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Topic :: Software Development :: Libraries", - "Programming Language :: Python :: 3", - ], - keywords="wirepas connectivity iot mesh", + author=about["__author__"], + author_email=about["__author_email__"], + url=about["__url__"], + license=about["__license__"], + classifiers=about["__classifiers__"], + keywords=about["__keywords__"], packages=find_packages(exclude=["contrib", "docs", "tests", "examples"]), install_requires=get_requirements("requirements.txt"), ext_modules=[ diff --git a/python_transport/wirepas_gateway/__about__.py b/python_transport/wirepas_gateway/__about__.py new file mode 100644 index 00000000..ee55e560 --- /dev/null +++ b/python_transport/wirepas_gateway/__about__.py @@ -0,0 +1,23 @@ +""" + .. Copyright: + Wirepas Oy licensed under Apache License, Version 2.0 + See file LICENSE for full license details. +""" + +__author__ = "Wirepas Ltd" +__author_email__ = "opensource@wirepas.com" +__classifiers__ = [ + "Development Status :: 5 - Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Topic :: Software Development :: Libraries", + "Programming Language :: Python :: 3", +] +__copyright__ = "2019 Wirepas Ltd" +__description__ = "Wirepas gateway transport service that connects the local dbus to a remote MQTT broker." +__license__ = "Apache-2" +__pkg_name__ = "wirepas_gateway" +__title__ = "Wirepas Gateway Transport Service" +__url__ = "https://github.com/wirepas/gateway" +__version__ = "1.2.0rc1" +__keywords__ = "wirepas connectivity iot mesh" diff --git a/python_transport/wirepas_gateway/__init__.py b/python_transport/wirepas_gateway/__init__.py index c1c4420e..46da4321 100644 --- a/python_transport/wirepas_gateway/__init__.py +++ b/python_transport/wirepas_gateway/__init__.py @@ -1,38 +1,28 @@ """ - Wirepas Gateway Client - ========================================= - - This module is property of Wirepas Oy and is meant for its user. Usage - implies knowledge and acceptance of the license agreement provided - through the separate channels. - - The goal of this module is to support the exchange of data from a - Wirepas gateway to a Wirepas or user backend system. + Wirepas Gateway + =============== .. Style guidelines: http://google.github.io/styleguide/pyguide.html - .. Attributes defined from _PEP 484: - https://www.python.org/dev/peps/pep-0484/ - .. Copyright: Wirepas Oy licensed under Apache License, Version 2.0 See file LICENSE for full license details. """ -try: - from . import dbus -except ImportError: - pass - -try: - from . import protocol -except ImportError: - pass - -try: - from . import utils -except ImportError: - pass -__title__ = "wirepas_gateway" -__version__ = "1.2.0rc1" +from . import dbus +from . import protocol +from . import utils + +from .__about__ import ( + __author__, + __author_email__, + __copyright__, + __description__, + __license__, + __pkg_name__, + __title__, + __url__, + __version__, + __keywords__, +)