Skip to content

Commit

Permalink
amended more debug-info, and reverted some environ handling
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Aug 14, 2024
1 parent 2157c89 commit 7bcd2ba
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
# We will use cmake_path for file-name manipulation

list(APPEND CMAKE_MESSAGE_CONTEXT "sisl")
Expand Down
7 changes: 7 additions & 0 deletions src/sisl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ endforeach()
# We do the configure step here
# We do not have the configure file in the current directory
# Otherwise it would be installed together with it
# Also get the compile definitions
get_directory_property( SISL_DEFINITIONS DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
COMPILE_DEFINITIONS )
# Join to stringify list
list(JOIN SISL_DEFINITIONS " " SISL_DEFINITIONS)

configure_file(
${PROJECT_SOURCE_DIR}/tools/_debug_info.py.conf
${CMAKE_CURRENT_SOURCE_DIR}/_debug_info.py
Expand Down
5 changes: 3 additions & 2 deletions src/sisl/_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def register_environ_variable(
"""
if not name.startswith("SISL_"):
raise ValueError("register_environ_variable: name should start with 'SISL_'")

if process is None:

def process(arg):
Expand Down Expand Up @@ -140,7 +141,7 @@ def _float_or_int(value: Union[str, float, int]):

register_environ_variable(
"SISL_TMP",
_abs_path(".sisl_tmp"),
".sisl_tmp",
"Path where temporary files should be stored",
process=_abs_path,
)
Expand All @@ -154,7 +155,7 @@ def _float_or_int(value: Union[str, float, int]):

register_environ_variable(
"SISL_FILES_TESTS",
_abs_path("_THIS_DIRECTORY_DOES_NOT_EXIST_"),
"_THIS_DIRECTORY_DOES_NOT_EXIST_",
dedent(
"""\
Full path of the sisl/files folder.
Expand Down
35 changes: 22 additions & 13 deletions tools/_debug_info.py.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ _fc = """@CMAKE_Fortran_COMPILER@"""
_fc_version = """@CMAKE_Fortran_COMPILER_VERSION@"""
_fflags = """@CMAKE_Fortran_FLAGS_RELEASE@"""

_definitions = [
("NPY_NO_DEPRECATED_API", """@NPY_NO_DEPRECATED_API@"""),
("CYTHON_NO_PYINIT_EXPORT", """@CYTHON_NO_PYINIT_EXPORT@"""),
("CYTHON_TRACE_NOGIL", """@CYTHON_TRACE_NOGIL@"""),
("F2PY_REPORT_ATEXIT", """@F2PY_REPORT_ATEXIT@"""),
("F2PY_REPORT_ON_ARRAY_COPY", """@F2PY_REPORT_ON_ARRAY_COPY@"""),
]
_definitions = """@SISL_DEFINITIONS@"""

_cmake_args = [
("CMAKE_BUILD_TYPE", """@CMAKE_BUILD_TYPE@"""),
("WITH_FORTRAN", """@WITH_FORTRAN@"""),
("F2PY_REPORT_ON_ARRAY_COPY", """@F2PY_REPORT_ON_ARRAY_COPY@"""),
("WITH_F2PY_REPORT_COPY", """@WITH_F2PY_REPORT_COPY@"""),
("WITH_F2PY_REPORT_EXIT", """@WITH_F2PY_REPORT_EXIT@"""),
("WITH_COVERAGE", """@WITH_COVERAGE@"""),
("WITH_LINE_DIRECTIVES", """@WITH_LINE_DIRECTIVES@"""),
("WITH_ANNOTATE", """@WITH_ANNOTATE@"""),
Expand Down Expand Up @@ -77,14 +74,26 @@ def print_debug_info():
print(fmt.format("FC version", _fc_version))
print(fmt.format("cython build version", _cython_build_version))
print(fmt.format("numpy build version", _numpy_build_version))
# print("[definitions]")
# for d, v in _definitions:
# print(fmt.format(d, v))
print("[cmake_args]")

print("[sisl.definitions]")
for df in _definitions.split():
try:
name, value = df.split("=", 1)
print(fmt.format(name, value))
except ValueError:
print(fmt.format(df, ""))

print("[sisl.cmake_args]")
for d, v in _cmake_args:
print(fmt.format(d, v))

print("[runtime modules]")
print("[sisl.env]")
from sisl._environ import SISL_ENVIRON, get_environ_variable

for envvar in SISL_ENVIRON:
print(fmt.format(envvar, get_environ_variable(envvar)))

print("[runtime]")

pip_install = []
conda_install = []
Expand All @@ -107,6 +116,6 @@ def print_debug_info():
pip_install.append(f"{pip}=={attr}")
conda_install.append(f"{conda}=={attr}")

print("[env]")
print("[install]")
print(fmt.format("pip", " ".join(pip_install)))
print(fmt.format("conda", " ".join(conda_install)))

0 comments on commit 7bcd2ba

Please sign in to comment.