Determining NPY_ABI_VERSION statically in compiled extensions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Determining NPY_ABI_VERSION statically in compiled extensions

Robert McGibbon
Is anyone aware of any tricks that can be played with tools like `readelf`, `nm` or `dlopen` / `dlsym` in order to statically determine what version of numpy a fully-compiled C extension (for example, found inside a wheel) was compiled against? Even if it only worked with relatively new versions of numpy, that would be fine.

I'm interested in creating something similar to  https://github.com/pypa/auditwheel that could statically check for compatibility between wheel files and python installations, in situations where the metadata about how they were compiled is missing.
--
-Robert

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Determining NPY_ABI_VERSION statically in compiled extensions

mattip
On 08/10/18 23:31, Robert T. McGibbon wrote:

> Is anyone aware of any tricks that can be played with tools like
> `readelf`, `nm` or `dlopen` / `dlsym` in order to statically determine
> what version of numpy a fully-compiled C extension (for example, found
> inside a wheel) was compiled against? Even if it only worked with
> relatively new versions of numpy, that would be fine.
>
> I'm interested in creating something similar to
> https://github.com/pypa/auditwheel that could statically check for
> compatibility between wheel files and python installations, in
> situations where the metadata about how they were compiled is missing.
> --
> -Robert
>
NPY_ABI_VERSION is exposed in C as PyArray_GetNDArrayCVersion and
NPY_API_VERSION is exposed in C as PyArray_GetNDArrayCFeatureVersion.
These are not incremented for every NumPy release, see the documentation
in numpy/core/setup_common.py.

The numpy.__version__ is determined by a python file numpy/version.py,
which is probably what you want to use.

There is an open Issue to better reveal compile time info
https://github.com/numpy/numpy/issues/10983

Matti
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Determining NPY_ABI_VERSION statically in compiled extensions

Robert McGibbon
Matti,

That doesn't quite cover my use case. I'm interested in querying a .whl file containing .so files that were compiled against numpy (not my currently installed version of numpy) to determine the conditions under which those `.so` files were compiled.

-Robert

On Mon, Oct 8, 2018 at 5:26 PM Matti Picus <[hidden email]> wrote:
On 08/10/18 23:31, Robert T. McGibbon wrote:
> Is anyone aware of any tricks that can be played with tools like
> `readelf`, `nm` or `dlopen` / `dlsym` in order to statically determine
> what version of numpy a fully-compiled C extension (for example, found
> inside a wheel) was compiled against? Even if it only worked with
> relatively new versions of numpy, that would be fine.
>
> I'm interested in creating something similar to
> https://github.com/pypa/auditwheel that could statically check for
> compatibility between wheel files and python installations, in
> situations where the metadata about how they were compiled is missing.
> --
> -Robert
>
NPY_ABI_VERSION is exposed in C as PyArray_GetNDArrayCVersion and
NPY_API_VERSION is exposed in C as PyArray_GetNDArrayCFeatureVersion.
These are not incremented for every NumPy release, see the documentation
in numpy/core/setup_common.py.

The numpy.__version__ is determined by a python file numpy/version.py,
which is probably what you want to use.

There is an open Issue to better reveal compile time info
https://github.com/numpy/numpy/issues/10983

Matti
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion


--
-Robert

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion