mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 10:56:10 +00:00
Leave the tar extraction fallback where it was
Refusing the install on a Python without the extraction filters is a change to how every archive on every platform is unpacked, and it has nothing to do with shipping a Vulkan whisper-server. On those Pythons the download stops working altogether, which is a worse answer than the one that was there. Worth doing on its own terms, in its own change, where the versions it turns away can be argued about without a backend release riding on it.
This commit is contained in:
+2
-5
@@ -353,11 +353,8 @@ def _extract(archive, into):
|
|||||||
with tarfile.open(archive, "r:gz") as tar:
|
with tarfile.open(archive, "r:gz") as tar:
|
||||||
try:
|
try:
|
||||||
tar.extractall(into, filter="data")
|
tar.extractall(into, filter="data")
|
||||||
except TypeError as exc: # Python 3.11.0-3 lack extraction filters
|
except TypeError: # Python without the extraction filters
|
||||||
raise LocalError(t(
|
tar.extractall(into)
|
||||||
"Could not safely unpack {name} with this Python version",
|
|
||||||
name=os.path.basename(str(archive)),
|
|
||||||
)) from exc
|
|
||||||
except (tarfile.TarError, zipfile.BadZipFile, OSError) as exc:
|
except (tarfile.TarError, zipfile.BadZipFile, OSError) as exc:
|
||||||
raise LocalError(t("Could not unpack {name}: {error}",
|
raise LocalError(t("Could not unpack {name}: {error}",
|
||||||
name=os.path.basename(str(archive)), error=exc)) from exc
|
name=os.path.basename(str(archive)), error=exc)) from exc
|
||||||
|
|||||||
@@ -500,18 +500,6 @@ class InstallProgram(Local):
|
|||||||
with self.assertRaises(ggml.LocalError):
|
with self.assertRaises(ggml.LocalError):
|
||||||
self.install("whisper-bin-ubuntu-x64.tar.gz", archive=buf.getvalue())
|
self.install("whisper-bin-ubuntu-x64.tar.gz", archive=buf.getvalue())
|
||||||
|
|
||||||
def test_python_without_safe_tar_filters_refuses_the_archive(self):
|
|
||||||
archive = self.path("bundle.tar.gz")
|
|
||||||
archive.write_bytes(self.archive)
|
|
||||||
destination = self.path("unpacked")
|
|
||||||
destination.mkdir()
|
|
||||||
with mock.patch.object(tarfile.TarFile, "extractall",
|
|
||||||
side_effect=[TypeError("no filter"), None]) as extract:
|
|
||||||
with self.assertRaises(ggml.LocalError) as caught:
|
|
||||||
ggml._extract(archive, destination)
|
|
||||||
self.assertEqual(1, extract.call_count)
|
|
||||||
self.assertIn("safely", str(caught.exception))
|
|
||||||
|
|
||||||
def test_everything_is_asked_for_over_tls(self):
|
def test_everything_is_asked_for_over_tls(self):
|
||||||
for url in (hub.GITHUB_API, hub.HF_API, hub.HF_FILES):
|
for url in (hub.GITHUB_API, hub.HF_API, hub.HF_FILES):
|
||||||
with self.subTest(url=url):
|
with self.subTest(url=url):
|
||||||
|
|||||||
Reference in New Issue
Block a user