pythonでiosアプリを作れるGUIのkivy-iosの環境構築を行おうとしたところ、エラーが出てこの解決策が調べてもあまり出ていなかったのでメモとして書いておく。
エラー内容
“toolchain build python kivy
“を実行したところ以下のエラーが起きた。
% toolchain build python kivy
[INFO ] Building with 4 processes, where supported
[INFO ] Want to build ['python', 'kivy']
[INFO ] Loaded recipe python (depends of ['python3'], optional are [])
[INFO ] Loaded recipe kivy (depends of ['sdl2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf',
'ios', 'pyobjus', 'python', 'host_setuptools3'], optional are [])
[INFO ] Loaded recipe python3 (depends of ['hostpython3', 'libffi', 'openssl'], optional
are [])
[INFO ] Loaded recipe sdl2 (depends of [], optional are [])
[INFO ] Loaded recipe sdl2_image (depends of ['sdl2'], optional are [])
[INFO ] Loaded recipe sdl2_mixer (depends of ['sdl2'], optional are [])
[INFO ] Loaded recipe sdl2_ttf (depends of ['sdl2', 'freetype'], optional are [])
[INFO ] Loaded recipe ios (depends of ['python'], optional are [])
[INFO ] Loaded recipe pyobjus (depends of ['python'], optional are [])
[INFO ] Loaded recipe host_setuptools3 (depends of ['openssl', 'hostpython3', 'python3'],
optional are [])
[INFO ] Loaded recipe hostpython3 (depends of ['hostlibffi', 'hostopenssl'], optional
are [])
[INFO ] Loaded recipe libffi (depends of [], optional are [])
[INFO ] Loaded recipe openssl (depends of [], optional are [])
[INFO ] Loaded recipe freetype (depends of [], optional are [])
[INFO ] Loaded recipe hostlibffi (depends of [], optional are [])
[INFO ] Loaded recipe hostopenssl (depends of [], optional are [])
[INFO ] Build order is ['freetype', 'hostlibffi', 'hostopenssl', 'libffi', 'openssl',
'sdl2', 'hostpython3', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'python3',
'host_setuptools3', 'python', 'ios', 'pyobjus', 'kivy']
[INFO ] Recipe order is ['freetype', 'hostlibffi', 'hostopenssl', 'libffi', 'openssl',
'sdl2', 'hostpython3', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'python3',
'host_setuptools3', 'ios', 'pyobjus', 'kivy']
[INFO ] Include dir added: {arch.arch}/freetype
[INFO ] Include dir added: {arch.arch}/hostlibffi
[INFO ] Include dir added: {arch.arch}/ffi
[INFO ] Include dir added: {arch.arch}/openssl
[INFO ] Include dir added: common/sdl2
[INFO ] Global: hostpython located at /Users/syoya/Documents/app/dist/hostpython3/bin/python
[INFO ] Global: hostpgen located at /Users/syoya/Documents/app/dist/hostpython3/bin/pgen
[INFO ] Include dir added: common/sdl2_image
[INFO ] Include dir added: common/sdl2_mixer
[INFO ] Include dir added: common/sdl2_ttf
[INFO ] Download freetype
[WARNING ] Error extracting the archive /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
[WARNING ] This is usually caused by a corrupt download. The file will be removed and
re-downloaded on the next run.
[WARNING ] /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
[DEBUG ] New State: freetype.download at 2021-10-17 04:44:28.116389
[INFO ] Extract freetype
[INFO ] Extract freetype for x86_64
[WARNING ] Error extracting the archive /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
[WARNING ] This is usually caused by a corrupt download. The file will be removed and
re-downloaded on the next run.
[WARNING ] /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
Traceback (most recent call last):
File "/Users/syoya/Documents/app/venv/bin/toolchain", line 8, in <module>
sys.exit(main())
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1519, in main
ToolchainCL()
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1276, in __init__
getattr(self, args.command)()
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1337, in build
build_recipes(args.recipe, ctx)
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1127, in build_recipes
recipe.execute()
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 698, in execute
self.extract()
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 73, in _cache_execution
f(self, *args, **kwargs)
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 742, in extract
self.extract_arch(arch.arch)
File "/Users/syoya/Documents/app/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 746, in extract_arch
dest_dir = join(build_dir, self.archive_root)
File "/Users/syoya/.pyenv/versions/3.10.0/lib/python3.10/posixpath.py", line 90, in join
genericpath._check_arg_types('join', a, *p)
File "/Users/syoya/.pyenv/versions/3.10.0/lib/python3.10/genericpath.py", line 152,
in _check_arg_types
raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
エラーの原因
エラー文の以下の部分に原因が書かれている。
[WARNING ] Error extracting the archive /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
[WARNING ] This is usually caused by a corrupt download. The file will be removed and re-downloaded on the next run.
[WARNING ] /Users/syoya/Documents/app/.cache/freetype-freetype-2.5.5.tar.bz2
どうやら”freetype-freetype-2.5.5.tar.bz2
“のアーカイブの抽出時にエラーが起きたっぽい。
このファイルを見てみると、
0バイトでした。このファイルが意味をなしていないのが原因です。
解決策
解決方法としては2つあります。
その1. ブラウザからファイルをダウンロードする
ここから該当するファイルをダウンロードし、ファイルを置き換える。
その2. ダウンロードするためのプログラムを書き換える
公式の修正のように
“仮想環境名/lib/python3.*/site-packages/kivy_ios/recipes/freetype/init.py
“のファイルを書き換える方法です。
まとめ
この記事を書いた後でkivy-iosのgithubを見てみると修正版”kivy-ios1.2.1″がリリースされていました。
しかし、pypl経由でダウンロードしたkivyはバージョンが1.2.1であるのにURLが修正されていませんでした。
てことで、girhubから直接masterブランチをインストールしてきました。
中身を確認するとしっかりURLが修正されていました。
githubから直接インストールする方法は以下の記事を参考にしてみてください。