Repository navigation
Fix Cython @implementation include_dirs being overwritten - #1923
Conversation
Merge compiler_kwds include_dirs with prefs before building extensions, and add a regression test using an external header in a temporary directory. Fixes brian-team#1922
antonsoo
left a comment
There was a problem hiding this comment.
Tested c77a4af0 against a88d9f15 on Linux, Python 3.13.9, NumPy 2.5.4 and Cython 3.3.0, with each tree's native extensions built separately. The added external-header test passes.
A constructed 64-neuron Cython LIF network using @implementation(..., include_dirs=[...]) cannot compile its current function on the base because the header is not found. Here it produces all 101 expected spikes and an exact match to an independent discrete voltage recurrence. Both runtime and string-expression targets were Cython.
Changing header directories within one process still reuses the first binary: a second configuration produces 101 spikes instead of 156. This is the separate cache bug covered by #1925, not introduced here. A private composition of both PRs, plus the include-list copy described in my #1925 review, gives the expected 101/156/101 spikes and exact traces when switching A -> B -> A. Scope is these Linux header/current configurations; no other-platform or full-model claim.
mstimberg
left a comment
There was a problem hiding this comment.
Huh, that's a silly bug, thanks for the fix! Apparently it has been around for eight years…
Summary
CythonCodeObject.__init__that overwroteself.include_dirsafter merging@implementation(..., include_dirs=...)withprefs['codegen.cpp.include_dirs'].test_external_function_cython_include_dirs, mirroring the existing C++ standalone include_dirs test: compile an external header from a temporary directory via Cythoncdef extern.Fixes #1922
Test plan
prefs.codegen.target = 'cython'and runtest_external_function_cython_include_dirslocally