--env working as intended?
I'm trying to cross compile Numpy with OpenBLAS. I've already cross compiles OpenBLAS and installed it into python_armhf/, i.e. headers are in python_armhf/include and binaries are in python_armhf/lib. I create the crossenv with
path/to/build-python -m crossenv \
--env=CPATH:=python_armhf/include \
--env=LIBRARY_PATH:=python_armhf/lib \
path/to/host-python env
However, when I'm in the crossenv neither of those environment variables are set, and env/cross/lib does not contain anything from python_armhf/lib. Consequently, the Numpy build fails due to missing OpenBLAS.
Am I misunderstanding how --env is supposed to work? How can I specify where to find cross compiled libraries in the crossenv?
It actually only sets the environment when Python runs, so you should see them set if you run something like:
$ cross-python -c 'import os; print(os.environ["CPATH"])'
For numpy specifically, they roll their own library/include finding code that doesn't account for CPATH or LIBRARY_PATH, (or at least I've never had much luck with them,) so I've had to specify paths when running setup.py, something like:
$ cross-python setup.py build_ext --library-dirs <libraries> \
--include-dirs <includes> bdist_wheel
~~Still, the behavior you expect is logical and useful enough that I think it warrants a fix.~~
(Edit: I remember now why I didn't do it that way: it would confuse build-python if they were set globally like you'd expect)
I tried with --include-dirs and --library-dirs, but Numpy does not seem to respect them. The only way I have been able to work around the issue is to symlink the libraries to env/cross/lib.
Creating a site.cfg in Numpy's base directory works:
[openblas]
libraries = openblas
library_dirs = path/to/dir/with/libopenblas.so
include_dirs = path/to/dir/with/headers
However, does build-python actually use env/cross/{include,lib} for anything? If not, why not allow the user to optionally symlink cross compiled libraries there when creating the crossenv?
env/cross/{include, lib} aren't used for anything, so it should be safe to symlink things there. Adding a symlink options isn't a bad idea, but first I think I want to figure out why numpy seems so hell-bent on using those directories by default.