Skip to content

Commit 87511e5

Browse files
committed
Derive requirement from wheel name if available.
1 parent 36781cd commit 87511e5

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/pip/_internal/req/constructors.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,34 +277,19 @@ def with_source(text):
277277
'archives'.format(name) + deduce_helpful_msg(p)
278278
)
279279

280-
# it's a local file, dir, or url
281-
if link:
282-
# wheel file
283-
if link.is_wheel:
284-
wheel = Wheel(link.filename) # can raise InvalidWheelFilename
285-
req_as_string = "%s==%s" % (wheel.name, wheel.version)
286-
else:
287-
# set the req to the egg fragment. when it's not there, this
288-
# will become an 'unnamed' requirement
289-
req_as_string = link.egg_fragment
290-
291-
# a requirement specifier
292-
else:
293-
req_as_string = name
294-
295280
if extras_as_string:
296281
extras = Requirement("placeholder" + extras_as_string.lower()).extras
297282
else:
298283
extras = ()
299-
if req_as_string is not None:
284+
# wheel file
285+
if link and link.is_wheel:
286+
wheel = Wheel(link.filename) # can raise InvalidWheelFilename
287+
wheel_req = "%s==%s" % (wheel.name, wheel.version)
300288
try:
301-
_req = Requirement(req_as_string)
289+
req.requirement = Requirement(wheel_req)
302290
except InvalidRequirement:
303-
# !under construction! this section being moved above
304-
msg = ''
305-
raise InstallationError(msg)
306-
else:
307-
_req = None
291+
pass
292+
requirement = req.requirement
308293

309294
return InstallRequirement(
310295
req.requirement, comes_from, link=link, markers=markers,

0 commit comments

Comments
 (0)