From ae0cac13043aa386334f8410f86eb6ef28781cbc Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Sun, 14 Nov 2021 04:11:17 +0100 Subject: [PATCH] update the buildsystem and readme - Add the proxy to the meson buildsystem - Create quick install scripts for a local install or development - Update the readme for newer meson conventions and explain the scripts --- README.md | 19 +++++++++++--- meson.build | 10 +++++-- meson_options.txt | 2 ++ openswitcher-develop.sh | 18 +++++++++++++ openswitcher-install.sh | 18 +++++++++++++ openswitcher_proxy/meson.build | 33 ++++++++++++++++++++++++ openswitcher_proxy/openswitcher-proxy.in | 17 ++++++++++++ 7 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 meson_options.txt create mode 100755 openswitcher-develop.sh create mode 100755 openswitcher-install.sh create mode 100644 openswitcher_proxy/meson.build create mode 100755 openswitcher_proxy/openswitcher-proxy.in diff --git a/README.md b/README.md index 211d97a..2a2a205 100644 --- a/README.md +++ b/README.md @@ -10,22 +10,29 @@ Installation Install the pyatem protocol module:: + setup.py build sudo setup.py install -Build and install the gtk application:: +Build and install the gtk application and proxy:: meson build - cd build - ninja - sudo ninja install + meson compile -C build + sudo meson install -C build Run the application:: switcher-control +There is also the `openswitcher-install.sh` script which will install the library, proxy and gtk application in +/usr/local for a quick installation of all components. + Developing ---------- +To work on the `pyatem` library the quickest way to get up and running is using the `openswitcher-develop.sh` script +that will install the `pyatem` library in devel mode where the files are symlinked to the git repository. It will also +install the proxy and gtk application in /usr/local which will use the symlinked library. + Development happens on matrix on #openatem:brixit.nl Proxy @@ -39,6 +46,10 @@ It can be run by starting the module:: python3 -m openswitcher_proxy --config /etc/myconfigfile.toml +Or if the software installed it can be started using the launcher script:: + + openswitcher-proxy --config /etc/myconfigfile.toml + The default config location is /etc/openswitcher/proxy.conf if not specified. Here's an example config: [[hardware]] diff --git a/meson.build b/meson.build index a85d1b2..ba7d2d1 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,13 @@ project('switcher', dependency('libhandy-1', version: '>=1.0.0') -subdir('data') -subdir('gtk_switcher') +if get_option('with_gtk_app') + subdir('data') + subdir('gtk_switcher') +endif + +if get_option('with_proxy') + subdir('openswitcher_proxy') +endif meson.add_install_script('build-aux/meson/postinstall.py') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..d350cd0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('with_proxy', type : 'boolean', value : true) +option('with_gtk_app', type : 'boolean', value : true) \ No newline at end of file diff --git a/openswitcher-develop.sh b/openswitcher-develop.sh new file mode 100755 index 0000000..ffad03c --- /dev/null +++ b/openswitcher-develop.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# This tool sets up openswitcher and pyatem to run from the source files in the git repository. This requires root +# permissions to install the software using symlinks to the source. + +printf "Installing the pyatem module using setup.py develop\n" +sudo python3 setup.py develop + +printf "Installing the openswitcher application to /usr/local/\n" +meson _build +meson compile -C _build +sudo meson install -C _build + +printf "*------------------------------------*\n" +printf "Development installation done\n" +printf "The python module is now available system-wide as 'pyatem'\n" +printf "The GTK application is now available as 'switcher-control'\n" +printf "The proxy application is now available as 'openswitcher-proxy'\n" \ No newline at end of file diff --git a/openswitcher-install.sh b/openswitcher-install.sh new file mode 100755 index 0000000..78a250a --- /dev/null +++ b/openswitcher-install.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# This scripts installs the openswitcher components on the local system. + +printf "Installing the pyatem module using setup.py install\n" +python3 setup.py build +sudo python3 setup.py install + +printf "Installing the openswitcher application to /usr/local/\n" +meson _build +meson compile -C _build +sudo meson install -C _build + +printf "*------------------------------------*\n" +printf "Installnstallation done\n" +printf "The python module is now available system-wide as 'pyatem'\n" +printf "The GTK application is now available as 'switcher-control'\n" +printf "The proxy application is now available as 'openswitcher-proxy'\n" \ No newline at end of file diff --git a/openswitcher_proxy/meson.build b/openswitcher_proxy/meson.build new file mode 100644 index 0000000..2437b8d --- /dev/null +++ b/openswitcher_proxy/meson.build @@ -0,0 +1,33 @@ +pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) +moduledir = join_paths(pkgdatadir, 'openswitcher_proxy') + +python = import('python') + +conf = configuration_data() +conf.set('PYTHON', python.find_installation('python3').path()) +conf.set('VERSION', meson.project_version()) +conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir'))) +conf.set('pkgdatadir', pkgdatadir) + +configure_file( + input: 'openswitcher-proxy.in', + output: 'openswitcher-proxy', + configuration: conf, + install: true, + install_dir: get_option('bindir') +) + +proxy_sources = [ + '__init__.py', + '__main__.py', + 'frontend.py', + 'frontend_status.py', + 'frontend_tcp.py', + 'frontend_httpapi.py', + 'frontend_mqtt.py', + 'hardware.py', + 'error.py', + +] + +install_data(proxy_sources, install_dir: moduledir) diff --git a/openswitcher_proxy/openswitcher-proxy.in b/openswitcher_proxy/openswitcher-proxy.in new file mode 100755 index 0000000..c44a532 --- /dev/null +++ b/openswitcher_proxy/openswitcher-proxy.in @@ -0,0 +1,17 @@ +#!@PYTHON@ + +import os +import sys +import signal +import gettext + +VERSION = '@VERSION@' +pkgdatadir = '@pkgdatadir@' +localedir = '@localedir@' + +sys.path.insert(1, pkgdatadir) +signal.signal(signal.SIGINT, signal.SIG_DFL) + +if __name__ == '__main__': + from openswitcher_proxy import __main__ + sys.exit(__main__.main()) -- 2.34.2