Skip to content

Commit 10eb118

Browse files
committed
meson: Reorganize Python modules
1 parent 3c85533 commit 10eb118

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+446
-399
lines changed

data/icons/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
scalable_dir = 'hicolor' / 'scalable' / 'apps'
22
install_data(
3-
scalable_dir / f'@[email protected]',
4-
install_dir: get_option('datadir') / 'icons' / scalable_dir,
3+
scalable_dir / f'@[email protected]',
4+
install_dir: get_option('datadir') / 'icons' / scalable_dir,
55
)
66

77
symbolic_dir = 'hicolor' / 'symbolic' / 'apps'
88
install_data(
9-
symbolic_dir / f'@[email protected]',
10-
install_dir: get_option('datadir') / 'icons' / symbolic_dir,
9+
symbolic_dir / f'@[email protected]',
10+
install_dir: get_option('datadir') / 'icons' / symbolic_dir,
1111
)
1212

1313
subdir('scalable/actions')
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
gnome.compile_resources(
2-
'icons',
3-
configure_file(
4-
input: 'icons.gresource.xml.in',
5-
output: '@BASENAME@',
6-
configuration: conf,
7-
),
8-
gresource_bundle: true,
9-
install: true,
10-
install_dir: pkgdatadir,
2+
'icons',
3+
configure_file(
4+
input: 'icons.gresource.xml.in',
5+
output: '@BASENAME@',
6+
configuration: conf,
7+
),
8+
gresource_bundle: true,
9+
install: true,
10+
install_dir: pkgdatadir,
1111
)

data/meson.build

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,86 @@
11
desktop_file = i18n.merge_file(
2-
input: configure_file(
3-
input: 'com.mercata.OpenEmail.desktop.in',
4-
output: '@PLAINNAME@',
5-
configuration: conf,
6-
),
7-
output: f'@[email protected]',
8-
type: 'desktop',
9-
po_dir: '../po',
10-
install: true,
11-
install_dir: get_option('datadir') / 'applications',
2+
input: configure_file(
3+
input: 'openemail.desktop.in',
4+
output: '@PLAINNAME@',
5+
configuration: conf,
6+
),
7+
output: f'@[email protected]',
8+
type: 'desktop',
9+
po_dir: '../po',
10+
install: true,
11+
install_dir: get_option('datadir') / 'applications',
1212
)
1313

1414
desktop_utils = find_program('desktop-file-validate', required: false)
1515
if desktop_utils.found()
16-
test('Validate desktop file', desktop_utils, args: [desktop_file])
16+
test('Validate desktop file', desktop_utils, args: [desktop_file])
1717
endif
1818

1919
appstream_file = i18n.merge_file(
20-
input: configure_file(
21-
input: 'com.mercata.OpenEmail.metainfo.xml.in',
22-
output: '@PLAINNAME@',
23-
configuration: conf,
24-
),
25-
output: f'@[email protected]',
26-
po_dir: '../po',
27-
install: true,
28-
install_dir: get_option('datadir') / 'metainfo',
20+
input: configure_file(
21+
input: 'openemail.metainfo.xml.in',
22+
output: '@PLAINNAME@',
23+
configuration: conf,
24+
),
25+
output: f'@[email protected]',
26+
po_dir: '../po',
27+
install: true,
28+
install_dir: get_option('datadir') / 'metainfo',
2929
)
3030

3131
appstreamcli = find_program('appstreamcli', required: false, disabler: true)
3232
test(
33-
'Validate appstream file',
34-
appstreamcli,
35-
args: ['validate', '--no-net', '--explain', appstream_file],
33+
'Validate appstream file',
34+
appstreamcli,
35+
args: ['validate', '--no-net', '--explain', appstream_file],
3636
)
3737

3838
install_data(
39-
configure_file(
40-
input: 'com.mercata.OpenEmail.gschema.xml.in',
41-
output: f'@[email protected]',
42-
configuration: conf,
43-
),
44-
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
39+
configure_file(
40+
input: 'openemail.gschema.xml.in',
41+
output: f'@[email protected]',
42+
configuration: conf,
43+
),
44+
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
4545
)
4646

47-
compile_schemas = find_program('glib-compile-schemas', required: false, disabler: true)
47+
compile_schemas = find_program(
48+
'glib-compile-schemas',
49+
required: false,
50+
disabler: true,
51+
)
4852
test(
49-
'Validate schema file',
50-
compile_schemas,
51-
args: ['--strict', '--dry-run', meson.current_source_dir()],
53+
'Validate schema file',
54+
compile_schemas,
55+
args: ['--strict', '--dry-run', meson.current_source_dir()],
5256
)
5357

