from zipfile import ZipFile


def extract_shp(path):
    """Return a geopandas-compatible path to the shapefile stored in a zip archive.

    If multiple shapefiles are included, return only the first one found.

    Parameters
    ----------
    path : Path
      Path to zip archive holding shapefile.

    Returns
    -------
    str
      zip:///<path to zip file>!<relative path to shapefile>
    """
    z = ZipFile(path)

    fn = next(filter(lambda x: x.endswith(".shp"), z.namelist()))
    z.close()

    return f"zip://{path.absolute()}!{fn}"