From e7dbd59e67cf3ce17bfdbb1ef3ac40bed1628f26 Mon Sep 17 00:00:00 2001 From: huakim Date: Fri, 24 May 2024 22:00:09 +0300 Subject: [PATCH] update --- py2pack/__init__.py | 17 +++++++++++------ pyproject.toml | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/py2pack/__init__.py b/py2pack/__init__.py index 3601065..151c5f4 100755 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -17,6 +17,7 @@ # limitations under the License. import argparse +import platformdirs import datetime import glob import json @@ -97,12 +98,16 @@ def _get_template_dirs(): """existing directories where to search for jinja2 templates. The order is important. The first found template from the first found dir wins!""" return filter(lambda x: os.path.exists(x), [ - # user dir - os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'), - # system wide dir - os.path.join('/', 'usr', 'share', 'py2pack', 'templates'), - # usually inside the site-packages dir - os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'), + os.path.join(i, "templates") for i in ( + # user dir + os.path.join(os.path.expanduser('~'), '.py2pack'), + platformdirs.user_data_dir(appname="py2pack"), + platformdirs.user_config_dir(appname="py2pack"), + # usually inside the site-packages dir + os.path.dirname(__file__), + # system wide dir + *platformdirs.site_data_dir(appname="py2pack", multipath=True).split(":"), + ) ]) diff --git a/pyproject.toml b/pyproject.toml index fd70b49..fe090ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "build", "setuptools", "metaextract", + "platformdirs", "packaging", "pypi-search", "requests",