Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
Python Packaging and Settings Reference updates
  • Loading branch information
NeonDaniel authored Jul 27, 2022
2 parents bcad423 + cd98aa4 commit 6c504ad
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 20 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will generate a release distribution and upload it to PyPI

name: Publish Build and GitHub Release
on:
push:
branches:
- master

jobs:
tag_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Version
run: |
VERSION=$(python setup.py --version)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
with:
token: ${{secrets.GITHUB_TOKEN}}
tag: ${{env.VERSION}}
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Build Distribution Packages
run: |
python setup.py bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{secrets.PYPI_TOKEN}}
39 changes: 39 additions & 0 deletions .github/workflows/publish_test_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will generate a distribution and upload it to PyPI

name: Publish Alpha Build
on:
push:
branches:
- dev
paths-ignore:
- 'version.py'

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Increment Version
run: |
VER=$(python setup.py --version)
python version_bump.py
- name: Push Version Change
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Increment Version
- name: Build Distribution Packages
run: |
python setup.py bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{secrets.PYPI_TOKEN}}
22 changes: 22 additions & 0 deletions .github/workflows/skill_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will run unit tests

name: Test Skill
on:
pull_request:
workflow_dispatch:

jobs:
build_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Build Distribution Packages
run: |
python setup.py bdist_wheel
29 changes: 11 additions & 18 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
import subprocess
import webbrowser

# from mycroft.skills.core import MycroftSkill
# from mycroft.util.log import LOG
from adapt.intent import IntentBuilder
from mycroft_bus_client import Message
from neon_utils.message_utils import request_from_mobile
from neon_utils.skills.neon_skill import NeonSkill, LOG
from ovos_utils.gui import is_gui_installed
Expand All @@ -42,19 +41,13 @@
class LauncherSkill(NeonSkill):
def __init__(self):
super(LauncherSkill, self).__init__(name="LauncherSkill")
# if skill_needs_patching(self):
# LOG.warning("Patching Neon skill for non-neon core")
# stub_missing_parameters(self)
self.chromium_opts = ['chrome', 'chromium', 'browser']
self.nautilus_opts = ['nautilus', 'files', 'file explorer']
self.terminal_opts = ['terminal', 'gnome terminal', 'command line']
self.textedit_opts = ['gedit', 'g edit', 'text edit', 'text editor', 'notepad', 'textedit']
self.valid_domains = ('com', 'net', 'org', 'edu', 'gov', 'ai', 'us', 'tech')

def initialize(self):
# launch_program_intent = IntentBuilder("launch_program_intent").require("LaunchKeyword"). \
# require('program').optionally("Neon").build()
# self.register_intent(launch_program_intent, self.launch_program_intent)
browse_website_intent = IntentBuilder("browse_website_intent").require("BrowseKeyword"). \
require("website").optionally("Neon").build()
self.register_intent(browse_website_intent, self.browse_website_intent)
Expand All @@ -65,7 +58,7 @@ def launch_program_intent(self, message):
if self.neon_in_request(message):
if message.context.get("mobile"):
self.speak_dialog("MobileNotSupported", private=True)
elif self.server:
elif message.context.get('klat_data'):
pass
else:
LOG.debug(message.data)
Expand Down Expand Up @@ -159,12 +152,16 @@ def browse_website_intent(self, message):
# TODO: Conditionally speak site name? DM
self.speak_dialog("LaunchWebsite", {"website": website}, private=True)
if request_from_mobile(message):
self.mobile_skill_intent("web_browser", {"link": website}, message)
pass
# TODO
# self.mobile_skill_intent("web_browser", {"link": website}, message)
# self.socket_io_emit('web_browser', f"&link={website}", message.context["flac_filename"])
elif self.server:
self.socket_emit_to_server("navigate to page", [website, message.context["klat_data"]["request_id"]])
# self.socket_io_emit(event="navigate to page", message=website,
# flac_filename=message.context["flac_filename"])
elif message.data.get('klat_data'):
# TODO
self.bus.emit(Message('css.emit',
{"event": "navigate to page",
"data": [website, message.context[
"klat_data"]["request_id"]]}))
elif self.gui_enabled or is_gui_installed():
if not website.startswith("http"):
# TODO: use neon_utils here DM
Expand All @@ -176,10 +173,6 @@ def browse_website_intent(self, message):
# TODO: use neon_utils here DM
website = f"https://{website}"
webbrowser.open_new(website)
# subprocess.Popen(["chromium-browser", website],
# stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
# else:
# self.check_for_signal("CORE_andCase")

