diff --git a/craft_cli/messages.py b/craft_cli/messages.py index 7ad159d..83731ad 100644 --- a/craft_cli/messages.py +++ b/craft_cli/messages.py @@ -33,7 +33,7 @@ from datetime import datetime from typing import Literal, Optional, TextIO, Union -import appdirs +import platformdirs try: import win32pipe # type: ignore @@ -92,7 +92,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path: The app name is used for both the directory where the logs are located and each log name. Rules: - - use an appdirs provided directory + - use an platformdirs provided directory - base filename is ..log - it rotates until it gets to reaches :data:`._MAX_LOG_FILES` - after limit is achieved, remove the exceeding files @@ -101,7 +101,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path: Existing files are not renamed (no need, as each name is unique) nor gzipped (they may be currently in use by another process). """ - basedir = pathlib.Path(appdirs.user_log_dir(appname)) + basedir = pathlib.Path(platformdirs.user_log_dir(appname)) filename = f"{appname}-{datetime.now():%Y%m%d-%H%M%S.%f}.log" # ensure the basedir is there diff --git a/requirements-dev.txt b/requirements-dev.txt index ecb9a5c..087e1cf 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,12 +1,10 @@ alabaster==0.7.12 -appdirs==1.4.4 -appdirs-stubs==0.1.0 -astroid==2.8.3 +astroid==2.8.4 attrs==21.2.0 autoflake==1.4 Babel==2.9.1 -backports.entry-points-selectable==1.1.0 -black==21.9b0 +backports.entry-points-selectable==1.1.1 +black==21.10b0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 @@ -14,34 +12,34 @@ charset-normalizer==2.0.7 click==8.0.3 codespell==2.1.0 colorama==0.4.4 -coverage==6.0.2 +coverage==6.1.1 cryptography==35.0.0 distlib==0.3.3 docutils==0.17.1 -filelock==3.3.1 +filelock==3.3.2 flake8==4.0.1 idna==3.3 -imagesize==1.2.0 -importlib-metadata==4.8.1 +imagesize==1.3.0 +importlib-metadata==4.8.2 iniconfig==1.1.1 -isort==5.9.3 +isort==5.10.1 jeepney==0.7.1 -Jinja2==3.0.2 -jsonpointer==2.1 +Jinja2==3.0.3 +jsonpointer==2.2 keyring==23.2.1 lazy-object-proxy==1.6.0 MarkupSafe==2.0.1 mccabe==0.6.1 mypy==0.910 mypy-extensions==0.4.3 -packaging==21.0 +packaging==21.2 pathspec==0.9.0 pkginfo==1.7.1 platformdirs==2.4.0 pluggy==1.0.0 -py==1.10.0 +py==1.11.0 pycodestyle==2.8.0 -pycparser==2.20 +pycparser==2.21 pydantic==1.8.2 pydocstyle==6.1.1 pyflakes==2.4.0 @@ -49,21 +47,21 @@ Pygments==2.10.0 pylint==2.11.1 pylint-fixme-info==1.0.2 pylint-pytest==1.1.2 -pyparsing==3.0.1 +pyparsing==2.4.7 pytest==6.2.5 pytest-mock==3.6.1 -pytest-subprocess==1.3.0 +pytest-subprocess==1.3.2 pytz==2021.3 PyYAML==6.0 readme-renderer==30.0 -regex==2021.10.23 +regex==2021.11.10 requests==2.26.0 requests-toolbelt==0.9.1 rfc3986==1.5.0 SecretStorage==3.3.1 six==1.16.0 snowballstemmer==2.1.0 -Sphinx==4.2.0 +Sphinx==4.3.0 sphinx-autodoc-typehints==1.12.0 sphinx-jsonschema==1.16.11 sphinx-pydantic==0.1.1 @@ -78,13 +76,13 @@ toml==0.10.2 tomli==1.2.2 tox==3.24.4 tqdm==4.62.3 -twine==3.4.2 +twine==3.6.0 types-PyYAML==6.0.0 -types-requests==2.25.11 +types-requests==2.26.0 types-setuptools==57.4.2 typing-extensions==3.10.0.2 urllib3==1.26.7 -virtualenv==20.9.0 +virtualenv==20.10.0 webencodings==0.5.1 -wrapt==1.13.2 +wrapt==1.13.3 zipp==3.6.0 diff --git a/requirements.txt b/requirements.txt index 8a6fd7f..fa84e79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -appdirs==1.4.4 +platformdirs==2.4.0 pydantic==1.8.2 PyYAML==6.0 typing-extensions==3.10.0.2 diff --git a/setup.cfg b/setup.cfg index 05d79ae..33fe92a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ include_package_data = True packages = find: zip_safe = False install_requires = - appdirs + platformdirs pydantic pyyaml pywin32; sys_platform == "win32" @@ -46,7 +46,6 @@ release = twine wheel test = - appdirs-stubs black codespell coverage diff --git a/tests/unit/test_messages_helpers.py b/tests/unit/test_messages_helpers.py index 2dc30a1..212be13 100644 --- a/tests/unit/test_messages_helpers.py +++ b/tests/unit/test_messages_helpers.py @@ -23,7 +23,7 @@ import time from unittest.mock import MagicMock, call -import appdirs +import platformdirs import pytest from craft_cli import messages @@ -43,10 +43,10 @@ @pytest.fixture def test_log_dir(tmp_path, monkeypatch): - """Provide a test log filepath, also fixing appdirs to use a temp dir.""" + """Provide a test log filepath, also fixing platformdirs to use a temp dir.""" dirpath = tmp_path / "testlogdir" dirpath.mkdir() - monkeypatch.setattr(appdirs, "user_log_dir", lambda appname: dirpath / appname) + monkeypatch.setattr(platformdirs, "user_log_dir", lambda appname: dirpath / appname) return dirpath @@ -158,7 +158,7 @@ def test_getlogpath_ignore_other_files(test_log_dir, monkeypatch): def test_getlogpath_deep_dirs(tmp_path, monkeypatch): """The log directory is inside a path that does not exist yet.""" dirpath = tmp_path / "foo" / "bar" / "testlogdir" - monkeypatch.setattr(appdirs, "user_log_dir", lambda appname: dirpath / appname) + monkeypatch.setattr(platformdirs, "user_log_dir", lambda appname: dirpath / appname) fpath = _get_log_filepath("testapp") # check the file is inside the proper dir and that it exists