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
This commit is contained in:
Jeremy Stanley 2023-06-21 15:02:02 +00:00
parent 377d734de0
commit b34de32a54
3 changed files with 16 additions and 6 deletions

View File

@ -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(),

View File

@ -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

View File

@ -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