Skip to content

Commit

Permalink
meson: use fallback import path in start script
Browse files Browse the repository at this point in the history
Pass the module install path to the start script and add it to sys.path
if import fails.
  • Loading branch information
rautesamtr authored and FFY00 committed Nov 10, 2018
1 parent 3210fc8 commit 8572144
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bin_conf = configuration_data()
bin_conf.set('appid', appid)
bin_conf.set('pkgdatadir', join_paths(prefix, pkgdatadir))
bin_conf.set('python_major_ver', python_major_ver)
bin_conf.set('purelib_path', join_paths(prefix, purelib_path))

configure_file(
input: 'pulseaudio-equalizer-gtk.in',
Expand Down
9 changes: 9 additions & 0 deletions bin/pulseaudio-equalizer-gtk.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ resource = Gio.resource_load(
os.path.join('@pkgdatadir@', '@appid@.gresource'))
Gio.Resource._register(resource)

try:
__import__('importlib').import_module('pulseeq')
except ImportError:
sys.path.append('@purelib_path@')
try:
__import__('importlib').import_module('pulseeq')
except ImportError:
raise

from pulseeq import equalizer

app = equalizer.Application()
Expand Down
8 changes: 8 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ pythondir = python.get_path('purelib')
pkgdatadir = join_paths(datadir, meson.project_name())
appdir = join_paths(pythondir, modname)

purelib_option = get_option('purelib')

if not (purelib_option == '')
purelib_path = purelib_option
else
purelib_path = python.get_install_dir()
endif

subdir('bin')
subdir('data')
subdir(modname)
Expand Down
2 changes: 1 addition & 1 deletion pulseeq/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ equalizer_sources = ['__init__.py', 'equalizer.py', constants_file]

purelib_path = get_option('purelib')

if not (purelib_path == '')
if not (purelib_option == '')
install_data(equalizer_sources,
install_dir: join_paths(purelib_path, modname)
)
Expand Down

0 comments on commit 8572144

Please sign in to comment.