poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Scripts defined in `[project.gui-scripts]` are not made available by `poetry install`

Open boimart1 opened this issue 7 months ago • 2 comments

Description

https://python-poetry.org/docs/pyproject/#gui-scripts

When a script is added or updated, run poetry install to make them available in the project’s virtualenv.

However, on Windows, any GUI scripts defined here are not actually made available in the <venv>\Scripts folder. So defining a gui-script named "mygui", running poetry install, and then running mygui from the active venv or poetry run mygui fails with the following output:

'mygui' is not recognized as an internal or external command,
operable program or batch file.

This only affects the virtual env, as GUI scripts defined here are properly included in the built wheel's entry_points.txt when running poetry build.

Here is a very simple GUI script to go along with the pyproject.toml further down:

from PySide6 import QtWidgets

def main():
    app = QtWidgets.QApplication([])
    main_window = QtWidgets.QMainWindow()
    main_window.show()
    return app.exec()

if __name__ == "__main__":
    import sys
    sys.exit(main())

Workarounds

Moving the script definition(s) to either of [project.scripts] or [tool.poetry.scripts] makes the scripts available. However, in doing this, they are no longer GUI scripts.

Poetry Installation Method

pipx

Operating System

Windows 11

Poetry Version

2.1.3

Poetry Configuration

cache-dir = "C:\\Users\\martin.boisvert\\AppData\\Local\\pypoetry\\Cache"
data-dir = "C:\\Users\\martin.boisvert\\AppData\\Roaming\\pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}\\python"  # C:\Users\martin.boisvert\AppData\Roaming\pypoetry\python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Platform: "win-amd64"
Python version: "3.13"
Current installation scheme: "venv"

Paths: 
      data = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13"
      include = "C:\Python313\Include"
      platinclude = "C:\Python313\Include"
      platlib = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Lib\site-packages"
      platstdlib = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Lib"
      purelib = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Lib\site-packages"
      scripts = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Scripts"   
      stdlib = "C:\Python313\Lib"

Variables:
      BINDIR = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Scripts"    
      BINLIBDEST = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13\Lib"    
      EXE = ".exe"
      EXT_SUFFIX = ".cp313-win_amd64.pyd"
      INCLUDEPY = "C:\Python313\Include"
      LDLIBRARY = "python313.dll"
      LIBDEST = "C:\Python313\Lib"
      LIBDIR = "C:\Python313\libs"
      LIBRARY = "python313.dll"
      Py_GIL_DISABLED = "0"
      SOABI = "cp313-win_amd64"
      TZPATH = ""
      VERSION = "313"
      VPATH = "..\.."
      abi_thread = ""
      abiflags = ""
      base = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13"
      exec_prefix = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13"       
      implementation = "Python"
      implementation_lower = "python"
      installed_base = "C:\Python313"
      installed_platbase = "C:\Python313"
      platbase = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13"
      platlibdir = "DLLs"
      prefix = "C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13"
      projectbase = "C:\Python313"
      py_version = "3.13.3"
      py_version_nodot = "313"
      py_version_nodot_plat = "313"
      py_version_short = "3.13"
      srcdir = "C:\Python313"
      userbase = "C:\Users\martin.boisvert\AppData\Roaming\Python"

Example pyproject.toml

[project]
name = "poetry-gui-scripts"
version = "0.1.0"
description = ""
requires-python = ">=3.10,<3.14"
dependencies = ["PySide6~=6.9.0"]


[project.gui-scripts]
mygui = "poetry_gui_scripts.__main__:main"


[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

poetry-runtime.log
C:\Work\Demos\poetry-gui-scripts
λ poetry -vvv run mygui
Loading configuration file C:\Users\martin.boisvert\AppData\Roaming\pypoetry\config.toml
Loading configuration file C:\Users\martin.boisvert\AppData\Roaming\pypoetry\auth.toml
[findpython:findpython] Running script: ['C:\\Python313\\python.EXE', '-EsSc', 'import sys; print(sys.executable)']
Found: C:\Python313\python.EXE
[findpython:findpython] Running script: ['C:\\Python313\\python.EXE', '-EsSc', 'import platform; print(platform.python_version())']
Using virtualenv: C:\Users\martin.boisvert\AppData\Local\pypoetry\Cache\virtualenvs\poetry-gui-scripts-GiBywCFm-py3.13
'mygui' is not recognized as an internal or external command,
operable program or batch file.

boimart1 avatar Jul 30 '25 21:07 boimart1

Potentially related to #9549.

boimart1 avatar Jul 30 '25 21:07 boimart1

I'm seeing the same issue on Linux.

Sorry about the noise. I've now seen from the docs "The difference between [project.scripts] and [project.gui-scripts] is only relevant on Windows". So on Linux I can just use [project.scripts] instead.

SteveDaulton avatar Oct 23 '25 11:10 SteveDaulton