Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually set python encoding env var in subprocesses (to fix language issue) #2815

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/src/dependencies/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

DEP_MAX_PROGRESS = 0.8

ENV = {**os.environ, "PYTHONIOENCODING": "utf-8"}


@dataclass(frozen=True)
class DependencyInfo:
Expand Down Expand Up @@ -101,6 +103,7 @@ def install_dependencies_sync(
"--no-warn-script-location",
*extra_index_args,
],
env=ENV,
)
if exit_code != 0:
raise ValueError("An error occurred while installing dependencies.")
Expand Down Expand Up @@ -167,6 +170,7 @@ def get_progress_amount():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8",
env=ENV,
)
installing_name = "Unknown"
while True:
Expand Down Expand Up @@ -252,6 +256,7 @@ def uninstall_dependencies_sync(
*[d.package_name for d in dependencies],
"-y",
],
env=ENV,
)
if exit_code != 0:
raise ValueError("An error occurred while uninstalling dependencies.")
Expand Down Expand Up @@ -301,6 +306,7 @@ def get_progress_amount():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8",
env=ENV,
)
uninstalling_name = "Unknown"
while True:
Expand Down
3 changes: 3 additions & 0 deletions backend/src/server_process_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def _port_in_use(port: int):

SANIC_LOG_REGEX = re.compile(r"^\s*\[[^\[\]]*\] \[\d*\] \[(\w*)\] (.*)")

ENV = {**os.environ, "PYTHONIOENCODING": "utf-8"}


class _WorkerProcess:
def __init__(self, flags: list[str]):
Expand All @@ -43,6 +45,7 @@ def __init__(self, flags: list[str]):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env=ENV,
)
self._stop_event = threading.Event()

Expand Down
Loading