From bfc4210a7812c9dd00f0c66c4c04fa777cd44179 Mon Sep 17 00:00:00 2001 From: Himadri Sekhar Basu Date: Sat, 19 Oct 2024 01:52:04 +0530 Subject: [PATCH] Install python sources using meson build - Setup meson to install python sources during python and meson builds - Install executable binary using meson and avoid using python builds for now - Remove unnecessary python packaging files --- MANIFEST.in | 1 + meson.build | 2 ++ setup.cfg | 50 ----------------------------- setup.py | 61 ------------------------------------ src/ThemeManager/VERSION.in | 1 + src/ThemeManager/meson.build | 35 +++++++++++++++++++++ src/meson.build | 17 ++++++++++ src/theme-manager.in | 11 +++++++ 8 files changed, 67 insertions(+), 111 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 src/ThemeManager/VERSION.in create mode 100644 src/ThemeManager/meson.build create mode 100644 src/meson.build create mode 100644 src/theme-manager.in diff --git a/MANIFEST.in b/MANIFEST.in index e822aa1..b3ae32e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include debian/changelog global-exclude *.py[cod] graft data* +include src/battery-monitor.in graft src/ThemeManager/ui* diff --git a/meson.build b/meson.build index 86bc382..73a484d 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,8 @@ prefix = get_option('prefix') bindir = get_option('bindir') datadir = get_option('datadir') +subdir('src') + gnome.post_install( glib_compile_schemas: true, gtk_update_icon_cache: true, diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a3de2e6..0000000 --- a/setup.cfg +++ /dev/null @@ -1,50 +0,0 @@ -[metadata] -name = theme-manager -version = file: src/ThemeManager/VERSION -author = Himadri Sekhar Basu -author_email = hsb10@iitbbs.ac.in -description = Theme Manager -long_description = file: README.md -long_description_content_type = text/markdown -url = https://www.github.com/mamolinux/theme-manager -project_urls = - Bug Tracker = https://www.github.com/mamolinux/theme-manager/issues -classifiers = - Development Status :: 5 - Production/Stable - Environment :: X11 Applications :: GTK - Intended Audience :: End Users/Desktop - License :: OSI Approved - :: GNU General Public License v2 or later (GPLv3+) - Operating System :: POSIX - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Accessories - -[options] -package_dir = - = src -packages = find_namespace: -python_requires = >=3.6 -include_package_data = True -install_requires = - configobj - PyGObject - setproctitle - -[options.package_data] -* = *VERSION, *ui - -[options.packages.find] -where = src - -[options.entry_points] -gui_scripts = - theme-manager = ThemeManager.main:start_TM - -[build_i18n] -domain=theme-manager -desktop_files=[("share/applications", ("data/theme-manager*.desktop.in", - ))] -schemas_files=[("share/glib-2.0/schemas", - ("data/org.mamolinux.theme-manager.gschema.xml.in",)) - ] diff --git a/setup.py b/setup.py deleted file mode 100644 index cff5c54..0000000 --- a/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -import glob -import os -import subprocess - -from setuptools import setup -from distutils.log import info -import distutils.command.install_data - -for line in subprocess.check_output('dpkg-parsechangelog --format rfc822'.split(), - universal_newlines=True).splitlines(): - header, colon, value = line.lower().partition(':') - if header == 'version': - version = value.strip() - break -else: - raise RuntimeError('No version found in debian/changelog') - -with open("src/ThemeManager/VERSION", "w") as f: - if '~' in version: - version = version.split('~')[0] - f.write("%s" % version) - -gschema_dir_suffix = 'share/glib-2.0/schemas' - -class install_data(distutils.command.install_data.install_data): - def run(self): - # Python 3 'super' call. - super().run() - - # Compile '*.gschema.xml' to update or create 'gschemas.compiled'. - info("compiling gsettings schemas") - # Use 'self.install_dir' to build the path, so that it works - # for both global and local '--user' installs. - gschema_dir = os.path.join(self.install_dir, gschema_dir_suffix) - self.spawn(["glib-compile-schemas", gschema_dir]) - -data_files = [('share/applications', glob.glob("data/applications/*.desktop")), - ('share/icons/hicolor/scalable/apps', glob.glob("data/icons/*")), - (gschema_dir_suffix, glob.glob("data/schema/*.xml")) - ] - -def create_mo_files(): - po_files = glob.glob("po/*.po") - prefix = 'theme-manager' - - for po_file in po_files: - po_name = os.path.splitext(os.path.split(po_file)[1])[0] - replace_txt = "%s-" % prefix - lang = po_name.replace(replace_txt, '') - os.makedirs("data/locale/%s" % lang, exist_ok=True) - mo = "data/locale/%s/%s.mo" % (lang, prefix) - subprocess.run(['msgfmt', '-o', str(mo), po_file], check=True) - - mo_file = map(lambda i: ('share/locale/%s/LC_MESSAGES' % lang, [i+'/%s.mo' % prefix]), glob.glob('data/locale/%s' % lang)) - data_files.extend(mo_file) - -create_mo_files() - -setup(data_files=data_files, - cmdclass = {'install_data': install_data} -) diff --git a/src/ThemeManager/VERSION.in b/src/ThemeManager/VERSION.in new file mode 100644 index 0000000..14d2ff6 --- /dev/null +++ b/src/ThemeManager/VERSION.in @@ -0,0 +1 @@ +@version@ diff --git a/src/ThemeManager/meson.build b/src/ThemeManager/meson.build new file mode 100644 index 0000000..9257fba --- /dev/null +++ b/src/ThemeManager/meson.build @@ -0,0 +1,35 @@ +python_sources = [ + 'about_window.py', + 'common.py', + 'DesktopTheme.py', + 'gui.py', + 'indicator.py', + '__init__.py', + 'logger.py', + 'LoginTheme.py', + 'main.py', + 'time_chooser.py', + 'tm_daemon.py', +] + +version_file = configure_file( + input: 'VERSION.in', + output: 'VERSION', + configuration: { + 'version': meson.project_version(), + } +) + +python.install_sources( + python_sources, version_file, + subdir: 'ThemeManager', + preserve_path: true, +) + +# Install assets like ui and icons +ui = files('ui/theme-manager.ui', 'ui/logger.ui') + +install_data( + ui, + install_dir: join_paths(pysrcinstalldir, 'ThemeManager', 'ui') +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..f783909 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,17 @@ +pysrcinstalldir = python.get_install_dir() # python.get_path('platlib') +message(f'Python dir: @pysrcinstalldir@') + +conf = configuration_data() +conf.set('PYTHON', python.full_path()) +conf.set('pkgdatadir', pysrcinstalldir) + +configure_file( + input: 'theme-manager.in', + output: 'theme-manager', + configuration: conf, + install: true, + install_dir: bindir, + install_mode: 'rwxr-xr-x' +) + +subdir('ThemeManager') diff --git a/src/theme-manager.in b/src/theme-manager.in new file mode 100644 index 0000000..866dd0f --- /dev/null +++ b/src/theme-manager.in @@ -0,0 +1,11 @@ +#!@PYTHON@ +# -*- coding: utf-8 -*- +import re +import sys + +sys.path.insert(1, '@pkgdatadir@') + +from ThemeManager.main import start_TM +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(start_TM())