From b3e2ab848c6df05204c350d32d434b7b62e3840f Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 25 Oct 2024 04:08:32 +0100 Subject: [PATCH] feat:semver (#1) --- .gitignore | 21 +++++++++++++ hivemind_mic_sat/__init__.py | 6 +++- requirements.txt | 2 ++ setup.py | 57 ++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c8ece8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +dev.env +.dev_opts.json +.idea +*.code-workspace +*.pyc +*.swp +*~ +*.egg-info/ +build +dist +.coverage +/htmlcov +.installed +.mypy_cache +.vscode +.theia +.venv/ + +# Created by unit tests +.pytest_cache/ +/.gtm/ diff --git a/hivemind_mic_sat/__init__.py b/hivemind_mic_sat/__init__.py index 039c9b0..355d3fa 100644 --- a/hivemind_mic_sat/__init__.py +++ b/hivemind_mic_sat/__init__.py @@ -120,6 +120,10 @@ def run(self): self.running = False -if __name__ == "__main__": +def run(): h = HiveMindMicrophoneClient() h.run() + + +if __name__ == "__main__": + run() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ebaa935 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +hivemind_bus_client +ovos-plugin-manager \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1dda594 --- /dev/null +++ b/setup.py @@ -0,0 +1,57 @@ +import os +from setuptools import setup + +BASEDIR = os.path.abspath(os.path.dirname(__file__)) + + +def get_version(): + """Find the version of the package""" + version = None + version_file = os.path.join(BASEDIR, "hivemind_mic_sat", "version.py") + major, minor, build, alpha = (None, None, None, None) + with open(version_file) as f: + for line in f: + if "VERSION_MAJOR" in line: + major = line.split("=")[1].strip() + elif "VERSION_MINOR" in line: + minor = line.split("=")[1].strip() + elif "VERSION_BUILD" in line: + build = line.split("=")[1].strip() + elif "VERSION_ALPHA" in line: + alpha = line.split("=")[1].strip() + + if (major and minor and build and alpha) or "# END_VERSION_BLOCK" in line: + break + version = f"{major}.{minor}.{build}" + if int(alpha) > 0: + version += f"a{alpha}" + return version + + +def required(requirements_file): + """Read requirements file and remove comments and empty lines.""" + with open(os.path.join(BASEDIR, requirements_file), "r") as f: + requirements = f.read().splitlines() + if "MYCROFT_LOOSE_REQUIREMENTS" in os.environ: + print("USING LOOSE REQUIREMENTS!") + requirements = [ + r.replace("==", ">=").replace("~=", ">=") for r in requirements + ] + return [pkg for pkg in requirements if pkg.strip() and not pkg.startswith("#")] + + +setup( + name="hivemind-mic-satellite", + version=get_version(), + packages=["hivemind_mic_sat"], + include_package_data=True, + install_requires=required("requirements.txt"), + url="https://github.com/JarbasHiveMind/hivemind-mic-satellite", + license="Apache2.0", + author="jarbasAI", + author_email="jarbasai@mailfence.com", + description="Remote microphone for HiveMind", + entry_points={ + "console_scripts": ["hivemind-mic-sat=hivemind_mic_sat:run"] + }, +)