Skip to content

Commit

Permalink
Switch from appdirs to platformdirs. (conda#13307)
Browse files Browse the repository at this point in the history
Co-authored-by: Ken Odegard <[email protected]>
  • Loading branch information
jezdez and kenodegard authored Nov 9, 2023
1 parent 25e4b1f commit e70adac
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 8 deletions.
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ Conda incorporates the following libraries into its distributed code:
* py-cpuinfo, licensed as MIT
* distro, licensed as Apache-2.0
* frozendict, license as LGPL-3.0
* tqdm, licensed as MIT
3 changes: 3 additions & 0 deletions conda/_vendor/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
# - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
from ..deprecations import deprecated
deprecated.module("24.3", "24.9", addendum="Use `platformdirs` instead.")


__version_info__ = (1, 2, 0)
__version__ = '.'.join(map(str, __version_info__))
Expand Down
3 changes: 2 additions & 1 deletion conda/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from os.path import abspath, expanduser, isdir, isfile, join
from os.path import split as path_split

from platformdirs import user_data_dir

try:
from boltons.setutils import IndexedSet
except ImportError: # pragma: no cover
from .._vendor.boltons.setutils import IndexedSet

from .. import CONDA_SOURCE_ROOT
from .. import __version__ as CONDA_VERSION
from .._vendor.appdirs import user_data_dir
from .._vendor.frozendict import frozendict
from ..auxlib.decorators import memoizedproperty
from ..auxlib.ish import dals
Expand Down
11 changes: 6 additions & 5 deletions conda/gateways/anaconda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from os.path import isdir, isfile, join
from stat import S_IREAD, S_IWRITE

from .._vendor.appdirs import AppDirs
from platformdirs import user_data_dir

from ..common.url import quote_plus, unquote_plus
from ..deprecations import deprecated
from .disk.delete import rm_rf

log = getLogger(__name__)
Expand All @@ -19,6 +21,7 @@ def replace_first_api_with_conda(url):
return re.sub(r"([./])api([./]|$)", r"\1conda\2", url, count=1)


@deprecated("24.3", "24.9", addendum="Use `platformdirs` instead.")
class EnvAppDirs:
def __init__(self, appname, appauthor, root_path):
self.appname = appname
Expand All @@ -44,11 +47,9 @@ def user_log_dir(self):

def _get_binstar_token_directory():
if "BINSTAR_CONFIG_DIR" in os.environ:
return EnvAppDirs(
"binstar", "ContinuumIO", os.environ["BINSTAR_CONFIG_DIR"]
).user_data_dir
return os.path.join(os.environ["BINSTAR_CONFIG_DIR"], "data")
else:
return AppDirs("binstar", "ContinuumIO").user_data_dir
return user_data_dir(appname="binstar", appauthor="ContinuumIO")


def read_binstar_tokens():
Expand Down
3 changes: 2 additions & 1 deletion conda/notices/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from pathlib import Path
from typing import Sequence

from .._vendor.appdirs import user_cache_dir
from platformdirs import user_cache_dir

from ..base.constants import APP_NAME, NOTICES_CACHE_FN, NOTICES_CACHE_SUBDIR
from ..utils import ensure_dir_exists
from .types import ChannelNotice, ChannelNoticeResponse
Expand Down
19 changes: 19 additions & 0 deletions news/13306-appdirs-platformdirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Switch from `appdirs` to `platformdirs`. (#13306)

### Bug fixes

* <news item>

### Deprecations

* Deprecate `conda.gateways.anaconda_client.EnvAppDirs` in favor of `platformdirs`. (#13306)

### Docs

* <news item>

### Other

* <news item>
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = [
"jsonpatch >=1.32",
"menuinst >=1.4.11,<2 ; platform_system=='Windows'",
"packaging",
"platformdirs >=3.10.0",
"pluggy >=1.0.0",
"pycosat >=0.6.3",
"requests >=2.27.0,<3",
Expand Down
1 change: 1 addition & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ requirements:
- jsonpatch >=1.32
- menuinst >=1.4.11,<2 # [win]
- packaging >=23.0
- platformdirs >=3.10.0
- pluggy >=1.0.0
- pycosat >=0.6.3
- python
Expand Down

0 comments on commit e70adac

Please sign in to comment.