changeset 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 a4a5565e7026
children 956f5db30223
files libervia/desktop_kivy/VERSION libervia/desktop_kivy/__init__.py libervia/desktop_kivy/core/kivy_hack.py pyproject.toml requirements.txt setup.py
diffstat 6 files changed, 80 insertions(+), 205 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/desktop_kivy/VERSION	Mon Aug 28 17:09:15 2023 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-0.9.0D
--- a/libervia/desktop_kivy/__init__.py	Mon Aug 28 17:09:15 2023 +0200
+++ b/libervia/desktop_kivy/__init__.py	Mon Aug 28 18:29:18 2023 +0200
@@ -19,9 +19,7 @@
 import os.path
 
 
-version_file = os.path.join(os.path.dirname(__file__), 'VERSION')
-with open(version_file) as f:
-    __version__ = f.read().strip()
+__version__ = "0.9.0.dev0"
 
 class Global(object):
     @property
--- a/libervia/desktop_kivy/core/kivy_hack.py	Mon Aug 28 17:09:15 2023 +0200
+++ b/libervia/desktop_kivy/core/kivy_hack.py	Mon Aug 28 18:29:18 2023 +0200
@@ -1,5 +1,4 @@
-#!/usr//bin/env python2
-
+#!/usr//bin/env python3
 
 #Libervia Desktop-Kivy
 # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org)
@@ -17,54 +16,24 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-CONF_KIVY_LEVEL = 'log_kivy_level'
+from .constants import Const as C
+from libervia.backend.core import log_config
+import os
+import sys
 
 
 def do_hack():
     """work around Kivy hijacking of logs and arguments"""
     # we remove args so kivy doesn't use them
     # this is need to avoid kivy breaking QuickApp args handling
-    import sys
     ori_argv = sys.argv[:]
     sys.argv = sys.argv[:1]
-    from .constants import Const as C
-    from libervia.backend.core import log_config
     log_config.libervia_configure(C.LOG_BACKEND_STANDARD, C)
 
-    from . import config
-    kivy_level = config.config_get(C.CONFIG_SECTION, CONF_KIVY_LEVEL, 'follow').upper()
+    os.environ["KIVY_LOG_MODE"] = "PYTHON"
 
-    # kivy handles its own loggers, we don't want that!
-    import logging
-    root_logger = logging.root
-    kivy_logger = logging.getLogger('kivy')
-    ori_addHandler = kivy_logger.addHandler
-    kivy_logger.addHandler = lambda __: None
-    ori_setLevel = kivy_logger.setLevel
-    if kivy_level == 'FOLLOW':
-        # level is following SàT level
-        kivy_logger.setLevel = lambda level: None
-    elif kivy_level == 'KIVY':
-        # level will be set by Kivy according to its own conf
-        pass
-    elif kivy_level in C.LOG_LEVELS:
-        kivy_logger.setLevel(kivy_level)
-        kivy_logger.setLevel = lambda level: None
-    else:
-        raise ValueError("Unknown value for {name}: {value}".format(name=CONF_KIVY_LEVEL, value=kivy_level))
-
-    # during import kivy set its logging stuff
     import kivy
-    kivy # to avoid pyflakes warning
-
-    # we want to separate kivy logs from other logs
-    logging.root = root_logger
-    from kivy import logger
-    sys.stderr = logger.previous_stderr
-
-    # we restore original methods
-    kivy_logger.addHandler = ori_addHandler
-    kivy_logger.setLevel = ori_setLevel
+    assert kivy # to avoid pyflakes warning
 
     # we restore original arguments
     sys.argv = ori_argv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pyproject.toml	Mon Aug 28 18:29:18 2023 +0200
