Skip to content

Commit

Permalink
tool.poetry-pyinstaller-plugin.version option added
Browse files Browse the repository at this point in the history
  • Loading branch information
thmahe committed May 26, 2024
1 parent a865115 commit e1f8ae8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ If you are having troubles to install the plugin please refer to Poetry document
Are listed in this sections all options available to configure `poetry-pyinstaller-plugin` in your `pyproject.toml`

* `[tool.poetry-pyinstaller-plugin]`
* `version` (string)
* Version of PyInstaller to use during build
* Does not support version constraint
* `scripts` (dictionary)
* Where key is the program name and value a path to script or a `PyInstallerTarget` spec
* Example: `prog-name = "my_package/script.py"`
Expand Down Expand Up @@ -55,6 +58,10 @@ Are listed in this sections all options available to configure `poetry-pyinstall

```toml
[tool.poetry-pyinstaller-plugin]
# Pyinstaller version (Optional, latest if not set)
# Does not support version constraint (eg: ^6.4)
version = "6.7.0"

# Disable UPX compression
disable-upx = true

Expand Down
25 changes: 23 additions & 2 deletions poetry_pyinstaller_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ class PyInstallerPlugin(ApplicationPlugin):
def __init__(self):
self._targets = []

@property
def version_opt(self) -> Dict:
"""
Get pyinstaller version option
:return: Version string of pyinstaller plugin
"""
data = self._app.poetry.pyproject.data
if data:
return data.get("tool", {}).get("poetry-pyinstaller-plugin", {}).get("version", None)
raise RuntimeError("Error while retrieving pyproject.toml data.")

@property
def scripts_opt_block(self) -> Dict:
"""
Expand Down Expand Up @@ -315,13 +326,23 @@ def _build_binaries(self, event: ConsoleCommandEvent, event_name: str, dispatche
io.write_line("<fg=black;bg=yellow>Skipping PyInstaller build, requires virtualenv.</>")
return

io.write_line(f"<b>Preparing</b> PyInstaller environment <debug>{venv.path}</debug>")
pyinstaller_package = "pyinstaller" if self.version_opt is None else f"pyinstaller=={self.version_opt}"
venv_pip = venv.run_pip(
"install",
"--disable-pip-version-check",
"--force-reinstall",
"--no-input",
pyinstaller_package,
)
pyinstaller_version = venv.run("pyinstaller", "--version").strip()
io.write_line(f"<b>Preparing</b> PyInstaller <b><c1>{pyinstaller_version}</b></c1> environment <debug>{venv.path}</debug>")

venv_pip = venv.run_pip(
"install",
"--disable-pip-version-check",
"--ignore-installed",
"--no-input",
"pyinstaller", "certifi", "cffi",
"certifi", "cffi",
)

for requirement in self._app.poetry.package.requires:
Expand Down

0 comments on commit e1f8ae8

Please sign in to comment.