BYVoid / OpenCC

Conversion between Traditional and Simplified Chinese
https://opencc.byvoid.com/
Apache License 2.0
8.48k stars 980 forks source link

Add support for apple silicon build tag #716

Closed p208p2002 closed 2 years ago

p208p2002 commented 2 years ago

在使用 Apple M1 build wheel 時會因為錯誤的 platform_tag 導致建立出來的 .whl 無法安裝

這個 PR 讓 build 出來的 .whl 能夠被正確安裝。應該可以幫助到需要自行編譯套件的使用者(#565 )

測試目前自行編譯的版本可以運行在m1底下了

lannka commented 1 year ago

@p208p2002 thanks for the fix. I tried to install using npm install BYVoid/OpenCC on my M1 machine, but it failed with errors. Do you know what can be the cause?

Full stack trace here:

npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /Users/uuu/.nvm/versions/node/v16.13.1/bin/node /Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/uuu/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! > opencc@1.1.6 install
npm ERR! > node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild
npm ERR!
npm ERR!   COPY Release/hk2s.json
npm ERR!   COPY Release/hk2t.json
npm ERR!   COPY Release/jp2t.json
npm ERR!   COPY Release/s2hk.json
npm ERR!   COPY Release/s2t.json
npm ERR!   COPY Release/s2tw.json
npm ERR!   COPY Release/s2twp.json
npm ERR!   COPY Release/t2hk.json
npm ERR!   COPY Release/t2jp.json
npm ERR!   COPY Release/t2s.json
npm ERR!   COPY Release/t2tw.json
npm ERR!   COPY Release/tw2s.json
npm ERR!   COPY Release/tw2sp.json
npm ERR!   COPY Release/tw2t.json
npm ERR!   TOUCH Release/obj.target/configs.stamp
npm ERR!   CXX(target) Release/obj.target/opencc/node/marisa.o
npm ERR!   CXX(target) Release/obj.target/opencc/node/opencc.o
npm ERR!   SOLINK_MODULE(target) Release/opencc.node
npm ERR!   ACTION binding_gyp_dicts_target_STCharacters Release/STCharacters.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_STPhrases Release/STPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TSCharacters Release/TSCharacters.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TSPhrases Release/TSPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWVariants Release/TWVariants.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWVariantsRevPhrases Release/TWVariantsRevPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_JPVariants Release/JPVariants.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWPhrases_txt Release/TWPhrases.txt
npm ERR! Failed to execute '/Users/uuu/.nvm/versions/node/v16.13.1/bin/node /Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node --module_name=opencc --module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! [opencc] Removing "/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release"
npm ERR!   COPY Release/hk2s.json
npm ERR!   COPY Release/hk2t.json
npm ERR!   COPY Release/jp2t.json
npm ERR!   COPY Release/s2hk.json
npm ERR!   COPY Release/s2t.json
npm ERR!   COPY Release/s2tw.json
npm ERR!   COPY Release/s2twp.json
npm ERR!   COPY Release/t2hk.json
npm ERR!   COPY Release/t2jp.json
npm ERR!   COPY Release/t2s.json
npm ERR!   COPY Release/t2tw.json
npm ERR!   COPY Release/tw2s.json
npm ERR!   COPY Release/tw2sp.json
npm ERR!   COPY Release/tw2t.json
npm ERR!   TOUCH Release/obj.target/configs.stamp
npm ERR!   CXX(target) Release/obj.target/opencc/node/marisa.o
npm ERR!   CXX(target) Release/obj.target/opencc/node/opencc.o
npm ERR!   SOLINK_MODULE(target) Release/opencc.node
npm ERR!   ACTION binding_gyp_dicts_target_STCharacters Release/STCharacters.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_STPhrases Release/STPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TSCharacters Release/TSCharacters.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TSPhrases Release/TSPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWVariants Release/TWVariants.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWVariantsRevPhrases Release/TWVariantsRevPhrases.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_JPVariants Release/JPVariants.ocd2
npm ERR!   ACTION binding_gyp_dicts_target_TWPhrases_txt Release/TWPhrases.txt
npm ERR! Failed to execute '/Users/uuu/.nvm/versions/node/v16.13.1/bin/node /Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node --module_name=opencc --module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.14.0
npm ERR! node-pre-gyp info using node@16.13.1 | darwin | arm64
npm ERR! node-pre-gyp WARN Using needle for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for "/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/BYVoid/OpenCC/releases/download/1.1.6/opencc-v1.1.6-node-v93-darwin-arm64.tar.gz
npm ERR! node-pre-gyp http 404 https://github.com/BYVoid/OpenCC/releases/download/1.1.6/opencc-v1.1.6-node-v93-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404): https://github.com/BYVoid/OpenCC/releases/download/1.1.6/opencc-v1.1.6-node-v93-darwin-arm64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for opencc@1.1.6 and node@16.13.1 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball https://github.com/BYVoid/OpenCC/releases/download/1.1.6/opencc-v1.1.6-node-v93-darwin-arm64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/Library/Caches/node-gyp/16.13.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/uuu/Library/Caches/node-gyp/16.13.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/uuu/Library/Caches/node-gyp/16.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! /bin/sh: python: command not found
npm ERR! make: *** [Release/TWPhrases.txt] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 22.6.0
npm ERR! gyp ERR! command "/Users/uuu/.nvm/versions/node/v16.13.1/bin/node" "/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node" "--module_name=opencc" "--module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/uuu/.nvm/versions/node/v16.13.1/bin/node /Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node --module_name=opencc --module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 22.6.0
npm ERR! node-pre-gyp ERR! command "/Users/uuu/.nvm/versions/node/v16.13.1/bin/node" "/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC
npm ERR! node-pre-gyp ERR! node -v v16.13.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.14.0
npm ERR! node-pre-gyp ERR! not ok
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.14.0
npm ERR! node-pre-gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/uuu/Library/Caches/node-gyp/16.13.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/uuu/Library/Caches/node-gyp/16.13.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/uuu/Library/Caches/node-gyp/16.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! /bin/sh: python: command not found
npm ERR! make: *** [Release/TWPhrases.txt] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 22.6.0
npm ERR! gyp ERR! command "/Users/uuu/.nvm/versions/node/v16.13.1/bin/node" "/Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node" "--module_name=opencc" "--module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/uuu/.nvm/versions/node/v16.13.1/bin/node /Users/uuu/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --module=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release/opencc.node --module_name=opencc --module_path=/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 22.6.0
npm ERR! node-pre-gyp ERR! command "/Users/uuu/.nvm/versions/node/v16.13.1/bin/node" "/Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC/node_modules/.bin/node-pre-gyp" "rebuild"
npm ERR! node-pre-gyp ERR! cwd /Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC
npm ERR! node-pre-gyp ERR! node -v v16.13.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.14.0
npm ERR! node-pre-gyp ERR! not ok
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /Users/uuu/.npm/_cacache/tmp/git-cloneiFvzkC
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild