From bbf83c4a4e10b8d069821e1cf36c1c0d9368386b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Hackathon=208th=20No.7=E3=80=91Python?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=80=82=E9=85=8D=202=20(#3967)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * auto opencc * Update setup.py --- setup.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 507a51f32..59a3e7db1 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,26 @@ HERE = Path(os.path.abspath(os.path.dirname(__file__))) VERSION = '0.0.0' COMMITID = 'none' + +def determine_opencc_version(): + # get gcc version + gcc_version = None + try: + output = sp.check_output( + ['gcc', '--version'], stderr=sp.STDOUT, text=True) + for line in output.splitlines(): + if "gcc" in line: + gcc_version = line.split()[-1] + except Exception as e: + gcc_version = None + + # determine opencc version + if gcc_version: + if int(gcc_version.split(".")[0]) <= 9: + return "opencc==1.1.6" # GCC<=9 need opencc==1.1.6 + return "opencc" # default + + base = [ "braceexpand", "editdistance", @@ -48,7 +68,7 @@ base = [ "matplotlib<=3.8.4", "nara_wpe", "onnxruntime>=1.11.0", - "opencc==1.1.6", + determine_opencc_version(), # opencc or opencc==1.1.6 "opencc-python-reimplemented", "pandas", "paddleaudio>=1.1.0",