You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix CedRawIO with sonpy >= 1.9.12 and re-enable the CED tests (#1891)
* Fix CedRawIO with sonpy >= 1.9.12
sonpy 1.9.12 dropped the 'lib' namespace that cedrawio.py used, so every
sonpy.lib.* access raised AttributeError. Resolve the namespace once,
probing sonpy.lib, sonpy and sonpy.sonpy in turn: the last is needed on
Linux, where the 1.9.12 wheel ships an empty __init__.py.
Refs #1890
Co-authored-by: Cursor <cursoragent@cursor.com>
* Use a single sonpy availability check in both CED tests
test_cedio.py replicated the old per-platform sonpy dispatch and skipped
with 1.9.12; test_cedrawio.py guarded on a bare 'import sonpy', which
succeeds with 1.9.12 so the test would run and fail. Both now delegate to
_get_sonpy_namespace().
Refs #1890
Co-authored-by: Cursor <cursoragent@cursor.com>
* Install sonpy in CI where usable wheels exist
The test extra declared sonpy;python_version<'3.10' while the project
requires >=3.10, so sonpy was never installed and the CED tests never ran.
Target the platform/version combinations sonpy actually publishes wheels
for; the sdist ships a Windows .pyd and is not usable elsewhere.
Refs #1890
Co-authored-by: Cursor <cursoragent@cursor.com>
* Resolve the sonpy submodule with find_spec instead of try/except
Per review: find_spec verifies sonpy.sonpy without importing it, so the
try/except goes away. Two guards are needed for that to hold: importlib.util
must be imported explicitly, and find_spec raises ModuleNotFoundError if
sonpy is not a package, so check __path__ first. Probing after the first two
candidates also means the submodule is only imported on Linux >= 1.9.12.
Refs #1890
Co-authored-by: Cursor <cursoragent@cursor.com>
* Document the sonpy platform constraint in the CedRawIO docstring
sonpy only ships wheels for Windows, and for Linux and macOS from 3.14 on,
so neo[ced] silently resolves to nothing elsewhere. Say so, and point users
at Spike2RawIO for .smr files, which needs no sonpy.
Refs #1890
Co-authored-by: Cursor <cursoragent@cursor.com>
* Handle sonpy.lib as an attribute, not a submodule
find_spec() cannot see sonpy.lib in <=1.9.5: __init__.py binds the
extension module via 'import sonpy.<platform>.sonpy as lib', so there is
no sonpy/lib.py for find_spec to find. Use getattr for that candidate and
keep find_spec for the top-level guard and for the nested sonpy.sonpy of
the 1.9.12 Linux wheel.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Drop @cache from _get_sonpy_namespace
After the first call find_spec() and import_module() are sys.modules
lookups, so the decorator saves ~1.2us on a path the import system
already caches. It cannot help the one path with real cost either:
functools.cache does not memoize exceptions, so find_spec()'s full
sys.path scan on a missing sonpy re-runs on every call regardless.
It also forces cache_clear() into any test of this function.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
0 commit comments