kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
228 stars 37 forks source link

Windows build fails on absurdly python bit-wise problem #133

Closed mzavadil closed 2 years ago

mzavadil commented 5 years ago

The cmake fails on this weird error:

CMake Error at cmake/modules/FindPythonLibsNew.cmake:122 (message):
  Python config failure: Python is 296-bit, chosen compiler is 64-bit

The problem is in unhandled parsing of _PYTHON_VALUES strings with backslash (a windows path typical). If, for example sys.prefix (like on my machine) ended with backslash, the following text is then escaped.

0: '3.7.2.final.0'
1: 'C:\Tools\Anaconda3\'
2: 'C:\Tools\Anaconda3\include'
3: 'C:\Tools\Anaconda3\Lib\site-packages'
4: '.cp37-win_amd64.pyd'
5: '0'
6: '8'
7: '37'
8: 'None'
9: ''

Line 1 and 2 was joined and on line 6 (= python bit-wise) jump value 37 (= python lib version) form line 7. Therefore, that curious value 296 of python bit-wise = 37 * 8.

I hotfixed cmake/modules/FindPythonLibsNew.cmake added extra replace:

string(REGEX REPLACE "\\\\" "/" _PYTHON_VALUES ${_PYTHON_VALUES})

before exists

 # Convert the process output into a list
 string(REGEX REPLACE "\\\\" "/" _PYTHON_VALUES ${_PYTHON_VALUES})
 string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES})
 string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES})
 list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST)
kpeeters commented 5 years ago

Ok, thanks for tracking that down, I have pushed this fix to master.

mzavadil commented 5 years ago

Thanks, the cmake of windows build is working.

summerdtao commented 5 years ago

Hi! I have the same problem when trying to use CMake to install dlib. I didn't find where to edit PYTHON_VALUES in the file. Can I have a look at your full edited file, please?

kpeeters commented 5 years ago

See https://github.com/kpeeters/cadabra2/blob/master/cmake/modules/FindPythonLibsNew.cmake .

summerdtao commented 5 years ago

Are you using Cmake version 3.15.3? There isn't a file FindPythonLibsNew.cmake but only FindPythonLibs on my computer, and the contents look a bit different.

kpeeters commented 5 years ago

I have no idea where we got this version from, it's shipped with Cadabra and we put it in place a long time ago, periodically updating. Actually, I believe we use the version that ships with pybind11.

The latest cmake I have used is 3.13.4 but that has little relevance to the origin of the FindPythonLibsNew.cmake file, as the latter does not ship with any of the cmake's I have used.

kpeeters commented 4 years ago

Is this still an issue?