Skip to content

Commit

Permalink
Switch from appdirs to platformdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Sep 22, 2021
1 parent b55ec00 commit 60e294d
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 481 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ drop = [

[tool.vendoring.typing-stubs]
six = ["six.__init__", "six.moves.__init__", "six.moves.configparser"]
appdirs = []
distro = []
platformdirs = []

[tool.vendoring.license.directories]
setuptools = "pkg_resources"
Expand Down
10 changes: 7 additions & 3 deletions src/pip/_internal/utils/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
from typing import List

from pip._vendor import appdirs as _appdirs
from pip._vendor import platformdirs as _appdirs


def user_cache_dir(appname: str) -> str:
Expand All @@ -29,7 +29,11 @@ def user_config_dir(appname: str, roaming: bool = True) -> str:
# see <https://github.com/pypa/pip/issues/1733>
def site_config_dirs(appname: str) -> List[str]:
dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
if _appdirs.system not in ["win32", "darwin"]:
if _appdirs.system == "darwin":
# always look in /Library/Application Support/pip as well
return dirval.split(os.pathsep) + ["/Library/Application Support/pip"]
elif _appdirs.system == "win32":
return [dirval]
else:
# always look in /etc directly as well
return dirval.split(os.pathsep) + ["/etc"]
return [dirval]
2 changes: 1 addition & 1 deletion src/pip/_vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def vendored(modulename):
sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path

# Actually alias all of our vendored dependencies.
vendored("appdirs")
vendored("cachecontrol")
vendored("certifi")
vendored("colorama")
Expand All @@ -74,6 +73,7 @@ def vendored(modulename):
vendored("packaging.specifiers")
vendored("pep517")
vendored("pkg_resources")
vendored("platformdirs")
vendored("progress")
vendored("requests")
vendored("requests.exceptions")
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_vendor/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
importlib_machinery = None

from . import py31compat
from pip._vendor import appdirs
from pip._vendor import platformdirs
from pip._vendor import packaging
__import__('pip._vendor.packaging.version')
__import__('pip._vendor.packaging.specifiers')
Expand Down Expand Up @@ -1310,7 +1310,7 @@ def get_default_cache():
"""
return (
os.environ.get('PYTHON_EGG_CACHE')
or appdirs.user_cache_dir(appname='Python-Eggs')
or platformdirs.user_cache_dir(appname='Python-Eggs')
)


Expand Down
File renamed without changes.

0 comments on commit 60e294d

Please sign in to comment.