## 事象 [[Python 3.10]]で[[PyYAML]]のインストールに失敗する。[[Python 3.8]]と[[Python 3.9]]ではインストールできることを確認済。 https://github.com/tadashi-aikawa/owlmixin/actions/runs/5610997504/jobs/10266728993 ```console • Installing pyyaml (5.4.1) ChefBuildError Backend subprocess exited when trying to invoke get_requires_for_build_wheel /tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg` !! ******************************************************************************** The license_file parameter is deprecated, use license_files instead. By 2023-Oct-30, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! parsed = self.parsers.get(option_name, lambda x: x)(value) running egg_info writing lib3/PyYAML.egg-info/PKG-INFO writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt writing top-level names to lib3/PyYAML.egg-info/top_level.txt Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires self.run_setup() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup exec(code, locals()) File "<string>", line 271, in <module> File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup return distutils.core.setup(**attrs) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 314, in run self.find_sources() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 322, in find_sources mm.run() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 551, in run self.add_defaults() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults sdist.add_defaults(self) File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/command/sdist.py", line 104, in add_defaults super().add_defaults() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults self._add_defaults_ext() File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext self.filelist.extend(build_ext.get_source_files()) File "<string>", line 201, in get_source_files File "/tmp/tmpisxf962k/.venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__ raise AttributeError(attr) AttributeError: cython_sources at /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/poetry/installation/chef.py:147 in _prepare 143│ 144│ error = ChefBuildError("\n\n".join(message_parts)) 145│ 146│ if error is not None: → 147│ raise error from None 148│ 149│ return path 150│ 151│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path: Note: This error originates from the build backend, and is likely not a problem with poetry but with pyyaml (5.4.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "pyyaml (==5.4.1)"'. ``` ## 原因 [[PyYAML]]のインストール時に[[Cython]]3系でビルドしようとするが、[[PyYAML]]が[[Cython]]3系に対応していないため、ビルドに失敗するから。(たぶん) ### 状況 - [[PyYAML]]は[[Cython]]を使っている - [[Cython]]は3系が3日ほど前にリリースされた - [PyYAML 5.4.1はPython3.9までのwhlしか提供していない](https://pypi.org/project/PyYAML/5.4.1/#files) - [PyYAML 6.0.0はPython3.11までwhlが提供されている](https://pypi.org/project/PyYAML/6.0/#files) - PyYAML 6.0.1はPython3.11までwhlが提供されており、[Cythonの3未満が指定されている](https://github.com/yaml/pyyaml/commit/ae08bdc82b4ddfcd2b93c8aedcd1963766c3307d) ### Python3.8と3.9でPyYAML 5.4.1がインストールできる理由 [[wheel]]ファイルが提供されているから。 ### Python3.10でPyYAML 5.4.1が以前はインストールできた理由 [[wheel]]ファイルが提供されていないためビルドを試みるが、そのときにインストールする[[Cython]]がバージョン指定されていないため、最新バージョンをインストールしようとする。 当時は2系が最新だったため、[[PyYAML]]のビルドにも成功するため。 ### Python3.10でPyYAML 5.4.1がインストールできない理由 [[wheel]]ファイルが提供されていないためビルドを試みるが、そのときにインストールする[[Cython]]がバージョン指定されていないため、最新の3系を取得してしまう。 [[PyYAML]]5.4.1は[[Cython]]3系に対応していないため、ビルドに失敗するから。 ## 解決方法 ### [[Python 3.10]]と[[Python 3.11]] [[PyYAML]]の6.0.0以上をインストールする。 ### [[Python 3.12]] [[PyYAML]]6.0.1以上をインストールする。 [PyYAML6.0.1はPython3.12のwheelファイルを提供していない](https://pypi.org/project/PyYAML/6.0.1/#files)ためビルドが必要になるが、[Cythonの3未満が指定されている](https://github.com/yaml/pyyaml/commit/ae08bdc82b4ddfcd2b93c8aedcd1963766c3307d)ため、ビルドに失敗しない。 ## 参考 - [Error installing Pyyaml\=\=5\.4, Cython\_sources · Issue \#724 · yaml/pyyaml](https://github.com/yaml/pyyaml/issues/724)