Skip to content

Commit dd1a346

Browse files
committed
Remove egg_link_path()
1 parent 9313884 commit dd1a346

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

src/pip/_internal/req/req_uninstall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from pip._internal.exceptions import UninstallationError
1313
from pip._internal.locations import get_bin_prefix, get_bin_user
1414
from pip._internal.utils.compat import WINDOWS
15+
from pip._internal.utils.egg_link import egg_link_path_from_location
1516
from pip._internal.utils.logging import getLogger, indent_log
1617
from pip._internal.utils.misc import (
1718
ask,
1819
dist_in_usersite,
1920
dist_is_local,
20-
egg_link_path,
2121
is_local,
2222
normalize_path,
2323
renames,
@@ -459,7 +459,7 @@ def from_dist(cls, dist: Distribution) -> "UninstallPathSet":
459459
return cls(dist)
460460

461461
paths_to_remove = cls(dist)
462-
develop_egg_link = egg_link_path(dist)
462+
develop_egg_link = egg_link_path_from_location(dist.project_name)
463463
develop_egg_link_egg_info = "{}.egg-info".format(
464464
pkg_resources.to_filename(dist.project_name)
465465
)

src/pip/_internal/utils/egg_link.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import sys
77
from typing import Optional
88

9-
from pip._vendor.pkg_resources import Distribution
10-
119
from pip._internal.locations import site_packages, user_site
1210
from pip._internal.utils.virtualenv import (
1311
running_under_virtualenv,
@@ -17,7 +15,6 @@
1715
__all__ = [
1816
"egg_link_path_from_sys_path",
1917
"egg_link_path_from_location",
20-
"egg_link_path",
2118
]
2219

2320

@@ -76,8 +73,3 @@ def egg_link_path_from_location(raw_name: str) -> Optional[str]:
7673
if os.path.isfile(egglink):
7774
return egglink
7875
return None
79-
80-
81-
def egg_link_path(dist):
82-
# type: (Distribution) -> Optional[str]
83-
return egg_link_path_from_location(dist.project_name)

src/pip/_internal/utils/misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from pip._internal.exceptions import CommandError
4040
from pip._internal.locations import get_major_minor_version, site_packages, user_site
4141
from pip._internal.utils.compat import WINDOWS
42-
from pip._internal.utils.egg_link import egg_link_path
42+
from pip._internal.utils.egg_link import egg_link_path_from_location
4343
from pip._internal.utils.virtualenv import running_under_virtualenv
4444

4545
__all__ = [
@@ -380,7 +380,7 @@ def dist_location(dist: Distribution) -> str:
380380
381381
The returned location is normalized (in particular, with symlinks removed).
382382
"""
383-
egg_link = egg_link_path(dist)
383+
egg_link = egg_link_path_from_location(dist.project_name)
384384
if egg_link:
385385
return normalize_path(egg_link)
386386
return normalize_path(dist.location)

tests/unit/test_utils.py

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from pip._internal.exceptions import HashMismatch, HashMissing, InstallationError
1919
from pip._internal.utils.deprecation import PipDeprecationWarning, deprecated
20+
from pip._internal.utils.egg_link import egg_link_path_from_location
2021
from pip._internal.utils.encoding import BOMS, auto_decode
2122
from pip._internal.utils.glibc import (
2223
glibc_version_string,
@@ -28,7 +29,6 @@
2829
HiddenText,
2930
build_netloc,
3031
build_url_from_netloc,
31-
egg_link_path,
3232
format_size,
3333
get_distribution,
3434
get_prog,
@@ -51,7 +51,7 @@
5151

5252

5353
class Tests_EgglinkPath:
54-
"util.egg_link_path() tests"
54+
"util.egg_link_path_from_location() tests"
5555

5656
def setup(self):
5757

@@ -106,19 +106,25 @@ def test_egglink_in_usersite_notvenv(self):
106106
self.mock_virtualenv_no_global.return_value = False
107107
self.mock_running_under_virtualenv.return_value = False
108108
self.mock_isfile.side_effect = self.eggLinkInUserSite
109-
assert egg_link_path(self.mock_dist) == self.user_site_egglink
109+
assert (
110+
egg_link_path_from_location(self.mock_dist.project_name)
111+
== self.user_site_egglink
112+
)
110113

111114
def test_egglink_in_usersite_venv_noglobal(self):
112115
self.mock_virtualenv_no_global.return_value = True
113116
self.mock_running_under_virtualenv.return_value = True
114117
self.mock_isfile.side_effect = self.eggLinkInUserSite
115-
assert egg_link_path(self.mock_dist) is None
118+
assert egg_link_path_from_location(self.mock_dist.project_name) is None
116119

117120
def test_egglink_in_usersite_venv_global(self):
118121
self.mock_virtualenv_no_global.return_value = False
119122
self.mock_running_under_virtualenv.return_value = True
120123
self.mock_isfile.side_effect = self.eggLinkInUserSite
121-
assert egg_link_path(self.mock_dist) == self.user_site_egglink
124+
assert (
125+
egg_link_path_from_location(self.mock_dist.project_name)
126+
== self.user_site_egglink
127+
)
122128

123129
# ####################### #
124130
# # egglink in sitepkgs # #
@@ -127,19 +133,28 @@ def test_egglink_in_sitepkgs_notvenv(self):
127133
self.mock_virtualenv_no_global.return_value = False
128134
self.mock_running_under_virtualenv.return_value = False
129135
self.mock_isfile.side_effect = self.eggLinkInSitePackages
130-
assert egg_link_path(self.mock_dist) == self.site_packages_egglink
136+
assert (
137+
egg_link_path_from_location(self.mock_dist.project_name)
138+
== self.site_packages_egglink
139+
)
131140

132141
def test_egglink_in_sitepkgs_venv_noglobal(self):
133142
self.mock_virtualenv_no_global.return_value = True
134143
self.mock_running_under_virtualenv.return_value = True
135144
self.mock_isfile.side_effect = self.eggLinkInSitePackages
136-
assert egg_link_path(self.mock_dist) == self.site_packages_egglink
145+
assert (
146+
egg_link_path_from_location(self.mock_dist.project_name)
147+
== self.site_packages_egglink
148+
)
137149

138150
def test_egglink_in_sitepkgs_venv_global(self):
139151
self.mock_virtualenv_no_global.return_value = False
140152
self.mock_running_under_virtualenv.return_value = True
141153
self.mock_isfile.side_effect = self.eggLinkInSitePackages
142-
assert egg_link_path(self.mock_dist) == self.site_packages_egglink
154+
assert (
155+
egg_link_path_from_location(self.mock_dist.project_name)
156+
== self.site_packages_egglink
157+
)
143158

144159
# ################################## #
145160
# # egglink in usersite & sitepkgs # #
@@ -148,19 +163,28 @@ def test_egglink_in_both_notvenv(self):
148163
self.mock_virtualenv_no_global.return_value = False
149164
self.mock_running_under_virtualenv.return_value = False
150165
self.mock_isfile.return_value = True
151-
assert egg_link_path(self.mock_dist) == self.user_site_egglink
166+
assert (
167+
egg_link_path_from_location(self.mock_dist.project_name)
168+
== self.user_site_egglink
169+
)
152170

153171
def test_egglink_in_both_venv_noglobal(self):
154172
self.mock_virtualenv_no_global.return_value = True
155173
self.mock_running_under_virtualenv.return_value = True
156174
self.mock_isfile.return_value = True
157-
assert egg_link_path(self.mock_dist) == self.site_packages_egglink
175+
assert (
176+
egg_link_path_from_location(self.mock_dist.project_name)
177+
== self.site_packages_egglink
178+
)
158179

159180
def test_egglink_in_both_venv_global(self):
160181
self.mock_virtualenv_no_global.return_value = False
161182
self.mock_running_under_virtualenv.return_value = True
162183
self.mock_isfile.return_value = True
163-
assert egg_link_path(self.mock_dist) == self.site_packages_egglink
184+
assert (
185+
egg_link_path_from_location(self.mock_dist.project_name)
186+
== self.site_packages_egglink
187+
)
164188

165189
# ############## #
166190
# # no egglink # #
@@ -169,19 +193,19 @@ def test_noegglink_in_sitepkgs_notvenv(self):
169193
self.mock_virtualenv_no_global.return_value = False
170194
self.mock_running_under_virtualenv.return_value = False
171195
self.mock_isfile.return_value = False
172-
assert egg_link_path(self.mock_dist) is None
196+
assert egg_link_path_from_location(self.mock_dist.project_name) is None
173197

174198
def test_noegglink_in_sitepkgs_venv_noglobal(self):
175199
self.mock_virtualenv_no_global.return_value = True
176200
self.mock_running_under_virtualenv.return_value = True
177201
self.mock_isfile.return_value = False
178-
assert egg_link_path(self.mock_dist) is None
202+
assert egg_link_path_from_location(self.mock_dist.project_name) is None
179203

180204
def test_noegglink_in_sitepkgs_venv_global(self):
181205
self.mock_virtualenv_no_global.return_value = False
182206
self.mock_running_under_virtualenv.return_value = True
183207
self.mock_isfile.return_value = False
184-
assert egg_link_path(self.mock_dist) is None
208+
assert egg_link_path_from_location(self.mock_dist.project_name) is None
185209

186210

187211
@patch("pip._internal.utils.misc.dist_in_usersite")

0 commit comments

Comments
 (0)