fix: escape pysqlite swapping (#410)
This commit is contained in:
@@ -60,22 +60,32 @@ def use_pysqlite3():
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
if platform.system() == "Linux" and sqlite3.sqlite_version_info < (3, 35, 0):
|
if platform.system() == "Linux" and sqlite3.sqlite_version_info < (3, 35, 0):
|
||||||
# According to the Chroma team, this patch only works on Linux
|
try:
|
||||||
import datetime
|
# According to the Chroma team, this patch only works on Linux
|
||||||
import subprocess
|
import datetime
|
||||||
import sys
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
[sys.executable, "-m", "pip", "install", "pysqlite3-binary", "--quiet", "--disable-pip-version-check"]
|
||||||
|
)
|
||||||
|
|
||||||
subprocess.check_call(
|
__import__("pysqlite3")
|
||||||
[sys.executable, "-m", "pip", "install", "pysqlite3-binary", "--quiet", "--disable-pip-version-check"]
|
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
|
||||||
)
|
|
||||||
|
|
||||||
__import__("pysqlite3")
|
# Let the user know what happened.
|
||||||
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
|
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
||||||
|
print(
|
||||||
# Let the user know what happened.
|
f"{current_time} [embedchain] [INFO]",
|
||||||
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
"Swapped std-lib sqlite3 with pysqlite3 for ChromaDb compatibility.",
|
||||||
print(
|
f"Your original version was {sqlite3.sqlite_version}.",
|
||||||
f"{current_time} [embedchain] [INFO]",
|
)
|
||||||
"Swapped std-lib sqlite3 with pysqlite3 for ChromaDb compatibility.",
|
except Exception as e:
|
||||||
f"Your original version was {sqlite3.sqlite_version}.",
|
# Escape all exceptions
|
||||||
)
|
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S,%f")[:-3]
|
||||||
|
print(
|
||||||
|
f"{current_time} [embedchain] [ERROR]",
|
||||||
|
"Failed to swap std-lib sqlite3 with pysqlite3 for ChromaDb compatibility.",
|
||||||
|
f"Error:",
|
||||||
|
e
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user