@@ -0,0 +1,72 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "libervia-desktop-kivy"
+dynamic = ["version"]
+description = "Desktop/Android frontend (Kivy version) for Libervia XMPP client"
+readme = "README.md"
+license = "AGPL-3.0-or-later"
+requires-python = ">=3.10"
+authors = [
+    { name = "Libervia Dev Team", email = "contact@goffi.org" },
+]
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Environment :: X11 Applications",
+    "Framework :: Twisted",
+    "Intended Audience :: End Users/Desktop",
+    "Operating System :: Android",
+    "Operating System :: POSIX :: Linux",
+    "Topic :: Communications :: Chat",
+    "Topic :: Internet :: XMPP",
+]
+dependencies = [
+    "kivy ~= 2.2.0",
+    "kivy_garden.modernmenu",
+    # "libervia-backend == 0.9.*",
+    "pillow <9.3",
+    "plyer <2.1",
+]
+keywords = [
+    "XMPP",
+    "desktop",
+    "kivy",
+    "chat",
+    "instant_messaging",
+    "file_sharing"
+]
+
+[project.scripts]
+libervia-desktop-kivy = "libervia.desktop_kivy:run"
+libervia-mobile = "libervia.desktop_kivy:run"
+cagou = "libervia.desktop_kivy:run"
+
+[project.urls]
+Homepage = "https://libervia.org"
+
+[tool.hatch.build.targets.wheel]
+packages = ["libervia", "twisted"]
+
+[tool.hatch.envs.default]
+# we need system-package for GPG
+system-packages = true
+
+[tool.hatch.envs.dev]
+dependencies = [
+    "ipdb",
+    "pudb",
+    "pytest",
+    "pytest-asyncio"
+]
+
+[tool.hatch.metadata]
+allow-direct-references = true
+
+[tool.hatch.version]
+path = "libervia/desktop_kivy/__init__.py"
+
+[tool.hatch.build.targets.wheel.shared-data]
+COPYING = "share/doc/libervia-desktop-kivy/COPYING"
+"README.md" = "share/doc/libervia-desktop-kivy/README.md"
--- a/requirements.txt	Mon Aug 28 17:09:15 2023 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-attrs==20.3.0
-Automat==20.2.0
-Babel==2.9.0
-certifi==2020.12.5
-cffi==1.14.5
-chardet==4.0.0
-constantly==15.1.0
-cryptography==3.4.6
-dbus-python==1.2.16
-docutils==0.16
-DoubleRatchet==0.7.0
-html2text==2020.1.16
-hyperlink==21.0.0
-idna==2.10
-incremental==21.3.0
-Jinja2==2.11.3
-Kivy==2.0.0
-Kivy-Garden==0.1.4
-kivy-garden.modernmenu==0.1.0.dev0
-langid==1.1.6
-lxml==4.6.2
-Markdown==3.3.4
-MarkupSafe==1.1.1
-miniupnpc==2.0.2
-mutagen==1.45.1
-netifaces==0.10.9
-numpy==1.20.1
-OMEMO==0.12.0
-omemo-backend-signal==0.2.6
-Pillow==8.1.2
-plyer==2.0.0
-progressbar2==3.53.1
-protobuf==3.15.6
-pyasn1==0.4.8
-pyasn1-modules==0.2.8
-pycairo==1.20.0
-pycparser==2.20
-pycrypto==2.6.1
-Pygments==2.8.1
-PyGObject==3.40.0
-PyNaCl==1.4.0
-pyOpenSSL==20.0.1
-python-dateutil==2.8.1
-python-potr==1.0.2
-python-utils==2.5.6
-pytz==2021.1
-pyxdg==0.27
-PyYAML==5.4.1
-requests==2.25.1
-service-identity==18.1.0
-shortuuid==1.0.1
-six==1.15.0
-treq==21.1.0
-Twisted==21.2.0
-urllib3==1.26.4
-urwid==2.1.2
-urwid-satext==0.7.0
-wokkel==18.0.0
-X3DH==0.5.9
-XEdDSA==0.4.7
-zope.interface==5.2.0
-
-sat-tmp @ hg+https://repos.goffi.org/sat_tmp
-sat @ hg+https://repos.goffi.org/sat
--e .
--- a/setup.py	Mon Aug 28 17:09:15 2023 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-#!/usr/bin/env python3
-
-# Libervia Desktop and Mobile Frontend
-# Copyright (C) 2009-2021  Jérôme Poisson (goffi@goffi.org)
-# Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from setuptools import setup, find_packages
-import os
-import textwrap
-
-NAME = "libervia-desktop_kivy"
-# NOTE: directory is still "cagou" for compatibility reason, should be changed for 0.9
-DIR_NAME = "libervia/desktop_kivy"
-
-install_requires = [
-    'kivy >=2.0.0, <2.2.0',
-    'kivy_garden.modernmenu',
-    'pillow <9.3',
-    'plyer <2.1',
-    'libervia-backend > 0.8',
-]
-
-with open(os.path.join(DIR_NAME, 'VERSION')) as f:
-    VERSION = f.read().strip()
-is_dev_version = VERSION.endswith('D')
-
-
-def desktop_kivy_dev_version():
-    """Use mercurial data to compute version"""
-    def version_scheme(version):
-        return VERSION.replace('D', '.dev0')
-
-    def local_scheme(version):
-        return "+{rev}.{distance}".format(
-            rev=version.node[1:],
-            distance=version.distance)
-
-    return {'version_scheme': version_scheme,
-            'local_scheme': local_scheme}
-
-
-setup(
-    name=NAME,
-    version=VERSION,
-    description="Desktop/Android frontend (Kivy version) for Libervia XMPP client",
-    long_description=textwrap.dedent("""\
-        Libervia Desktop Kivy is a Desktop/Android frontend for Libervia.
-        This is an alternative version using the Kivy framework.
-        It provides native graphical interface with a modern user interface,
-        using touch screen abilitiy when available, and with split ability inspired from
-        Blender
-        """),
-    author="Libervia Team",
-    author_email="contact@goffi.org",
-    url="https://libervia.org",
-    classifiers=[
-        "Programming Language :: Python :: 3 :: Only",
-        "Programming Language :: Python :: 3.7",
-        "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",
-        "Development Status :: 5 - Production/Stable",
-        "Environment :: X11 Applications",
-        "Framework :: Twisted",
-        "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
-        "Operating System :: POSIX :: Linux",
-        "Operating System :: Android",
-        "Topic :: Internet :: XMPP",
-        "Topic :: Communications :: Chat",
-        "Intended Audience :: End Users/Desktop",
-    ],
-    packages=find_packages(),
-    entry_points={
-        "console_scripts": [
-            "libervia-desktop_kivy = libervia.desktop_kivy:run",
-            "libervia-mobile = libervia.desktop_kivy:run",
-            "cagou = libervia.desktop_kivy:run",
-            ],
-        },
-    zip_safe=False,
-    setup_requires=["setuptools_scm"] if is_dev_version else [],
-    use_scm_version=desktop_kivy_dev_version if is_dev_version else False,
-    install_requires=install_requires,
-    package_data={"": ["*.kv"], "libervia.desktop_kivy": ["VERSION"]},
-    python_requires=">=3.7",
-)