0

I'm developing a python package that contains a C extension. I want to deploy a release for each operating system (linux, windows, macOS) using cibuildwheel. The C extension uses the arrayobject.h header (from numpy). In order to use this header locally I set the enviroment variable C_INCLUDE_PATH and I'm trying to do that in the builder action.

As I don't know "where" is that header in the cloud I find it using this command:

$(python -c 'import numpy, os; print(os.path.dirname(numpy.__file__))')/core/include/numpy

I've tried to set that enviroment variable using:

[tool.cibuildwheel]
environment = { C_INCLUDE_PATH="$(python -c 'import numpy, os; print(os.path.dirname(numpy.__file__))')/core/include/numpy" }

But it sais numpy is not installed, even when I've tried:

[tool.cibuildwheel]
before-build = [ "pip install numpy" ]

I'm aware that I should use the build-system.requires but that didn't work either.

It seems that enviroment variables are setted before all.

I know i can use the -I flag and set the CFLAG variable but I'm afraid this will end up in the same mistake (evaluating the variable before instaling numpy).

So, how can I include this path? Is a better way to do this that I'm missing?

Thanks.

Jorge Morgado
  • 1,148
  • 7
  • 23

1 Answers1

1

I got a solution from the cibuildwheel's discussion section and it worked for me (I'm using setuptools):

  • Set oldest-supported-numpy as a build requirement in the build-system.requires section in the pyproject.toml
  • Set the parameter include_dirs=[np.get_include()] for the Extension instance in the setup.py.

This way there is no need of setting any before-build command or any environment variable for the build pipline.

Jorge Morgado
  • 1,148
  • 7
  • 23