@@ -259,24 +259,33 @@ jobs:
259259 - name : Install minimal dependencies (no numpy, no scipy)
260260 run : |
261261 python -m pip install --upgrade pip
262- python -m pip install build pandas pytest tqdm
262+ python -m pip install build pytest tqdm
263263
264264 - name : Build and install package
265265 run : |
266266 python -m pip install build
267267 python -m build
268268 pip install dist/*.whl
269269
270- - name : Verify numpy is NOT installed
270+ - name : Uninstall numpy and pandas (test pure Python mode)
271+ run : |
272+ pip uninstall numpy pandas -y
273+
274+ - name : Verify numpy and pandas are NOT installed
271275 run : |
272276 python -c "
273277 import sys
274- try:
275- import numpy
276- print('ERROR: numpy is installed but should not be!')
278+ errors = []
279+ for mod in ('numpy', 'pandas'):
280+ try:
281+ __import__(mod)
282+ errors.append(f'{mod} is installed but should not be')
283+ except ImportError:
284+ print(f'OK: {mod} is not installed')
285+ if errors:
286+ for e in errors:
287+ print(f'ERROR: {e}')
277288 sys.exit(1)
278- except ImportError:
279- print('OK: numpy is not installed')
280289 "
281290
282291 - name : Verify array backend uses pure Python
@@ -292,13 +301,62 @@ jobs:
292301 run : |
293302 python -m pytest tests/test_dependencies/test_no_numpy.py -v --tb=short -p no:warnings
294303
304+ # ===========================================================================
305+ # STAGE 3d: C Extension Tests (no numpy, with compiled C backend)
306+ # ===========================================================================
307+ test-c-extension :
308+ name : Tests (C extension, no numpy)
309+ runs-on : ubuntu-latest
310+ needs : api-smoke-tests
311+ steps :
312+ - name : Checkout code
313+ uses : actions/checkout@v4
314+
315+ - name : Set up Python 3.11
316+ uses : actions/setup-python@v5
317+ with :
318+ python-version : " 3.11"
319+
320+ - name : Install build dependencies
321+ run : |
322+ python -m pip install --upgrade pip
323+ python -m pip install build pandas pytest tqdm setuptools
324+
325+ - name : Build and install package (with C extension)
326+ run : |
327+ python -m pip install build
328+ python -m build
329+ pip install dist/*.whl
330+
331+ - name : Uninstall numpy (keep C extension)
332+ run : |
333+ pip uninstall numpy -y || true
334+
335+ - name : Verify C extension is active
336+ run : |
337+ python -c "
338+ from gradient_free_optimizers._array_backend import _backend_name, HAS_NUMPY, HAS_C_EXTENSION
339+ assert not HAS_NUMPY, 'numpy should not be installed'
340+ assert HAS_C_EXTENSION, 'C extension should be available'
341+ assert _backend_name == 'c_extension', f'Expected c_extension backend, got {_backend_name}'
342+ print('OK: using C extension array backend')
343+ "
344+
345+ - name : Run C extension unit tests
346+ run : |
347+ python -m pytest tests/test_internal/test_array_backend/test_c_extension.py -v --tb=short -p no:warnings
348+
349+ - name : Run dependency isolation tests
350+ run : |
351+ python -m pytest tests/test_dependencies/test_no_numpy.py -v --tb=short -p no:warnings
352+
295353 # ===========================================================================
296354 # STAGE 4: Coverage Report (only on Ubuntu with full dependencies)
297355 # ===========================================================================
298356 coverage :
299357 name : Coverage Report
300358 runs-on : ubuntu-latest
301- needs : [test-matrix, test-no-scipy, test-no-numpy]
359+ needs : [test-matrix, test-no-scipy, test-no-numpy, test-c-extension ]
302360 steps :
303361 - name : Checkout code
304362 uses : actions/checkout@v4
0 commit comments