Skip to content

Commit 7616583

Browse files
authored
Merge pull request #10202 from domdfcoding/platformdirs
2 parents a07bfb3 + 78b8b8b commit 7616583

24 files changed

+1019
-815
lines changed

news/10202.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace vendored appdirs with platformdirs.

news/pkg_resources.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Patch pkg_resources to use platformdirs rather than appdirs.

news/platformdirs.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Patch platformdirs import its submodules from ``pip._vendor.platformdirs``.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ drop = [
4848

4949
[tool.vendoring.typing-stubs]
5050
six = ["six.__init__", "six.moves.__init__", "six.moves.configparser"]
51-
appdirs = []
5251
distro = []
5352

5453
[tool.vendoring.license.directories]

src/pip/_internal/utils/appdirs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"""
88

99
import os
10+
import sys
1011
from typing import List
1112

12-
from pip._vendor import appdirs as _appdirs
13+
from pip._vendor import platformdirs as _appdirs
1314

1415

1516
def user_cache_dir(appname: str) -> str:
@@ -18,7 +19,7 @@ def user_cache_dir(appname: str) -> str:
1819

1920
def user_config_dir(appname: str, roaming: bool = True) -> str:
2021
path = _appdirs.user_config_dir(appname, appauthor=False, roaming=roaming)
21-
if _appdirs.system == "darwin" and not os.path.isdir(path):
22+
if sys.platform == "darwin" and not os.path.isdir(path):
2223
path = os.path.expanduser("~/.config/")
2324
if appname:
2425
path = os.path.join(path, appname)
@@ -29,7 +30,11 @@ def user_config_dir(appname: str, roaming: bool = True) -> str:
2930
# see <https://github.com/pypa/pip/issues/1733>
3031
def site_config_dirs(appname: str) -> List[str]:
3132
dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
32-
if _appdirs.system not in ["win32", "darwin"]:
33+
if sys.platform == "darwin":
34+
# always look in /Library/Application Support/pip as well
35+
return dirval.split(os.pathsep) + ["/Library/Application Support/pip"]
36+
elif sys.platform == "win32":
37+
return [dirval]
38+
else:
3339
# always look in /etc directly as well
3440
return dirval.split(os.pathsep) + ["/etc"]
35-
return [dirval]

src/pip/_vendor/README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ Modifications
100100

101101
* ``setuptools`` is completely stripped to only keep ``pkg_resources``.
102102
* ``pkg_resources`` has been modified to import its dependencies from
103-
``pip._vendor``.
103+
``pip._vendor``, and to use the vendored copy of ``platformdirs``
104+
rather than ``appdirs``.
104105
* ``packaging`` has been modified to import its dependencies from
105106
``pip._vendor``.
106107
* ``html5lib`` has been modified to import six from ``pip._vendor``, to prefer
@@ -111,7 +112,7 @@ Modifications
111112
* ``requests`` has been modified to import its other dependencies from
112113
``pip._vendor`` and to *not* load ``simplejson`` (all platforms) and
113114
``pyopenssl`` (Windows).
114-
115+
* ``platformdirs`` has been modified to import its submodules from ``pip._vendor.platformdirs``.
115116

116117
Automatic Vendoring
117118
===================

src/pip/_vendor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def vendored(modulename):
5858
sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
5959

6060
# Actually alias all of our vendored dependencies.
61-
vendored("appdirs")
6261
vendored("cachecontrol")
6362
vendored("certifi")
6463
vendored("colorama")
@@ -74,6 +73,7 @@ def vendored(modulename):
7473
vendored("packaging.specifiers")
7574
vendored("pep517")
7675
vendored("pkg_resources")
76+
vendored("platformdirs")
7777
vendored("progress")
7878
vendored("requests")
7979
vendored("requests.exceptions")

0 commit comments

Comments
 (0)