summaryrefslogtreecommitdiff
path: root/post_install.py
diff options
context:
space:
mode:
Diffstat (limited to 'post_install.py')
-rw-r--r--post_install.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/post_install.py b/post_install.py
new file mode 100644
index 0000000..c9f4d9e
--- /dev/null
+++ b/post_install.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+
+import os
+import glob
+import subprocess
+import sysconfig
+from compileall import compile_dir
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+destdir = os.environ.get('DESTDIR', '')
+
+if __name__=="__main__":
+ print('Compiling python bytecode...')
+ puredir = sysconfig.get_path('purelib', vars={'base': str(prefix)})
+ module_dir = os.path.join(destdir + os.path.join(puredir, 'Mozo'))
+ compile_dir(module_dir, optimize=2)
+
+ if destdir == '':
+ print('Updating icon cache...')
+ icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
+ if not os.path.exists(icon_cache_dir):
+ os.makedirs(icon_cache_dir)
+ subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
+
+ print('Updating desktop database...')
+ desktop_database_dir = os.path.join(datadir, 'applications')
+ if not os.path.exists(desktop_database_dir):
+ os.makedirs(desktop_database_dir)
+ subprocess.call(['update-desktop-database', '-q', desktop_database_dir])