Detection of python module argparse_color_formatter
Hi (specially @keckj ),
I' try to write a guix recipe to compile hysop and I have a problem to detect the module argparse_color_formatter
like in the following output
-- Found networkx: /gnu/store/r2lk125g2pdvbmrlw3dqjhl7sw8sgn1k-python-networkx-2.8.6/lib/python3.9/site-packages/networkx
-- Found pyfftw: /gnu/store/k7mk6r1vi41q21ng3hvjac9pq1hjv1wj-python-pyfftw-0.13.1/lib/python3.9/site-packages/pyfftw
-- Found zarr: /gnu/store/0plbag2cklv3szqprn6sj7xrxqffygk0-python-zarr-2.13.3/lib/python3.9/site-packages/zarr
-- Found numcodecs: /gnu/store/vx015q5yammzhbr9ypc67p5b4qa14xci-python-numcodecs-0.10.2/lib/python3.9/site-packages/numcodecs
-- Found jsonpickle: /gnu/store/5wjlnasgm7s4bzny3m8qgziikqchzsvs-python-jsonpickle-1.5.2/lib/python3.9/site-packages/jsonpickle
CMake Error at /gnu/store/j65q3aw414010gdfvmsynwpzfb2jyyd3-cmake-minimal-3.21.4/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find argparse_color_formatter (missing:
_argparse_color_formatter_location)
Call Stack (most recent call first):
/gnu/store/j65q3aw414010gdfvmsynwpzfb2jyyd3-cmake-minimal-3.21.4/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
cmake/FindPythonModule.cmake:32 (find_package_handle_standard_args)
CMakeLists.txt:153 (find_python_module)
After some investigation, I found a particularity for that module. The differents versions I have installed do not have a __init__.py
So when I look at the following cmake code
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"import re, ${module}; print(re.compile(r'/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
for two following examples :
bash-5.1$ python3 -c 'import re, networkx; print(re.compile(r"/__init__.py.*").sub("",networkx.__file__))'
/gnu/store/lbb42czj0kg5za1mm7wj5269xsimw9bb-profile/lib/python3.9/site-packages/networkx
bash-5.1$ python3 -c 'import re, argparse_color_formatter; print(re.compile(r"/__init__.py.*").sub("",argparse_color_formatter.__file__))'
/gnu/store/lbb42czj0kg5za1mm7wj5269xsimw9bb-profile/lib/python3.9/site-packages/argparse_color_formatter.py
I found that the execute_process can not furnish the string '/gnu/store/lbb42czj0kg5za1mm7wj5269xsimw9bb-profile/lib/python3.9/site-packages/argparse_color_formatter' such as in the first case.
Is the find_python_module
cmake function works for you for the argparse_color_formatter
package. If it is the case, may be I do not use the right version of that package. If no, could we generalize the function to take into account also that case.
Bests,
marc