Merge pull request #1687 from forslund/feature/cleanup-setup

Clean up setup scripts
pull/1681/merge
Matthew D. Scholefield 2018-07-18 10:45:21 -05:00 committed by GitHub
commit 823bfd2828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 276 deletions

2
.gitignore vendored
View File

@ -10,8 +10,6 @@ dist
tornado.web
tornado.ioloop
mycroft/__version__.py
MANIFEST.in
setup.py
scripts/logs/*
logs/*
.coverage

View File

@ -1,7 +1,6 @@
recursive-include mycroft/client/speech/recognizer/model *
include requirements.txt
include mycroft/configuration/*.conf
#include mycroft/tts/mycroft_voice_4.0.flitevox
recursive-include mycroft/res *
recursive-include mycroft/res/snd *
recursive-include mycroft/res/text/* *

View File

@ -1,46 +0,0 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from setuptools import setup
from mycroft.util.setup_base import (
find_all_packages,
required,
get_version,
place_manifest
)
place_manifest('mycroft-base-MANIFEST.in')
setup(
name="mycroft-core",
version=get_version(),
install_requires=[required('requirements.txt')],
packages=find_all_packages("mycroft"),
include_package_data=True,
entry_points={
'console_scripts': [
'mycroft-speech-client=mycroft.client.speech.main:main',
'mycroft-messagebus=mycroft.messagebus.service.main:main',
'mycroft-skills=mycroft.skills.main:main',
'mycroft-audio=mycroft.audio.main:main',
'mycroft-echo-observer=mycroft.messagebus.client.ws:echo',
'mycroft-audio-test=mycroft.util.audio_test:main',
'mycroft-enclosure-client=mycroft.client.enclosure.main:main',
'mycroft-skill-container=mycroft.skills.container:main',
'mycroft-cli-client=mycroft.client.text.main:main'
]
}
)

View File

@ -22,7 +22,7 @@ from mycroft.api import DeviceApi, is_paired
from mycroft.configuration import Configuration
from mycroft.session import SessionManager
from mycroft.util.log import LOG
from mycroft.util.setup_base import get_version
from mycroft.version import CORE_VERSION_STR
from copy import copy
@ -121,7 +121,7 @@ class MetricsAggregator(object):
self._timers = {}
self._levels = {}
self._attributes = {}
self.attr("version", get_version())
self.attr("version", CORE_VERSION_STR)
def increment(self, name, value=1):
cur = self._counters.get(name, 0)
@ -142,7 +142,7 @@ class MetricsAggregator(object):
self._timers = {}
self._levels = {}
self._attributes = {}
self.attr("version", get_version())
self.attr("version", CORE_VERSION_STR)
def attr(self, name, value):
self._attributes[name] = value

View File

@ -1,105 +0,0 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import argparse
import sys
from os.path import dirname, exists, isdir
from mycroft.configuration import Configuration
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.skills.core import create_skill_descriptor, load_skill
from mycroft.skills.intent_service import IntentService
from mycroft.util.log import LOG
class SkillContainer(object):
def __init__(self, args):
params = self.__build_params(args)
if params.config:
Configuration.get([params.config])
if exists(params.lib) and isdir(params.lib):
sys.path.append(params.lib)
sys.path.append(params.dir)
self.dir = params.dir
self.enable_intent = params.enable_intent
self.__init_client(params)
@staticmethod
def __build_params(args):
parser = argparse.ArgumentParser()
parser.add_argument("--config", default="./mycroft.conf")
parser.add_argument("dir", nargs='?', default=dirname(__file__))
parser.add_argument("--lib", default="./lib")
parser.add_argument("--host", default=None)
parser.add_argument("--port", default=None)
parser.add_argument("--use-ssl", action='store_true', default=False)
parser.add_argument("--enable-intent", action='store_true',
default=False)
return parser.parse_args(args)
def __init_client(self, params):
config = Configuration.get().get("websocket")
if not params.host:
params.host = config.get('host')
if not params.port:
params.port = config.get('port')
self.ws = WebsocketClient(host=params.host,
port=params.port,
ssl=params.use_ssl)
# Connect configuration manager to message bus to receive updates
Configuration.init(self.ws)
def load_skill(self):
if self.enable_intent:
IntentService(self.ws)
skill_descriptor = create_skill_descriptor(self.dir)
self.skill = load_skill(skill_descriptor, self.ws, hash(self.dir))
def run(self):
try:
self.ws.on('message', LOG.debug)
self.ws.on('open', self.load_skill)
self.ws.on('error', LOG.error)
self.ws.run_forever()
except Exception as e:
LOG.error("Error: {0}".format(e))
self.stop()
def stop(self):
if self.skill:
self.skill._shutdown()
def main():
container = SkillContainer(sys.argv[1:])
try:
container.run()
except KeyboardInterrupt:
container.stop()
finally:
sys.exit()
if __name__ == "__main__":
main()

View File

@ -1,58 +0,0 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import shutil
import subprocess
import os
from setuptools import find_packages
from mycroft.util.log import LOG
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
def place_manifest(manifest_file):
shutil.copy(manifest_file, "MANIFEST.in")
def get_version():
version = None
try:
from mycroft.version import CORE_VERSION_STR
version = CORE_VERSION_STR
except Exception as e:
try:
version = "dev-" + subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"]).strip()
except subprocess.CalledProcessError as e2:
version = "development"
LOG.debug(e)
LOG.exception(e2)
return version
def required(requirements_file):
with open(os.path.join(BASEDIR, requirements_file), 'r') as f:
requirements = f.read().splitlines()
return [pkg for pkg in requirements if not pkg.startswith("--")]
def find_all_packages(where):
packages = find_packages(where=where, exclude=["*test*"])
return [
os.path.join(where, pkg.replace(".", os.sep))
for pkg in packages] + [where]

76
setup.py Normal file
View File

@ -0,0 +1,76 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from setuptools import setup, find_packages
import os.path
BASEDIR = os.path.abspath(os.path.dirname(__file__))
def get_version():
""" Find the version of mycroft-core"""
version = None
version_file = os.path.join(BASEDIR, 'mycroft', 'version', '__init__.py')
major, minor, build = (None, None, None)
with open(version_file) as f:
for line in f:
if 'CORE_VERSION_MAJOR' in line:
major = line.split('=')[1].strip()
elif 'CORE_VERSION_MINOR' in line:
minor = line.split('=')[1].strip()
elif 'CORE_VERSION_BUILD' in line:
build = line.split('=')[1].strip()
if ((major and minor and build) or
'# END_VERSION_BLOCK' in line):
break
version = '.'.join([major, minor, build])
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()
return [pkg for pkg in requirements
if pkg.strip() and not pkg.startswith("#")]
setup(
name='mycroft-core',
version=get_version(),
license='Apache-2.0',
author='Mycroft A.I.',
author_email='devs@mycroft.ai',
url='https://github.com/MycroftAI/mycroft-core',
description='Mycroft Core',
install_requires=required('requirements.txt'),
packages=find_packages(include=['mycroft*']),
include_package_data=True,
entry_points={
'console_scripts': [
'mycroft-speech-client=mycroft.client.speech.main:main',
'mycroft-messagebus=mycroft.messagebus.service.main:main',
'mycroft-skills=mycroft.skills.main:main',
'mycroft-audio=mycroft.audio.main:main',
'mycroft-echo-observer=mycroft.messagebus.client.ws:echo',
'mycroft-audio-test=mycroft.util.audio_test:main',
'mycroft-enclosure-client=mycroft.client.enclosure.main:main',
'mycroft-skill-container=mycroft.skills.container:main',
'mycroft-cli-client=mycroft.client.text.main:main'
]
}
)

View File

@ -1,5 +0,0 @@
include requirements.txt
include mycroft/configuration/*.conf
include mycroft/util/setup_base.py
include mycroft/__version__.py
include skills-sdk-MANIFEST.in

View File

@ -1,51 +0,0 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from setuptools import setup
from mycroft.util.setup_base import get_version, place_manifest
place_manifest("skills-sdk-MANIFEST.in")
setup(
name="mycroft-skills-sdk",
version=get_version(),
install_requires=[
"mustache==0.1.4",
"configobj==5.0.6",
"pyee==1.0.1",
"adapt-parser==0.2.1",
"padatious==0.1.4"
"websocket-client==0.32.0"
],
packages=[
"mycroft.configuration",
"mycroft.dialog",
"mycroft.filesystem",
"mycroft.messagebus",
"mycroft.messagebus.client",
"mycroft.session",
"mycroft.skills",
"mycroft.util",
"mycroft"
],
include_package_data=True,
entry_points={
'console_scripts': [
'mycroft-skill-container=mycroft.skills.container:main'
]
}
)

View File

@ -46,7 +46,6 @@ function help() {
echo " skillstest run the skill autotests for all skills (requires pytest)"
echo
echo "Utils:"
echo " skill_container <skill> container for running a single skill"
echo " audiotest attempt simple audio validation"
echo " audioaccuracytest more complex audio validation"
echo " sdkdoc generate sdk documentation"
@ -68,7 +67,6 @@ function name-to-script-path() {
"voice") _script=${DIR}/mycroft/client/speech/main.py ;;
"cli") _script=${DIR}/mycroft/client/text/main.py ;;
"wifi") _script=${DIR}/mycroft/client/wifisetup/main.py ;;
"skill_container") _script=${DIR}/mycroft/skills/container.py ;;
"audioaccuracytest") _script=${DIR}/mycroft/audio-accuracy-test/audio_accuracy_test.py ;;
"sdkdoc") _script=${DIR}/doc/generate_sdk_docs.py ;;
"enclosure") _script=${DIR}/mycroft/client/enclosure/main.py ;;
@ -176,9 +174,6 @@ case ${_opt} in
"wifi")
launch-background ${_opt}
;;
"skill_container")
launch-process ${_opt}
;;
"unittest")
source ${VIRTUALENV_ROOT}/bin/activate
pytest test/unittests/ --cov=mycroft "$@"