0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python3.12をサポートするツールで、pyinstaller5.10(Python3.12未対応)をインストールする

Last updated at Posted at 2023-05-02

環境

  • Python 3.11.2
  • poetry 1.4.2
  • pinstaller 5.10.1

やりたいこと

Python3.9以上で動くツールを作成しています。
pyinstallerは開発用時に利用したいです。
ライブラリはpoetryで管理しています。

pyproject.toml
[tool.poetry]
name = "yuji38kwmt-cli"
version = "0.1.0"
description = "yuji38kwmt's CLI"
authors = ["yuji38kwmt"]
license = "MIT"
packages = [
    { include = "yuji38kwmt_cli" }
]

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.group.dev.dependencies]
pyinstaller = "^5.10"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

起きたこと

poetry install時に以下のエラーが発生しました。

$ poetry install 
Updating dependencies
Resolving dependencies... (0.7s)

The current project's Python requirement (>=3.9,<4.0) is not compatible with some of the required packages Python requirement:
  - pyinstaller requires Python <3.12,>=3.7, so it will not be satisfied for Python >=3.12,<4.0
  - pyinstaller requires Python <3.12,>=3.7, so it will not be satisfied for Python >=3.12,<4.0

Because no versions of pyinstaller match >5.10,<5.10.1 || >5.10.1,<6.0
 and pyinstaller (5.10.0) requires Python <3.12,>=3.7, pyinstaller is forbidden.
So, because pyinstaller (5.10.1) requires Python <3.12,>=3.7
 and yuji38kwmt-cli depends on pyinstaller (^5.10), version solving failed.

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
    
    For pyinstaller, a possible solution would be to set the `python` property to ">=3.9,<3.12"
    For pyinstaller, a possible solution would be to set the `python` property to ">=3.9,<3.12"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

pyinstallerのPython requirementは<3.12,>=3.7なのに対して、私のツールは>=3.9,<4.0なので、インストールできませんでした。

解決策

私のツールのサポートしているPythonバージョンを、4.0未満から3.12未満に変更すれば解決します。

pyproject.toml
[tool.poetry.dependencies]
python = ">=3.9,<3.12"

私のツールはたぶんPython3.12でも動くはずなので、できればPython3.12もサポートするようにしたいです。

pyinstallerは開発時しか利用しないので、pyinstallerをインストール条件にPythonのバージョンを指定するようにしました。

pyproject.toml
[tool.poetry.group.dev.dependencies]
pyinstaller = {version="^5.10", python="<3.12"}

Python3.12で開発する頃にはpyinstallerもPython3.12に対応していると思うので、問題ないでしょう。

補足

Python3.12をサポートしていない理由を質問しました。

Python's bytecode (which PyInstaller has to read) is not backwards compatible. Nor is its binary ABI which PyInstaller's bootloaders depend on. And in the case of Python 3.12, the standard lib libraries imp and distutils are being removed so PyInstaller needs some fairly serious work to remove its dependency on those.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?