chen3feng / blade-build

Blade is a powerful build system from Tencent, supports many mainstream programming languages, such as C/C++, java, scala, python, protobuf...
Other
2.05k stars 500 forks source link

Sequence 从 Python3.10 起改变了坐标,需要调整 import #995

Closed fish2bird closed 2 years ago

fish2bird commented 2 years ago

https://github.com/chen3feng/blade-build/blob/e9784d69064518f31aa61eda08de2726f491d664/src/blade/pathlib.py#L14

使用高版本 python 3.10 构建发现

./blade build yadcc/...
Traceback (most recent call last):
  File "/opt/buildtools/python-3.10.2/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/buildtools/python-3.10.2/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/**/yadcc/thirdparty/blade/blade.zip/__main__.py", line 14, in <module>
  File "/**/yadcc/thirdparty/blade/blade.zip/blade/main.py", line 23, in <module>
  File "/**/yadcc/thirdparty/blade/blade.zip/blade/build_manager.py", line 31, in <module>
  File "/**/yadcc/thirdparty/blade/blade.zip/blade/load_build_files.py", line 32, in <module>
  File "/**/yadcc/thirdparty/blade/blade.zip/blade/pathlib.py", line 14, in <module>
    from urllib.parse import quote_from_bytes as urlquote_from_bytes
ImportError: cannot import name 'Sequence' from 'collections' (/opt/buildtools/python-3.10.2/lib/python3.10/collections/__init__.py)

按照提示兼容补丁如下后解决

[huawei@0149829b4131 /opt/build/c00644348/yadcc/build/external/flare/thirdparty/blade]$diff -r blade_orig/ blade_patched/
diff -r blade_orig/blade/pathlib.py blade_patched/blade/pathlib.py
14c14,19
< from collections import Sequence
---
>
> try:
>     from collections import Sequence
> except ImportError:
>     from collections.abc import Sequence
>
chen3feng commented 2 years ago

thanks