From b34de32a5414bc4a724a13148d92b53a1b0091b0 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 21 Jun 2023 15:02:02 +0000 Subject: [PATCH] Replace appdirs usage with platformdirs The appdirs library has been abandoned for several years now, and a fork named platformdirs is the recommended alternative. It's almost a drop-in replacement, except the module and convenience class name have changed. Adjust the internal variable name we're using for the expansion to match as well, for all those consistent hobgoblins. Add it with a >=3 lower bound because that introduces a breaking change of the default configuration location for macOS users. Include a release note about that too. Depends-On: https://review.opendev.org/886642 Change-Id: I4c2b60ca0da29da1f605b4c0b5e77f8e1071a19c --- openstack/config/loader.py | 12 +++++++----- ...e-appdirs-with-platformdirs-d3f5bcbe726b7829.yaml | 8 ++++++++ requirements.txt | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/replace-appdirs-with-platformdirs-d3f5bcbe726b7829.yaml diff --git a/openstack/config/loader.py b/openstack/config/loader.py index 8df3422be..b9dc82402 100644 --- a/openstack/config/loader.py +++ b/openstack/config/loader.py @@ -23,9 +23,9 @@ import re import sys import warnings -import appdirs from keystoneauth1 import adapter from keystoneauth1 import loading +import platformdirs import yaml from openstack import _log @@ -36,9 +36,11 @@ from openstack.config import vendors from openstack import exceptions from openstack import warnings as os_warnings -APPDIRS = appdirs.AppDirs('openstack', 'OpenStack', multipath='/etc') -CONFIG_HOME = APPDIRS.user_config_dir -CACHE_PATH = APPDIRS.user_cache_dir +PLATFORMDIRS = platformdirs.PlatformDirs( + 'openstack', 'OpenStack', multipath='/etc' +) +CONFIG_HOME = PLATFORMDIRS.user_config_dir +CACHE_PATH = PLATFORMDIRS.user_cache_dir # snaps do set $HOME to something like # /home/$USER/snap/openstackclients/$SNAP_VERSION @@ -55,7 +57,7 @@ else: ) UNIX_SITE_CONFIG_HOME = '/etc/openstack' -SITE_CONFIG_HOME = APPDIRS.site_config_dir +SITE_CONFIG_HOME = PLATFORMDIRS.site_config_dir CONFIG_SEARCH_PATH = [ os.getcwd(), diff --git a/releasenotes/notes/replace-appdirs-with-platformdirs-d3f5bcbe726b7829.yaml b/releasenotes/notes/replace-appdirs-with-platformdirs-d3f5bcbe726b7829.yaml new file mode 100644 index 000000000..01a0815a2 --- /dev/null +++ b/releasenotes/notes/replace-appdirs-with-platformdirs-d3f5bcbe726b7829.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + The ``appdirs`` dependency is replaced by a requirement for + ``platformdirs`` 3.0.0 or later. Users on macOS may need to move + configuration files to ``*/Library/Application Support``. See its release + notes for further details: + https://platformdirs.readthedocs.io/en/latest/changelog.html#platformdirs-3-0-0-2023-02-06 diff --git a/requirements.txt b/requirements.txt index 6dc4d905c..48188d4e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 PyYAML>=3.13 # MIT -appdirs>=1.3.0 # MIT License +platformdirs>=3 # MIT License requestsexceptions>=1.2.0 # Apache-2.0 jsonpatch!=1.20,>=1.16 # BSD os-service-types>=1.7.0 # Apache-2.0