click: Windows "Usage" incorrect display and difficulty to get a command name correct displayed

When you create a command with a setuptools console_scripts entry_points (for instance named mycli) the Usage displayed on POSIX (Linux, Mac,…) when running mycli --help will be: Usage: mycli

In contrast on Windows, I get the following: Usage: mycli-script.py

This is annoying because the correct invocation on windows is to use mycli, not mycli-script.py. The script is the same on all OSes, even though behind the scenes setuptools creates:

  • on posix, a bin/mycli python script with a correct shebang
  • on windows, a Scripts/mycli-script.py and Scripts/mycli.exe. This is called by invoking mycli like on POSIX

The obvious way to force this would be to use the name arg in click.command. (“This defaults to the function name.”). But it does not default to the function name and always show the mycli-script.py instead of mycli.

It looks like this comes from Context.info_name which is computed somehow, but I could not find a way to get this info_name forced to something fixed.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 25 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Fixed in latest version of setuptools (*_^)/

This should be fixed soon: pypa/setuptools/pull/736 pypa/pip/pull/3918