From d03d9a94d25fda96ef9a160cf94bf5e710e07db3 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Tue, 17 Oct 2023 21:07:26 -0700 Subject: [PATCH 1/5] do not set locale on windows fix #434 --- radian/app.py | 8 +------- radian/rutils.py | 4 +--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/radian/app.py b/radian/app.py index 1da7937..bcc4fd3 100644 --- a/radian/app.py +++ b/radian/app.py @@ -215,16 +215,10 @@ def run(self, options, cleanup=None): # enable signal handlers os.environ["RCHITECT_REGISTER_SIGNAL_HANDLERS"] = "1" - if sys.platform.startswith("win"): - # avoid "using locale code page other than 1252 may cause problems" warning - lc_ctype = os.environ.pop('LC_CTYPE', "en_US.UTF-8") - else: - lc_ctype = None - rchitect.init(args=args, register_signal_handlers=True) if sys.platform.startswith("win"): - rutils.set_locale(lc_ctype = lc_ctype) + rutils.set_lang() try: rutils.source_radian_profile(options.profile) diff --git a/radian/rutils.py b/radian/rutils.py index 95b05a0..d4876e3 100644 --- a/radian/rutils.py +++ b/radian/rutils.py @@ -96,15 +96,13 @@ def register_cleanup(cleanup): onexit=True) -def set_locale(lc_ctype): +def set_lang(): if sys.platform.startswith("win"): ucrt = rcopy( reval('compareVersion(paste0(R.version$major, ".", R.version$minor), "4.2.0") >= 0')) if ucrt: if not os.environ.get("LANG", ""): os.environ["LANG"] = "en_US.UTF-8" - if lc_ctype: - reval("suppressWarnings(Sys.setlocale(locale = '{}'))".format(lc_ctype)) def run_on_load_hooks(): From c1b1743e6857ea49cf7a7e3799facb8995256c6a Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Tue, 17 Oct 2023 21:07:26 -0700 Subject: [PATCH 2/5] do not set locale on windows fix #434 --- radian/app.py | 2 +- radian/rutils.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/radian/app.py b/radian/app.py index bcc4fd3..e33c672 100644 --- a/radian/app.py +++ b/radian/app.py @@ -218,7 +218,7 @@ def run(self, options, cleanup=None): rchitect.init(args=args, register_signal_handlers=True) if sys.platform.startswith("win"): - rutils.set_lang() + rutils.set_utf8() try: rutils.source_radian_profile(options.profile) diff --git a/radian/rutils.py b/radian/rutils.py index d4876e3..d1da87b 100644 --- a/radian/rutils.py +++ b/radian/rutils.py @@ -1,7 +1,7 @@ import os import sys from rchitect import rcopy, reval, rcall -from rchitect.interface import roption +from rchitect.interface import roption, setoption from .key_bindings import map_key def is_ascii(str): @@ -96,13 +96,14 @@ def register_cleanup(cleanup): onexit=True) -def set_lang(): +def set_utf8(): if sys.platform.startswith("win"): ucrt = rcopy( reval('compareVersion(paste0(R.version$major, ".", R.version$minor), "4.2.0") >= 0')) if ucrt: if not os.environ.get("LANG", ""): - os.environ["LANG"] = "en_US.UTF-8" + os.environ["LANG"] = "en_US.UTF-8" + setoption("encoding", "UTF-8") def run_on_load_hooks(): From c0efbb6558aaed75e40fde7d2aa1a375994c35f7 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Tue, 17 Oct 2023 21:36:15 -0700 Subject: [PATCH 3/5] bump rchitect requirement --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c2f52c4..ccab43c 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def get_version(package): python_requires='>=3.6', install_requires=[ # 'rchitect@git+https://github.com/randy3k/rchitect', - 'rchitect>=0.4.1,<0.5.0', + 'rchitect>=0.4.3,<0.5.0', 'prompt_toolkit>=3.0.15,<3.1', 'pygments>=2.5.0' ], From 95194d12cb1ec83514af281fc4181934fd2de762 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Tue, 17 Oct 2023 22:54:47 -0700 Subject: [PATCH 4/5] a note about plot() --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1085bb..cd16d00 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ options( #### Unicode doesn't work in Windows and R 4.2+. -The latest version of R supports Unicode codepage directly. However, radian relies on Python and Python doesn't support Unicode in the way that R supports it. A workaround could be found here: https://github.com/randy3k/radian/issues/269#issuecomment-1169663251 +The latest version of R supports Unicode codepage directly. However, radian relies on Python and Python doesn't support Unicode in the way that R supports it. A workaround could be found here: https://github.com/randy3k/radian/issues/269#issuecomment-1169663251. Though it may break the ploting device (running `plot()` will kill radian). #### I can't specify python runtime in reticulate. From d9b31b354a49304723093646130116e55010f2b6 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Tue, 17 Oct 2023 22:55:02 -0700 Subject: [PATCH 5/5] bump to 0.6.8 --- radian/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radian/__init__.py b/radian/__init__.py index b3354fa..f1f4103 100644 --- a/radian/__init__.py +++ b/radian/__init__.py @@ -1,5 +1,5 @@ from .app import get_app, main -__version__ = '0.6.7' +__version__ = '0.6.8' __all__ = ["get_app", "main"]