54-
gnome.compile_resources(
55-
'data',
56-
configure_file(
57-
input: 'data.gresource.xml.in',
58+
configure_file(
59+
input: 'openemail.in',
5860
output: '@BASENAME@',
5961
configuration: conf,
60-
),
61-
gresource_bundle: true,
62-
install: true,
63-
install_dir: pkgdatadir,
64-
dependencies: appstream_file,
62+
install_dir: bindir,
63+
install_mode: 'r-xr-xr-x',
64+
)
65+
66+
configure_file(
67+
input: 'openemail.service.in',
68+
output: f'@[email protected]',
69+
configuration: conf,
70+
install_dir: get_option('datadir') / 'dbus-1' / 'services',
71+
)
72+
73+
gnome.compile_resources(
74+
'data',
75+
configure_file(
76+
input: 'data.gresource.xml.in',
77+
output: '@BASENAME@',
78+
configuration: conf,
79+
),
80+
gresource_bundle: true,
81+
install: true,
82+
install_dir: pkgdatadir,
83+
dependencies: appstream_file,
6584
)
6685

6786
subdir('icons')
File renamed without changes.
File renamed without changes.

data/openemail.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!@PYTHON@
2+
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
# SPDX-FileCopyrightText: Copyright 2025 Mercata Sagl
5+
# SPDX-FileContributor: kramo
6+
7+
import runpy
8+
9+
runpy.run_module("openemail")
File renamed without changes.

data/openemail.service.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[D-BUS Service]
2+
Name=@APP_ID@
3+
Exec=@BINDIR@/openemail --gapplication-service

meson.build

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
project(
2-
'openemail',
3-
version: '0.1.0',
4-
meson_version: '>= 1.0.0',
5-
default_options: [
6-
'warning_level=2',
7-
'werror=false',
8-
],
2+
'openemail',
3+
version: '0.1.0',
4+
meson_version: '>= 1.0.0',
5+
default_options: ['warning_level=2', 'werror=false'],
96
)
107

118
dependency('gtk4', version: '>= 4.18.0')
@@ -18,30 +15,32 @@ python = import('python')
1815
py_installation = python.find_installation('python3')
1916

2017
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
18+
localedir = get_option('prefix') / get_option('localedir')
19+
bindir = get_option('bindir')
2120

2221
profile = 'release'
2322
app_id = 'com.mercata.OpenEmail'
2423
prefix = '/com/mercata/OpenEmail'
2524

26-
conf = configuration_data()
27-
28-
conf.set('PYTHON', python.find_installation('python3').full_path())
29-
conf.set('VERSION', meson.project_version())
30-
conf.set('APP_ID', app_id)
31-
conf.set('PREFIX', prefix)
32-
conf.set('PROFILE', profile)
33-
34-
conf.set('pkgdatadir', pkgdatadir)
35-
conf.set('localedir', get_option('prefix') / get_option('localedir'))
36-
conf.set('bindir', get_option('bindir'))
37-
conf.set('prefix', get_option('prefix'))
25+
conf = configuration_data(
26+
{
27+
'PYTHON': py_installation.full_path(),
28+
'APP_ID': app_id,
29+
'VERSION': meson.project_version(),
30+
'PREFIX': prefix,
31+
'PROFILE': profile,
32+
'PKGDATADIR': pkgdatadir,
33+
'LOCALEDIR': localedir,
34+
'BINDIR': bindir,
35+
},
36+
)
3837

3938
subdir('data')
4039
subdir('openemail')
4140
subdir('po')
4241

4342
gnome.post_install(
44-
glib_compile_schemas: true,
45-
gtk_update_icon_cache: true,
46-
update_desktop_database: true,
43+
glib_compile_schemas: true,
44+
gtk_update_icon_cache: true,
45+
update_desktop_database: true,
4746
)

openemail/__init__.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
# SPDX-FileCopyrightText: Copyright 2025 Mercata Sagl
3+
# SPDX-FileContributor: kramo
4+
5+
# ruff: noqa: F401
6+
7+
"""A Mail/HTTPS client."""
8+
9+
import gettext
10+
import locale
11+
import logging
12+
import signal
13+
import sys
14+
from logging.handlers import RotatingFileHandler
15+
from pathlib import Path
16+
17+
import gi
18+
19+
gi.require_versions({"Gdk": "4.0", "Gtk": "4.0", "Adw": "1"})
20+
21+
from gi.repository import Gio
22+
23+
from .configuration import APP_ID, LOCALEDIR, PKGDATADIR, PREFIX, PROFILE, VERSION
24+
from .core.client import WriteError, user
25+
from .core.crypto import KeyPair
26+
from .core.model import Address
27+
28+
signal.signal(signal.SIGINT, signal.SIG_DFL)
29+
30+
if sys.platform.startswith("linux"):
31+
locale.bindtextdomain("openemail", LOCALEDIR)
32+
locale.textdomain("openemail")
33+
34+
gettext.install("openemail", LOCALEDIR)
35+
36+
for resource in ("data", "gtk", "icons"):
37+
resource_path = Path(PKGDATADIR, f"{resource}.gresource")
38+
Gio.resources_register(Gio.Resource.load(str(resource_path)))
39+
40+
from .account import delete as delete_account
41+
from .account import log_out, register, try_auth
42+
from .asyncio import create_task
43+
from .message import Attachment, IncomingAttachment, Message, OutgoingAttachment
44+
from .message import send as send_message
45+
from .notifier import Notifier
46+
from .profile import Profile, ProfileCategory, ProfileField
47+
from .profile import delete_image as delete_profile_image
48+
from .profile import refresh as refresh_profile
49+
from .profile import update as update_profile
50+
from .profile import update_image as update_profile_image
51+
from .store import (
52+
ADDRESS_SPLIT_PATTERN,
53+
DictStore,
54+
MessageStore,
55+
ProfileStore,
56+
address_book,
57+
broadcasts,
58+
contact_requests,
59+
drafts,
60+
empty_trash,
61+
inbox,
62+
log_file,
63+
outbox,
64+
profiles,
65+
secret_service,
66+
settings,
67+
state_settings,
68+
sync,
69+
)
70+
71+
logging.basicConfig(
72+
level=logging.DEBUG,
73+
format="%(levelname)s: %(name)s:%(lineno)d %(message)s",
74+
handlers=(
75+
(
76+
logging.StreamHandler(),
77+
RotatingFileHandler(log_file, maxBytes=1_000_000),
78+
)
79+
),
80+
)

0 commit comments

Comments
 (0)