Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
Feature: feature-more-config-usage (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
bossjones committed Aug 8, 2018
1 parent f92b44b commit a724062
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 35 deletions.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1084,3 +1084,26 @@ install-deps-all-osx:
# ln -sfn $$file $(CURDIR)/roles/$f; \
# done; \
# ls -lta $(CURDIR)/roles/; \
meson-build:
meson mesonbuild/

ninja-build:
ninja-build -C mesonbuild/

ninja-install:
ninja-build -C mesonbuild/ install


meson-install: meson-build ninja-install

meson-build-uninstalled:
meson mesonbuild/ --prefix=$$(pwd)/uninstalled --libdir=lib

ninja-build-uninstalled:
ninja-build -C mesonbuild/

ninja-install-uninstalled:
ninja-build -C mesonbuild/ install

meson-install-uninstalled: meson-build-uninstalled ninja-install-uninstalled
15 changes: 15 additions & 0 deletions RESEARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -2338,3 +2338,18 @@ Implementations based on this ^ :
|2.4.2| hyenatop in /usr/local/Cellar
○ → find . -name "*pkgconfig" -print
```


# The most basic jhbuildrc( used on vagrant 16.04 instance )

```
import os
prefix='/home/pi/jhbuild'
checkoutroot='/home/pi/gnome'
moduleset = 'gnome-world'
interact = False
makeargs = '-j4'
os.environ['CFLAGS'] = '-fPIC -O0 -ggdb -fno-inline -fno-omit-frame-pointer'
os.environ['PYTHON'] = '/usr/bin/python3'
os.environ['PROMPT_COMMAND'] = ''
```
4 changes: 2 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
subdir('icons')

subdir('sounds')
subdir('speech')
# subdir('sounds')
# subdir('speech')

# FIXME: Re-enable these
# # Validating the desktop file
Expand Down
100 changes: 88 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ project('scarlett-os', ['c'], version: '0.1.0')
# Imports the given extension module. Returns an opaque object that can be used to call the methods of the module. Here's an example for a hypothetical testmod module.
gnome = import('gnome')
python = import('python3')
py3 = python.find_python()
py3_dep = dependency('python3', required : false)
pkg = import('pkgconfig')

# Make sure Python is installed and found
if not python.find_python().found()
Expand All @@ -22,7 +25,11 @@ endif

# FIXME: Replace this with gstreamer-espeak
# gst_transcoder_dep = dependency('gst-transcoder-1.0', version : '>= 1.8.1', fallback : ['gst-transcoder', 'gst_transcoder_dep'])
espeak_dep = dependency('espeak-ng', fallback : ['espeak', 'espeak_dep'])
espeak_dep = dependency('espeak-ng', required : false)

if not espeak_dep.found()
espeak_dep = dependency('espeak', required : false)
endif

pkgdatadir = join_paths(get_option('datadir'), meson.project_name())

Expand Down Expand Up @@ -52,17 +59,38 @@ PKGLIB_DIR = join_paths(get_option('prefix'), get_option('libdir'), PROJECT_RDNN

# Dependencies

python_dep = dependency('python3', version : '>= 3.5')
gst_dep = dependency('gstreamer-1.0', version : '>= 1.8.2')
python_dep = dependency('python3')
gst_dep = dependency('gstreamer-1.0')
cairo_dep = dependency('cairo')
pycairo_dep = dependency('py3cairo')

dependency('gobject-introspection-1.0', version: '>= 1.35.0')
dependency('gtk+-3.0', version: '>= 3.19.3')
dependency('pygobject-3.0', version: '>= 3.21.1')
dependency('py3cairo', version: '>= 1.14.0')
dependency('sphinxbase')
dependency('pocketsphinx')
go_dep = dependency('gobject-introspection-1.0')
# Dependency: What this declaration means is that first Meson tries to look up the dependency from the system (such as by using pkg-config). If it is not available, then it builds subproject named foo and from that extracts a variable foo_dep. That means that the return value of this function is either an external or an internal dependency object. Since they can be used interchangeably, the rest of the build definitions do not need to care which one it is. Meson will take care of all the work behind the scenes to make this work.
# EXAMPLE: foo_dep = dependency('foo', fallback : ['foo', 'foo_dep'])

gtk3_dep = dependency('gtk+-3.0')
pygobject_dep = dependency('pygobject-3.0')
sb_dep = dependency('sphinxbase', method : 'pkg-config')
ps_dep = dependency('pocketsphinx', method : 'pkg-config')
dbus1_dep = dependency('dbus-1')

glib_dep = dependency ('glib-2.0', version: '>=2.32', required: true)
gobject_dep = dependency ('gobject-2.0', required: true)
gio_dep = dependency ('gio-2.0', required: true)

# NOTE: Same as pkg-config --variable datadir pocketsphinx
ps_datadir = ps_dep.get_pkgconfig_variable('datadir')
gst_libdir = gst_dep.get_pkgconfig_variable('libdir')
gst_plugin_path = join_paths(gst_libdir, 'gstreamer-1.0')

ps_model_dir = join_paths(ps_datadir, 'model')

# total 30536
# drwxrwxr-x 4 pi pi 4096 Jul 5 23:54 ./
# drwxrwxr-x 5 pi pi 4096 Jul 5 23:54 ../
# drwxrwxr-x 3 pi pi 4096 Sep 11 2016 model/
# -rw-rw-r-- 1 pi pi 31251191 Jul 5 23:54 model.tar.gz
# drwxrwxr-x 2 pi pi 4096 Oct 1 2016 swig/

# Subproject(): Takes the project specified in the positional argument and brings that
# in the current build specification by returning a subproject object.
Expand All @@ -80,6 +108,18 @@ dependency('pocketsphinx')
# 'pkglibdir=' + PKGLIB_DIR
# ])

# Add a way to build all GStreamer as a ScarlettOS Subproject
if get_option('build-gst')
subproject('gst-build', default_options: ['enable_python=true',
'disable_gstreamer_sharp=true', 'disable_rtsp_server=true',
'gst-devtools:disable_gtkdoc=true',
'gst-editing-services:disable_gtkdoc=true',
'gst-plugins-base:disable_gtkdoc=true',
'gstreamer:disable_gtkdoc=true',
])
subproject('gst-transcoder')
endif

subdir('data')

# FIXME: This is from Pitivi, add this in to our stuff
Expand All @@ -88,8 +128,11 @@ geteenvvar = find_program('getenvvar.py')
cdata = configuration_data()
cdata.set('CONFIGURED_PYTHONPATH', run_command(geteenvvar, 'PYTHONPATH').stdout().strip())
cdata.set('CONFIGURED_LD_LIBRARY_PATH', run_command(geteenvvar, 'LD_LIBRARY_PATH').stdout().strip())
cdata.set('CONFIGURED_GST_PLUGIN_PATH', run_command(geteenvvar, 'GST_PLUGIN_PATH').stdout().strip())
cdata.set('CONFIGURED_GST_PLUGIN_SYSTEM_PATH', run_command(geteenvvar, 'GST_PLUGIN_SYSTEM_PATH').stdout().strip())
cdata.set('CONFIGURED_GI_TYPELIB_PATH', gst_plugin_path)
cdata.set('CONFIGURED_GST_PLUGIN_PATH', gst_plugin_path)
# cdata.set('CONFIGURED_GST_PLUGIN_SYSTEM_PATH', run_command(geteenvvar, 'GST_PLUGIN_SYSTEM_PATH').stdout().strip())
cdata.set('SCARLETT_OS_CONFIG_POCKETSPHINX_HMM', ps_model_dir)
cdata.set('CONFIGURED_GST_PLUGIN_SYSTEM_PATH', gst_plugin_path)
cdata.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
cdata.set('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
cdata.set('PACKAGE_NAME', 'ScarlettOS')
Expand All @@ -98,9 +141,30 @@ cdata.set('GITVERSION', GITVERSION)
cdata.set('VERSION', meson.project_version())
cdata.set('BUILDDIR', meson.current_build_dir())

# FIXME: probably need to set these guys too? 8/7/2018
# os.environ['CFLAGS'] = '-fPIC -O0 -ggdb -fno-inline -fno-omit-frame-pointer'
# os.environ['PYTHON'] = 'python'
# os.environ['GSTREAMER'] = '1.0'
# os.environ['ENABLE_PYTHON3'] = 'yes'
# os.environ['ENABLE_GTK'] = 'yes'
# os.environ['PYTHON_VERSION'] = '3.5'
# os.environ['CFLAGS'] = '-fPIC -O0 -ggdb -fno-inline -fno-omit-frame-pointer'
# os.environ['MAKEFLAGS'] = '-j4'
# os.environ['PREFIX'] = '/home/pi/jhbuild'
# os.environ['JHBUILD'] = '/home/pi/gnome'
# os.environ['PATH'] = '/home/pi/jhbuild/bin:/home/pi/jhbuild/sbin:/home/pi/jhbuild/bin:/home/pi/jhbuild/sbin:/home/pi/.pyenv/shims:~/.pyenv/bin/:~/.bin:/home/pi/.local/bin:/home/pi/.rbenv/shims:/home/pi/.rbenv/bin:/home/pi/.nvm/versions/node/v8.7.0/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/pi/.rvm/bin:/home/pi/.go/bin:/home/pi/go/bin'
# os.environ['LD_LIBRARY_PATH'] = '/home/pi/jhbuild/lib:/usr/lib'
# os.environ['PYTHONPATH'] = '/home/pi/.pyenv/versions/3.5.2/lib/python3.5/site-packages:/home/pi/jhbuild/lib/python3.5/site-packages:/usr/lib/python3.5/site-packages'
# os.environ['PKG_CONFIG_PATH'] = '/home/pi/.pyenv/versions/3.5.2/lib/pkgconfig:/home/pi/jhbuild/lib/pkgconfig:/home/pi/jhbuild/share/pkgconfig:/usr/lib/pkgconfig'
# os.environ['XDG_DATA_DIRS'] = '/home/pi/jhbuild/share:/usr/share'
# os.environ['XDG_CONFIG_DIRS'] = '/home/pi/jhbuild/etc/xdg'
# os.environ['CC'] = 'gcc'
# os.environ['PROJECT_HOME'] = '/home/pi/dev'
# os.environ['PYTHONSTARTUP'] = '/home/pi/.pythonrc'

scarlett_os_install_dir = get_option('libdir') + '/scarlett_os/python/'

# run_command(python, '-m', 'compileall', meson.current_source_dir() + '/pitivi')
run_command(py3, '-m', 'compileall', meson.current_source_dir() + '/scarlett_os')
install_subdir('scarlett_os', install_dir: scarlett_os_install_dir)

# SOURCE: pitivi
Expand All @@ -114,6 +178,18 @@ install_data(configure_file, install_dir: scarlett_os_install_dir + 'scarlett_os
# FIXME work around to get testsuite working
run_command('cp', configure_file, meson.current_source_dir() + '/scarlett_os')

# pocketsphinx model
# install_data(ps_model_dir, install_dir: scarlett_os_install_dir + 'scarlett_os')
# run_command('cp', '-a', ps_model_dir, meson.current_source_dir() + '/scarlett_os')

# install_subdir('gstpresets', install_dir: pkgdatadir)

# custom_target('pocketsphinx/model',
# output : 'model',
# input : ps_model_dir,
# install : true,
# install_dir : pkgdatadir)

subdir('bin')
# if not get_option('disable-help')
# subdir('help')
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SOURCE: https://github.com/GNOME/pitivi/blob/0fcc448e098d430f226bc6a2912a3909c2429400/meson_options.txt
option('disable-help', type : 'boolean', value : false)
option('build-gst', type : 'boolean', value : false)

# SOURCE: https://github.com/GNOME/gtk/blob/1b62d28cbb561c12f43f08819e1714c8bf068ef7/meson_options.txt
# GDK backends
Expand Down
2 changes: 1 addition & 1 deletion scarlett_os/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import scarlett_os.core as core
from scarlett_os.exceptions import ScarlettError
from scarlett_os.utility.yaml import load_yaml
# from scarlett_os.utility.yaml import load_yaml
import scarlett_os.helpers.config_validation as cv
from scarlett_os.helpers.entity import set_customize
from scarlett_os.utility import dt as date_utility, location as loc_utility
Expand Down
6 changes: 3 additions & 3 deletions scarlett_os/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import itertools

# python2 uses from itertools import imap, else just imap=map
map = (
itertools.imap if sys.version_info < (3,) else map
) # pylint: disable=no-member
# map = (
# itertools.imap if sys.version_info < (3,) else map
# ) # pylint: disable=no-member

import errno
from os import environ as environ
Expand Down
2 changes: 1 addition & 1 deletion scarlett_os/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from scarlett_os.core import valid_entity_id
from scarlett_os.exceptions import ScarlettError
from scarlett_os.utility.yaml import load_yaml
# from scarlett_os.utility.yaml import load_yaml
import scarlett_os.helpers.config_validation as cv
from scarlett_os.helpers.entity import set_customize
from scarlett_os.utility import dt as date_utility, location as loc_utility
Expand Down
13 changes: 10 additions & 3 deletions scarlett_os/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ def _on_state_changed(self, bus, msg):
Gst.debug_bin_to_dot_file(
msg.src, Gst.DebugGraphDetails.ALL, "generator-player"
)
os.system("/usr/bin/dot" + " -Tpng -o " + pngfile + " " + dotfile)

cmd = "/usr/bin/dot -Tpng -o {pngfile} {dotfile}".format(
pngfile=pngfile, dotfile=dotfile
)
os.system(cmd)
print("pipeline dot file created in " + os.getenv("GST_DEBUG_DUMP_DOT_DIR"))

def _listElements(self, bin, level=0):
Expand All @@ -372,7 +376,7 @@ def _iteratePads(self, element):
pad = iterator.next()
if pad[1] is None:
break
logger.debug("pad: " + str(pad[1]))
logger.debug("pad: {}".format(str(pad[1])))
except AttributeError:
pass

Expand Down Expand Up @@ -405,7 +409,10 @@ def on_debug_activate(self):
Gst.debug_bin_to_dot_file(
self.pipeline, Gst.DebugGraphDetails.ALL, "generator-player"
)
os.system("/usr/bin/dot" + " -Tpng -o " + pngfile + " " + dotfile)
cmd = "/usr/bin/dot -Tpng -o {pngfile} {dotfile}".format(
pngfile=pngfile, dotfile=dotfile
)
os.system(cmd)

# Gstreamer callbacks.

Expand Down
2 changes: 1 addition & 1 deletion scarlett_os/shim.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _get_root_dir():

def in_devel():
"""Returns whether the app is run from a git checkout."""
return os.environ.get("PITIVI_DEVELOPMENT", "0") != "0"
return os.environ.get("SCARLETT_DEVELOPMENT", "0") != "0"

LIBDIR = '@LIBDIR@'
PKGDATADIR = '@DATADIR@/@PACKAGE@'
Expand Down
9 changes: 9 additions & 0 deletions scarlett_os/sounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-

"""Scarlett Sounds Module."""

import os

STATIC_SOUNDS_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "data", "sounds"
)
4 changes: 2 additions & 2 deletions scarlett_os/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from scarlett_os.utility import thread as s_thread
from scarlett_os import subprocess
from scarlett_os import player
from scarlett_os.user import get_user_project_base_path
from scarlett_os.sounds import STATIC_SOUNDS_PATH

from scarlett_os.common.configure.ruamel_config import ConfigManager

Expand Down Expand Up @@ -164,6 +164,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
for scarlett_text in tts_list:
with s_thread.time_logger("Scarlett Speaks"):
path_to_espeak_tmp_wav = os.path.join(
get_user_project_base_path(), "espeak_tmp.wav"
STATIC_SOUNDS_PATH, "espeak_tmp.wav"
)
ScarlettSpeaker(text_to_speak=scarlett_text, wavpath=path_to_espeak_tmp_wav)
9 changes: 4 additions & 5 deletions scarlett_os/tasker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@

from scarlett_os.utility.generators import GIdleThread

from scarlett_os.user import get_user_project_base_path

from scarlett_os.sounds import STATIC_SOUNDS_PATH

#######################################
# FIXME: Temporary, till we figure out best way to approach logging module
Expand Down Expand Up @@ -71,8 +72,6 @@
player_run = False
command_run = False

STATIC_SOUNDS_PATH = os.path.join(get_user_project_base_path() + "/static", "sounds")

pause_in_seconds = 1


Expand All @@ -91,7 +90,7 @@ def get_path(sound_type):
@staticmethod
def get_speaker_path():
path_to_espeak_tmp_wav = os.path.join(
get_user_project_base_path(), "espeak_tmp.wav"
STATIC_SOUNDS_PATH, "espeak_tmp.wav"
)
return [path_to_espeak_tmp_wav]

Expand Down Expand Up @@ -306,7 +305,7 @@ def prepare(self, player_cb, command_cb, connected_to_listener_cb):
self._cancel_signal_callback = player_cb
self._connect_signal_callback = connected_to_listener_cb
self._prep_tmp_espeak(
wavepath=os.path.join(get_user_project_base_path(), "espeak_tmp.wav")
wavepath=os.path.join(STATIC_SOUNDS_PATH, "espeak_tmp.wav")
)

def configure(self):
Expand Down
Empty file added subprojects/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions tests/integrationtests/test_integration_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from tests.integrationtests.stubs import create_main_loop

from scarlett_os import player
from scarlett_os.user import get_user_project_base_path
from scarlett_os.sounds import STATIC_SOUNDS_PATH

import imp

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_ScarlettPlayer_listening(self, player_monkeyfunc, player_mocker_stopall
player_data = []

pi_listening_wav = os.path.join(
get_user_project_base_path() + "/static/sounds", "pi-listening.wav"
STATIC_SOUNDS_PATH, "pi-listening.wav"
)
# Run player
wavefile = [pi_listening_wav]
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/test_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import scarlett_os.exceptions
from scarlett_os.utility.gnome import _IdleObject, abort_on_exception, trace
from tests import common
from scarlett_os.user import get_user_project_base_path
from scarlett_os.sounds import STATIC_SOUNDS_PATH


# DISABLED 5/8/2017 LETS TRY TO DO EVERYTHING FROM player # from scarlett_os.player import get_loop_thread, MainLoopThread, ScarlettPlayer
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_ScarlettPlayer_init_missing_gst_elements(
self, mock_gst_elementfactory_make
):
path = os.path.join(
get_user_project_base_path() + "/static/sounds", "pi-listening.wav"
STATIC_SOUNDS_PATH, "pi-listening.wav"
)
with pytest.raises(scarlett_os.exceptions.IncompleteGStreamerError):
p = player.ScarlettPlayer(path, False, False)
2 changes: 1 addition & 1 deletion tests/unittests/test_tasker.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def connected_to_listener_cb(*args, **kwargs):
@pytest.mark.unittest
class TestSoundType(object):
def test_soundtype_get_path(self):
path_to_sound = "/home/pi/dev/bossjones-github/scarlett_os/static/sounds"
path_to_sound = "/home/pi/dev/bossjones-github/scarlett_os/scarlett_os/data/sounds"
assert tasker.STATIC_SOUNDS_PATH == path_to_sound
assert type(tasker.SoundType.get_path("pi-cancel")) == list
assert tasker.SoundType.get_path("pi-cancel") == [
Expand Down

0 comments on commit a724062

Please sign in to comment.