def stop(self):
if self.gui_enabled:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
neon-utils~=0.6
neon-utils>=0.6,<2.0.0
101 changes: 101 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from setuptools import setup
from os import getenv, path, walk

SKILL_NAME = "skill-launcher"
SKILL_PKG = SKILL_NAME.replace('-', '_')
# skill_id=package_name:SkillClass
PLUGIN_ENTRY_POINT = f'{SKILL_NAME}.neongeckocom={SKILL_PKG}:LauncherSkill'


def get_requirements(requirements_filename: str):
requirements_file = path.join(path.abspath(path.dirname(__file__)),
requirements_filename)
with open(requirements_file, 'r', encoding='utf-8') as r:
requirements = r.readlines()
requirements = [r.strip() for r in requirements if r.strip()
and not r.strip().startswith("#")]

for i in range(0, len(requirements)):
r = requirements[i]
if "@" in r:
parts = [p.lower() if p.strip().startswith("git+http") else p
for p in r.split('@')]
r = "@".join(parts)
if getenv("GITHUB_TOKEN"):
if "github.com" in r:
requirements[i] = \
r.replace("github.com",
f"{getenv('GITHUB_TOKEN')}@github.com")
return requirements


def find_resource_files():
resource_base_dirs = ("locale", "ui", "vocab", "dialog", "regex")
base_dir = path.dirname(__file__)
package_data = ["skill.json"]
for res in resource_base_dirs:
if path.isdir(path.join(base_dir, res)):
for (directory, _, files) in walk(path.join(base_dir, res)):
if files:
package_data.append(
path.join(directory.replace(base_dir, "").lstrip('/'),
'*'))
# print(package_data)
return package_data


with open("README.md", "r") as f:
long_description = f.read()

with open("./version.py", "r", encoding="utf-8") as v:
for line in v.readlines():
if line.startswith("__version__"):
if '"' in line:
version = line.split('"')[1]
else:
version = line.split("'")[1]

setup(
name=f"neon-{SKILL_NAME}",
version=version,
url=f'https://github.com/NeonGeckoCom/{SKILL_NAME}',
license='BSD-3-Clause',
install_requires=get_requirements("requirements.txt"),
author='Neongecko',
author_email='developers@neon.ai',
long_description=long_description,
long_description_content_type="text/markdown",
package_dir={SKILL_PKG: ""},
packages=[SKILL_PKG],
package_data={SKILL_PKG: find_resource_files()},
include_package_data=True,
entry_points={"ovos.plugin.skill": PLUGIN_ENTRY_POINT}
)
2 changes: 1 addition & 1 deletion skill.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"systemDeps": false,
"requirements": {
"python": [
"neon-utils~=0.6"
"neon-utils>=0.6,<2.0.0"
],
"system": {},
"skill": []
Expand Down
29 changes: 29 additions & 0 deletions version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = "0.2.0"
54 changes: 54 additions & 0 deletions version_bump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import fileinput
from os.path import join, dirname

with open(join(dirname(__file__), "version.py"), "r", encoding="utf-8") as v:
for line in v.readlines():
if line.startswith("__version__"):
if '"' in line:
version = line.split('"')[1]
else:
version = line.split("'")[1]

if "a" not in version:
parts = version.split('.')
parts[-1] = str(int(parts[-1]) + 1)
version = '.'.join(parts)
version = f"{version}a0"
else:
post = version.split("a")[1]
new_post = int(post) + 1
version = version.replace(f"a{post}", f"a{new_post}")

for line in fileinput.input(join(dirname(__file__), "version.py"), inplace=True):
if line.startswith("__version__"):
print(f"__version__ = \"{version}\"")
else:
print(line.rstrip('\n'))

0 comments on commit 6c504ad

Please sign in to comment.