From 3bb74aecbb7fa7fa592e498b33a768d4e40bfe85 Mon Sep 17 00:00:00 2001
From: Daniel K Lyons <dlyons@nrao.edu>
Date: Mon, 15 Jun 2020 13:50:38 -0600
Subject: [PATCH] Pymygdala build support

---
 apps/cli/executables/datafetcher/setup.py     |  2 +-
 apps/cli/launchers/pymygdala/README.md        |  5 +++
 apps/cli/launchers/pymygdala/setup.py         | 35 +++++++++++++++++++
 .../pymygdala/{ => src/pymygdala}/__init__.py |  2 +-
 .../pymygdala/src/pymygdala/_version.py       |  2 ++
 .../pymygdala/{ => src/pymygdala}/commands.py |  5 ++-
 .../pymygdala/{ => src/pymygdala}/models.py   |  0
 environment.yml                               |  1 +
 8 files changed, 47 insertions(+), 5 deletions(-)
 create mode 100644 apps/cli/launchers/pymygdala/README.md
 create mode 100644 apps/cli/launchers/pymygdala/setup.py
 rename apps/cli/launchers/pymygdala/{ => src/pymygdala}/__init__.py (85%)
 create mode 100644 apps/cli/launchers/pymygdala/src/pymygdala/_version.py
 rename apps/cli/launchers/pymygdala/{ => src/pymygdala}/commands.py (98%)
 rename apps/cli/launchers/pymygdala/{ => src/pymygdala}/models.py (100%)

diff --git a/apps/cli/executables/datafetcher/setup.py b/apps/cli/executables/datafetcher/setup.py
index e22756a4f..e8f5d2cd3 100644
--- a/apps/cli/executables/datafetcher/setup.py
+++ b/apps/cli/executables/datafetcher/setup.py
@@ -10,7 +10,7 @@ README = Path('README.md').read_text()
 setup(
     name=Path().absolute().name,
     version=VERSION,
-    description='NRAO Archive Job Epilogue Script',
+    description='NRAO Archive Data Fetcher Script',
     long_description=README,
     author='NRAO SSA Team',
     author_email='dms-ssa@nrao.edu',
diff --git a/apps/cli/launchers/pymygdala/README.md b/apps/cli/launchers/pymygdala/README.md
new file mode 100644
index 000000000..8eda85ae4
--- /dev/null
+++ b/apps/cli/launchers/pymygdala/README.md
@@ -0,0 +1,5 @@
+# Pymygdala
+
+Module contains libraries for accessing AMQP and sending NRAO-flavored AMQP events.
+
+If you think you might want to use this library, consider using the `events` library instead if possible.
diff --git a/apps/cli/launchers/pymygdala/setup.py b/apps/cli/launchers/pymygdala/setup.py
new file mode 100644
index 000000000..27b8db5fc
--- /dev/null
+++ b/apps/cli/launchers/pymygdala/setup.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from pathlib import Path
+from setuptools import setup, find_packages
+
+VERSION = open('src/pymygdala/_version.py').readlines()[-1].split()[-1].strip("\"'")
+README = Path('README.md').read_text()
+
+setup(
+    name=Path().absolute().name,
+    version=VERSION,
+    description='NRAO Archive Pymygdala General Message Sender',
+    long_description=README,
+    author='NRAO SSA Team',
+    author_email='dms-ssa@nrao.edu',
+    url='TBD',
+    license="GPL",
+    install_requires=['simplejson', 'pika', 'pycapo'],
+    keywords=[],
+    packages=['pymygdala'],
+    package_dir={'':'src'},
+    classifiers=[
+        'Programming Language :: Python :: 3.8'
+    ],
+    entry_points={
+        'console_scripts': [
+            'pym-sendevent    = pymygdala.commands:sendevent',
+            'pym-dumplogs     = pymygdala.commands:dumplogs',
+            'pym-sendlog      = pymygdala.commands:sendlog',
+            'ingest-complete  = pymygdala.commands:ingestion_complete',
+            'logwrapper       = pymygdala.commands:amqp_logging_shell_wrapper',
+        ]
+    },
+)
diff --git a/apps/cli/launchers/pymygdala/__init__.py b/apps/cli/launchers/pymygdala/src/pymygdala/__init__.py
similarity index 85%
rename from apps/cli/launchers/pymygdala/__init__.py
rename to apps/cli/launchers/pymygdala/src/pymygdala/__init__.py
index c7d048f88..2bd360421 100644
--- a/apps/cli/launchers/pymygdala/__init__.py
+++ b/apps/cli/launchers/pymygdala/src/pymygdala/__init__.py
@@ -6,4 +6,4 @@ Using this library you can log messages to RabbitMQ with a standard-isg logging
 Many (most?) of the defaults for things like routing keys, exchange names and CAPO properties are heavily NRAO-centric but you can order-ride them if you want.
 """
 
-from pyat.pymygdala.models import (LogHandler, LogDumper, SendEvent, SendNRAOEvent, RPCEvent)
+from .models import (LogHandler, LogDumper, SendEvent, SendNRAOEvent, RPCEvent)
diff --git a/apps/cli/launchers/pymygdala/src/pymygdala/_version.py b/apps/cli/launchers/pymygdala/src/pymygdala/_version.py
new file mode 100644
index 000000000..41dbad0d2
--- /dev/null
+++ b/apps/cli/launchers/pymygdala/src/pymygdala/_version.py
@@ -0,0 +1,2 @@
+""" Version information for this package, don't put anything else here. """
+___version___ = '0.1.5'
diff --git a/apps/cli/launchers/pymygdala/commands.py b/apps/cli/launchers/pymygdala/src/pymygdala/commands.py
similarity index 98%
rename from apps/cli/launchers/pymygdala/commands.py
rename to apps/cli/launchers/pymygdala/src/pymygdala/commands.py
index 126c28ef6..bb322b070 100644
--- a/apps/cli/launchers/pymygdala/commands.py
+++ b/apps/cli/launchers/pymygdala/src/pymygdala/commands.py
@@ -6,9 +6,8 @@ import sys
 import json
 import re
 
-from pyat import version
-from pyat.pymygdala import (LogDumper, LogHandler, SendEvent, SendNRAOEvent)
-from pyat.pymygdala.models import MotDBroadcaster
+from ._version import ___version___ as version
+from .models import LogDumper, LogHandler, SendEvent, SendNRAOEvent, MotDBroadcaster
 
 _ERR_MISSING_PROFILE = r"""ERROR: {script} can't deduce the 'profile', give it the --profile argument or set the CAPO_PROFILE environment variable! Geeze!
 
diff --git a/apps/cli/launchers/pymygdala/models.py b/apps/cli/launchers/pymygdala/src/pymygdala/models.py
similarity index 100%
rename from apps/cli/launchers/pymygdala/models.py
rename to apps/cli/launchers/pymygdala/src/pymygdala/models.py
diff --git a/environment.yml b/environment.yml
index ccde529f9..861bc1776 100644
--- a/environment.yml
+++ b/environment.yml
@@ -24,3 +24,4 @@ dependencies:
   - waitress=1.4
   - blessings=1.7
   - pytest=5.4
+  - simplejson=3.17
-- 
GitLab