Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken build-system for copying Python files. #1503

Open
1uc opened this issue Oct 7, 2024 · 0 comments
Open

Broken build-system for copying Python files. #1503

1uc opened this issue Oct 7, 2024 · 0 comments

Comments

@1uc
Copy link
Collaborator

1uc commented Oct 7, 2024

We use:

file(
  GLOB NMODL_PYTHON_FILES
  RELATIVE "${NMODL_PROJECT_SOURCE_DIR}/python/nmodl/"
  CONFIGURE_DEPENDS "${NMODL_PROJECT_SOURCE_DIR}/python/nmodl/*.py")

foreach(file IN LISTS NMODL_PYTHON_FILES)
  cpp_cc_build_time_copy(INPUT ${NMODL_PROJECT_SOURCE_DIR}/python/nmodl/${file} OUTPUT
                         ${CMAKE_BINARY_DIR}/lib/nmodl/${file})
  list(APPEND nmodl_python_binary_dir_files "${CMAKE_BINARY_DIR}/lib/nmodl/${file}")
endforeach()

with

function(cpp_cc_build_time_copy)
  cmake_parse_arguments(opt "NO_TARGET" "INPUT;OUTPUT" "" ${ARGN})
  add_custom_command(
    OUTPUT "${opt_OUTPUT}"
    DEPENDS "${opt_INPUT}"
    COMMAND ${CMAKE_COMMAND} -E copy "${opt_INPUT}" "${opt_OUTPUT}")
  if(NOT opt_NO_TARGET)
    string(SHA256 target_name "${opt_INPUT};${opt_OUTPUT}")
    set(target_name "build-time-copy-${target_name}")
    if(NOT TARGET "${target_name}")
      add_custom_target(${target_name} ALL DEPENDS "${opt_OUTPUT}")
    endif()
  endif()

to copy the Python files into a subdirectory of lib. Unfortunately, it now occasionally happens that the copying fails when building in parallel:

[  1%] Generating ../../lib/nmodl/ode.py
...
[  2%] Generating ../../lib/nmodl/ode.py
...
Error copying file "/home/lucg/git/bbp/nmodl/python/nmodl/ode.py" to "/home/lucg/git/bbp/nmodl/build-debug/lib/nmodl/ode.py".

Note that lib/nmodl/ode.py is generated twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant