cmake-python-distributions icon indicating copy to clipboard operation
cmake-python-distributions copied to clipboard

fix: more readable error on missing `ccmake`

Open Andrej730 opened this issue 2 months ago • 4 comments

I've stumbled upon the error below, trying to use ccmake. Adding a bit more readable error for this case.

uv tool install cmake
# Installed 4 executables: ccmake, cmake, cpack, ctest
ccmake --version 
# Traceback (most recent call last):
#   File "<frozen runpy>", line 198, in _run_module_as_main
#   File "<frozen runpy>", line 88, in _run_code
#   File "C:\Users\Andrej\.local\bin\ccmake.exe\__main__.py", line 10, in <module>
#     sys.exit(ccmake())
#              ~~~~~~^^
#   File "L:\UV_TOOL_DIR\cmake\Lib\site-packages\cmake\__init__.py", line 53, in ccmake
#     _program_exit('ccmake', *sys.argv[1:])
#     ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
#   File "L:\UV_TOOL_DIR\cmake\Lib\site-packages\cmake\__init__.py", line 47, in _program_exit
#     raise SystemExit(_program(name, args))
#                      ~~~~~~~~^^^^^^^^^^^^
#   File "L:\UV_TOOL_DIR\cmake\Lib\site-packages\cmake\__init__.py", line 43, in _program
#     return subprocess.call([os.path.join(CMAKE_BIN_DIR, name), *args], close_fds=False)
#            ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#   File "L:\UV_PYTHON_INSTALL_DIR\cpython-3.14.0-windows-x86_64-none\Lib\subprocess.py", line 395, in call
#     with Popen(*popenargs, **kwargs) as p:
#          ~~~~~^^^^^^^^^^^^^^^^^^^^^^
#   File "L:\UV_PYTHON_INSTALL_DIR\cpython-3.14.0-windows-x86_64-none\Lib\subprocess.py", line 1038, in __init__
#     self._execute_child(args, executable, preexec_fn, close_fds,
#     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#                         pass_fds, cwd, env,
#                         ^^^^^^^^^^^^^^^^^^^
#     ...<5 lines>...
#                         gid, gids, uid, umask,
#                         ^^^^^^^^^^^^^^^^^^^^^^
#                         start_new_session, process_group)
#                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#   File "L:\UV_PYTHON_INSTALL_DIR\cpython-3.14.0-windows-x86_64-none\Lib\subprocess.py", line 1552, in _execute_child
#     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
#                        ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
#                              # no special security
#                              ^^^^^^^^^^^^^^^^^^^^^
#     ...<4 lines>...
#                              cwd,
#                              ^^^^
#                              startupinfo)
#                              ^^^^^^^^^^^^
# FileNotFoundError: [WinError 2] The system cannot find the file specified

Andrej730 avatar Dec 11 '25 15:12 Andrej730

If you ran cmake --version, why is it looking for ccmake? Also, according to the line above, it did install ccmake. (No issue with better error messages, but might be something fixable?)

henryiii avatar Dec 11 '25 16:12 henryiii

If you ran cmake --version, why is it looking for ccmake?

cmake --version was a mistake when typing example above, I meant ccmake --version, fixed.

Also, according to the line above, it did install ccmake. (No issue with better error messages, but might be something fixable?)

It did installed ccmake meaning ccmake.exe script as in project.scripts:

https://github.com/scikit-build/cmake-python-distributions/blob/40acf75985b28bd112b28ddc4506f5e0283cbd45/pyproject.toml#L38-L42

But the way this script works, it imports cmake module and executes corresponding ccmake method below:

https://github.com/scikit-build/cmake-python-distributions/blob/ecad19912918f6975d32491a60812ce78eb9e33e/src/cmake/init.py#L52-L55

And ccmake.exe is not included in the package (at least on Windows) as probably part of https://github.com/scikit-build/cmake-python-distributions/issues/66 and also there are issues upstream (https://gitlab.kitware.com/cmake/cmake/-/issues/18053).

image

Andrej730 avatar Dec 11 '25 18:12 Andrej730

Ahh, excellent, thank you. We could make the entry points dynamic, but that would be nicer if PEP 808 is accepted. I had missed it isn't in the official distribution, which we use.

henryiii avatar Dec 11 '25 19:12 henryiii

Removing/adding entry point dynamically would be more proper solution, but I'm not familar with scikit build backend, so I'd rather keep this PR as just a clarified error message.

Andrej730 avatar Dec 12 '25 05:12 Andrej730