Skip to content

Commit b6a1dcf

Browse files
committed
Fix empty neuron.__version__ when git describe fails in shallow clones
Release dry-runs build wheels from a depth-1 checkout without creating the release tag. git describe then fails while .git still exists, so GIT_DESCRIBE stayed empty and neuron.__version__ (nrnversion(5)) was "", breaking ModelDB CI workdir creation. Fall back to PROJECT_VERSION and assert non-empty __version__ in wheel tests.
1 parent 7ca2dbb commit b6a1dcf

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

cmake/MacroHelper.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,21 @@ endfunction()
256256
function(add_cpp_git_information target scope)
257257
find_program(GIT git)
258258
if(EXISTS "${PROJECT_SOURCE_DIR}/.git" AND GIT)
259+
# Shallow clones: tags may not be ancestors of HEAD, so describe fails and
260+
# GIT_DESCRIBE would stay empty (neuron.__version__ / nrnversion(5)). Fall
261+
# back to PROJECT_VERSION so release dry-run and ship wheels match.
259262
execute_process(
260263
COMMAND "${GIT}" -C "${PROJECT_SOURCE_DIR}" describe
261264
OUTPUT_VARIABLE GIT_DESCRIBE
265+
RESULT_VARIABLE GIT_DESCRIBE_RESULT
262266
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
263267
268+
if(GIT_DESCRIBE_RESULT OR "${GIT_DESCRIBE}" STREQUAL "")
269+
set(GIT_DESCRIBE "${PROJECT_VERSION}")
270+
message(
271+
STATUS "git describe failed or empty; falling back to PROJECT_VERSION=${PROJECT_VERSION}")
272+
endif()
273+
264274
execute_process(
265275
COMMAND "${GIT}" -C "${PROJECT_SOURCE_DIR}" rev-parse --abbrev-ref HEAD
266276
OUTPUT_VARIABLE GIT_BRANCH

packaging/python/test_wheels.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ $python_exe -m uv pip install -r packaging/python/test_requirements.txt
256256
$python_exe -m uv pip install --force-reinstall $python_wheel
257257
$python_exe -m uv pip show neuron || $python_exe -m uv pip show neuron-nightly
258258

259+
# neuron.__version__ is nrnversion(5)/GIT_DESCRIBE; empty breaks ModelDB workdir naming
260+
$python_exe -c "import neuron; v = neuron.__version__; assert v and str(v).strip(), repr(v)"
259261

260262
# check the existence of coreneuron support
261263
compile_options="$(nrniv -nobanner -nogui -c 'nrnversion(6)')"

0 commit comments

Comments
 (0)