annotate libervia/desktop_kivy/core/kivy_hack.py @ 495:59bdf78bd1d9

installation: update to use hatch following change in backend and other frontends: - `setup.py` and `requirements.txt` have been removed in favor of `pyproject.toml` - changed versionning mechanism to use a version directly in `libervia/desktop_kivy/__init__.py` handled by Hatch - remove the log hack from `kivy_hack` as there is now an environment variable to disable the logging hijacking
author Goffi <goffi@goffi.org>
date Mon, 28 Aug 2023 18:29:18 +0200
parents b3cedbee561d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
495
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
1 #!/usr//bin/env python3
6
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
3 #Libervia Desktop-Kivy
461
3c9ba4a694ef dates update
Goffi <goffi@goffi.org>
parents: 379
diff changeset
4 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org)
6
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
495
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
19 from .constants import Const as C
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
20 from libervia.backend.core import log_config
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
21 import os
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
22 import sys
6
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
23
48
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
24
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
25 def do_hack():
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
26 """work around Kivy hijacking of logs and arguments"""
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
27 # we remove args so kivy doesn't use them
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
28 # this is need to avoid kivy breaking QuickApp args handling
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
29 ori_argv = sys.argv[:]
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
30 sys.argv = sys.argv[:1]
493
b3cedbee561d refactoring: rename `cagou` to `libervia.desktop_kivy` + update imports and names following backend changes
Goffi <goffi@goffi.org>
parents: 491
diff changeset
31 log_config.libervia_configure(C.LOG_BACKEND_STANDARD, C)
6
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
495
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
33 os.environ["KIVY_LOG_MODE"] = "PYTHON"
6
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
85649eca9f9b core (logs): integrate Kivy logs with SàT:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 import kivy
495
59bdf78bd1d9 installation: update to use hatch following change in backend and other frontends:
Goffi <goffi@goffi.org>
parents: 493
diff changeset
36 assert kivy # to avoid pyflakes warning
48
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
37
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
38 # we restore original arguments
028a98983e46 core: avoid kivy arguments hijacking so QuickApp arguments parsing can be used
Goffi <goffi@goffi.org>
parents: 15
diff changeset
39 sys.argv = ori_argv