Kivy-ios: 工具链构建 python3 Kivy 错误

Kivy-ios: Toolchain build python3 Kivy error

我按照 these instructions 在我的 virtualbox macOS Big Sur 虚拟机中构建了 Kivy 和其他食谱。当我 运行 toolchain build python3 kivytoolchain build kivy 时,我遇到了以下错误。有什么建议吗?非常感谢。

(venv) xxxx-iMac kivy-ios % 工具链构建 python3 kivy

[INFO    ] Building with 2 processes, where supported
[INFO    ] Want to build ['python3', 'kivy']
[INFO    ] Loaded recipe python3 (depends of ['hostpython3', 'libffi', 'openssl'], 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 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 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 python (depends of ['python3'], optional are [])
[INFO    ] Loaded recipe host_setuptools3 (depends of ['openssl', 'hostpython3', 'python3'], optional are [])
[INFO    ] Loaded recipe hostlibffi (depends of [], optional are [])
[INFO    ] Loaded recipe hostopenssl (depends of [], optional are [])
[INFO    ] Loaded recipe freetype (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/jesscarlett/kivy-ios/dist/hostpython3/bin/python
[INFO    ] Global: hostpgen located at /Users/jesscarlett/kivy-ios/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
[INFO    ] Downloading http://download.savannah.gnu.org/releases/freetype/freetype-2.5.5.tar.bz2
Traceback (most recent call last):
  File "/Users/jesscarlett/venv/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1519, in main
    ToolchainCL()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1276, in __init__
    getattr(self, args.command)()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1337, in build
    build_recipes(args.recipe, ctx)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1127, in build_recipes
    recipe.execute()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 697, in execute
    self.download()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 73, in _cache_execution
    f(self, *args, **kwargs)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 732, in download
    self.download_file(self.url.format(version=self.version), fn)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 473, in download_file
    urlretrieve(url, filename, report_hook)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1847, in retrieve
    block = fp.read(bs)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tempfile.py", line 474, in func_wrapper
    return func(*args, **kwargs)
ValueError: read of closed file

这是我 运行 的时候: (venv) xxxxx-iMac kivy-ios % 工具链构建 kivy

[INFO    ] Building with 2 processes, where supported
[INFO    ] Want to build ['kivy']
[INFO    ] Loaded recipe kivy (depends of ['sdl2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'ios', 'pyobjus', 'python', 'host_setuptools3'], 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 python (depends of ['python3'], optional are [])
[INFO    ] Loaded recipe host_setuptools3 (depends of ['openssl', 'hostpython3', 'python3'], optional are [])
[INFO    ] Loaded recipe freetype (depends of [], optional are [])
[INFO    ] Loaded recipe python3 (depends of ['hostpython3', 'libffi', 'openssl'], optional are [])
[INFO    ] Loaded recipe openssl (depends of [], optional are [])
[INFO    ] Loaded recipe hostpython3 (depends of ['hostlibffi', 'hostopenssl'], optional are [])
[INFO    ] Loaded recipe libffi (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/jesscarlett/kivy-ios/dist/hostpython3/bin/python
[INFO    ] Global: hostpgen located at /Users/jesscarlett/kivy-ios/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/jesscarlett/kivy-ios/.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/jesscarlett/kivy-ios/.cache/freetype-freetype-2.5.5.tar.bz2
[DEBUG   ] New State: freetype.download at 2021-09-29 06:48:32.453443
[INFO    ] Extract freetype
[INFO    ] Extract freetype for x86_64
[WARNING ] Error extracting the archive /Users/jesscarlett/kivy-ios/.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/jesscarlett/kivy-ios/.cache/freetype-freetype-2.5.5.tar.bz2
Traceback (most recent call last):
  File "/Users/jesscarlett/venv/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1519, in main
    ToolchainCL()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1276, in __init__
    getattr(self, args.command)()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1337, in build
    build_recipes(args.recipe, ctx)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1127, in build_recipes
    recipe.execute()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 698, in execute
    self.extract()
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 73, in _cache_execution
    f(self, *args, **kwargs)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 742, in extract
    self.extract_arch(arch.arch)
  File "/Users/jesscarlett/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 746, in extract_arch
    dest_dir = join(build_dir, self.archive_root)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 90, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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'

您的 _init_.py 文件在 freetype 文件夹中(例如,/Library/Frameworks/Python.framework/Versions/3.x/lib/python3.x/site-packages/kivy_ios/recipes/freetype/_init_.py)指的是过时的URLlink,所以你只需要编辑文件,修改“url = "喜欢,

class FreetypeRecipe(Recipe):
    version = "2.5.5" 
    url =  "http://download.savannah.gnu.org/releases/freetype/freetype-{version}.tar.bz2" 
    library = "objs/.libs/libfreetype.a" 
    include_dir = ["include", ("builds/unix/ftconfig.h", "config/ftconfig.h")] 
    include_per_arch = True 

亲爱的 Taka(参考 Taka 的 post),非常感谢。这是我几个月来见过的最好的答案。你的方法在我的 MAC 和我的 MAC VM 上保存了 kivy。发生的事情是版本 freetype-2.5.5 被移动到 savannah 站点上的另一个子文件夹。较新的版本是 2.10.0。这就是我解决问题的方法:

  1. 进入init.py,更新版本=“2.10.0”。我不能只是 运行 toolchain build python3 kivy。这将再次抛出错误。

  2. 那我得去网站下载freetype-2.10.0.tar.bz2 文件并将其保存在 .cache/ 文件夹中。这是如何去 MAC 中的 .cache 文件夹。前往 Finder -> 前往 -> 前往文件夹 -> 输入 /users/{用户名}/.cache

解决此问题的一种方法是从此处下载预期的 freetype 包:

https://download-mirror.savannah.gnu.org/releases/freetype/freetype-old/freetype-2.5.5.tar.bz2

然后将其移动到预期位置。所以在你的情况下,你可以 运行:

mv ~/Downloads/free-type-2.5.5.tar.bz2 ~/kivy-ios/.cache/freetype-freetype-2.5.5.tar.bz2

然后重新运行 构建,它将解决这个问题。

不过,我认为这个错误可能表示环境问题。您应该验证您使用的 Python3 版本是否适用于 Kivy(目前是 3.7.x)。检查 python3 --version.