python-platformdirs: Add new package
authorJeffery To <jeffery.to@gmail.com>
Mon, 4 Dec 2023 06:05:55 +0000 (14:05 +0800)
committerTianling Shen <cnsztl@gmail.com>
Thu, 7 Dec 2023 07:07:05 +0000 (15:07 +0800)
This also includes a test.sh script for the packages feed CI.

From the README:

When writing desktop application, finding the right location to store
user data and configuration varies per platform. Even for
single-platform apps, there may by plenty of nuances in figuring out the
right location.

This kind of thing is what the platformdirs package is for.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python-platformdirs/Makefile [new file with mode: 0644]
lang/python/python-platformdirs/test.sh [new file with mode: 0644]

diff --git a/lang/python/python-platformdirs/Makefile b/lang/python/python-platformdirs/Makefile
new file mode 100644 (file)
index 0000000..620377e
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2023 Jeffery To
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=python-platformdirs
+PKG_VERSION:=4.0.0
+PKG_RELEASE:=1
+
+PYPI_NAME:=platformdirs
+PKG_HASH:=cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+
+PKG_BUILD_DEPENDS:=python-hatchling/host python-hatch-vcs/host
+
+include ../pypi.mk
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-platformdirs
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Python
+  TITLE:=Determine appropriate platform-specific dirs
+  URL:=https://github.com/platformdirs/platformdirs
+  DEPENDS:=+python3-light +python3-urllib
+endef
+
+define Package/python3-platformdirs/description
+When writing desktop application, finding the right location to store
+user data and configuration varies per platform. Even for
+single-platform apps, there may by plenty of nuances in figuring out the
+right location.
+
+This kind of thing is what the platformdirs package is for.
+endef
+
+$(eval $(call Py3Package,python3-platformdirs))
+$(eval $(call BuildPackage,python3-platformdirs))
+$(eval $(call BuildPackage,python3-platformdirs-src))
diff --git a/lang/python/python-platformdirs/test.sh b/lang/python/python-platformdirs/test.sh
new file mode 100644 (file)
index 0000000..40dabb2
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+[ "$1" = python3-platformdirs ] || exit 0
+
+python3 - << 'EOF'
+
+from platformdirs import *
+appname = "SuperApp"
+appauthor = "Acme"
+
+assert user_data_dir(appname, appauthor) == '/root/.local/share/SuperApp'
+assert user_cache_dir(appname, appauthor) == '/root/.cache/SuperApp'
+assert user_log_dir(appname, appauthor) == '/root/.local/state/SuperApp/log'
+assert user_config_dir(appname) == '/root/.config/SuperApp'
+assert user_documents_dir() == '/root/Documents'
+assert user_downloads_dir() == '/root/Downloads'
+assert user_pictures_dir() == '/root/Pictures'
+assert user_videos_dir() == '/root/Videos'
+assert user_music_dir() == '/root/Music'
+assert user_desktop_dir() == '/root/Desktop'
+assert user_runtime_dir(appname, appauthor) == '/run/user/0/SuperApp'
+
+assert site_data_dir(appname, appauthor) == '/usr/local/share/SuperApp'
+assert site_data_dir(appname, appauthor, multipath=True) == '/usr/local/share/SuperApp:/usr/share/SuperApp'
+
+assert site_config_dir(appname) == '/etc/xdg/SuperApp'
+
+import os
+os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
+
+assert site_config_dir(appname, multipath=True) == '/etc/SuperApp:/usr/local/etc/SuperApp'
+
+EOF