Skip to content

Commit

Permalink
Add non-functional WheelDistribution.locate_file() method (#11685)
Browse files Browse the repository at this point in the history
importlib.metadata.Distribution was always meant to be a proper ABC with
API enforcement, but this enforcement was never added (probably due to
Python 2.7 compatibility concerns). Upstream would like to fix this
wart, so let's define a locate_file() method that simply raises
NotImplementedError as permitted.

Co-authored-by: Stéphane Bidoul <[email protected]>
Co-authored-by: Richard Si <[email protected]>
  • Loading branch information
3 people authored Jan 12, 2025
1 parent 394e032 commit d2bb8eb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pip/_internal/metadata/importlib/_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib.metadata
import pathlib
import zipfile
from os import PathLike
from typing import (
Collection,
Dict,
Expand Down Expand Up @@ -95,6 +96,11 @@ def read_text(self, filename: str) -> Optional[str]:
raise UnsupportedWheel(error)
return text

def locate_file(self, path: str | PathLike[str]) -> pathlib.Path:
# This method doesn't make sense for our in-memory wheel, but the API
# requires us to define it.
raise NotImplementedError


class Distribution(BaseDistribution):
def __init__(
Expand Down

0 comments on commit d2bb8eb

Please sign in to comment.