david-cortes / isotree

(Python, R, C/C++) Isolation Forest and variations such as SCiForest and EIF, with some additions (outlier detection + similarity + NA imputation)
https://isotree.readthedocs.io
BSD 2-Clause "Simplified" License
186 stars 38 forks source link

Decrease required NumPy version from 1.25 to 1.24 #58

Closed kamilc closed 6 months ago

kamilc commented 6 months ago

This PR decreases the required NumPy version from 1.25 to 1.24. The library works just fine on 1.24. The problem with 1.25 is that it dropped support for Python 3.8 and there are still live systems running on that version that can benefit from integrating isotree.

david-cortes commented 6 months ago

Thanks for the suggestion, but there is a reason why the requirement is there: NumPy 1.25 introduced backwards compatibility in their C API.

This package has a cython extension which indirectly uses the numpy C API. If the numpy version is lowered, it can end up with cases in which the package is compiled against a certain version of numpy, but then if at runtime you have a different version, it will fail to import due to C struct changes for example. That is quite likely to happen when packages have build dependencies and use a build environment in addition to having runtime dependencies, which is the case here.

Previously, this package was using oldest-supported-numpy as a workaround, but that package is now deprecated with the recent compatibility changes in numpy, and reverting towards it would cause breakages once there is a numpy2.0 release.

In theory you could lower the version in requirements.txt without issue (but not the one in pyproject.toml), but it still requires the newer numpy at build time, so it would not allow you to run it in older python versions.

If for some reason you need to run an older python version, you could perhaps try older versions of isotree with custom pip options to disable build environments.