Give python users clear instructions about how to install cmake

This commit is contained in:
Davis King 2024-08-09 15:13:57 -04:00
parent 3ca155da68
commit aba96b576a
1 changed files with 40 additions and 3 deletions

View File

@ -115,7 +115,45 @@ class CMakeBuild(build_ext):
try: try:
out = subprocess.check_output(['cmake', '--version']) out = subprocess.check_output(['cmake', '--version'])
except: except:
sys.stderr.write("\nERROR: CMake must be installed to build dlib\n\n") sys.stderr.write("""
================================================================================
================================================================================
================================================================================
CMake is not installed on your system!
Or it is possible some broken copy of cmake is installed on your system.
It is unfortunately very common for python package managers to include
broken copies of cmake. So if the error above this refers to some file
path to a cmake file inside a python or anaconda or miniconda path then you
should delete that broken copy of cmake from your computer.
Instead, please get an official copy of cmake from one of these known good
sources of an official cmake:
- cmake.org (this is how windows users should get cmake)
- apt install cmake (for Ubuntu or Debian based systems)
- yum install cmake (for Redhat or CenOS based systems)
On a linux machine you can run `which cmake` to see what cmake you are
actually using. If it tells you it's some cmake from any kind of python
packager delete it and install an official cmake.
More generally, cmake is not installed if when you open a terminal window
and type
cmake --version
you get an error. So you can use that as a very basic test to see if you
have cmake installed. That is, if cmake --version doesn't run from the
same terminal window from which you are reading this error message, then
you have not installed cmake. Windows users should take note that they
need to tell the cmake installer to add cmake to their PATH. Since you
can't run commands that are not in your PATH. This is how the PATH works
on Linux as well, but failing to add cmake to the PATH is a particularly
common problem on windows and rarely a problem on Linux.
================================================================================
================================================================================
================================================================================
""")
sys.exit(1) sys.exit(1)
return re.search(r'version\s*([\d.]+)', out.decode()).group(1) return re.search(r'version\s*([\d.]+)', out.decode()).group(1)
@ -199,8 +237,7 @@ def read_version_from_cmakelists(cmake_file):
return major + '.' + minor + '.' + patch return major + '.' + minor + '.' + patch
def read_entire_file(fname): def read_entire_file(fname):
"""Read text out of a file relative to setup.py. """Read text out of a file relative to setup.py. """
"""
return open(os.path.join(fname)).read() return open(os.path.join(fname)).read()
setup( setup(