I have some code, generic numba. I'm attempting to compile it with setuptools, which I've done successfully before on this computer, in this environment, but lost my setup.py file. Code to compile immediately below. Setup.py below that.
Running python setupnumba.py build_ext --inplace throws no errors, and creates a pyd file, but it doesn't appear as if it's actually compiling the code. When I import the code it appears to be treating it as a regular python file with a JIT encoder, and it's running it. if I protect some code inside 'File to compile' with if name='main', it will run that code on import. In the print monitor, on import, it prints temp.c temp.cxx
No idea what's going on. What I had to do was rebuild the setup.py from scratch, and I did it based on numba's documentation, so I think there's an issue there.
File to compile
from numba.pycc import CC
import numpy as np
cc = CC('nufit1d')
@cc.export('jacg1dsup', 'f8[:,:](f8[:],f8,f8,f8,f8)')
def jacg1dsup(x, aa, bb, cc, dd):
xx = x[0:-1]
size = xx.size
j = np.empty((size, 4))
j[:, 0] = np.ones(size)
j[:, 1] = np.exp(-2 * (xx - cc) ** 2 / (np.abs(dd) + 0.5) ** 2)
j[:, 2] = 4 * bb * (xx - cc) / (np.abs(dd) + 0.5) ** 2 * np.exp(-2 * (xx - cc) ** 2 / (np.abs(dd) + 0.5) ** 2)
j[:, 3] = bb * (4 * (xx - cc) ** 2 / (np.abs(dd) + 0.5) ** 3) * np.exp(-2 * (xx - cc) ** 2 / (np.abs(dd) + 0.5) ** 2)
return j
The setup.py file
from setuptools import setup, Extension
from numba.pycc import CC
setup(
name='nufit1d',
ext_modules=[Extension('nufit1d', sources=['nfit1d.py'])],
)
Only current answer: don't try it with setuptools if you're trying to build an independent .[whatevs] from numba code. Use cc.compile() at the end of your code, run it, and do whatever is necessary to make sure it talks to your c compiler correctly. On windows, Vis Studio works, run 'python yourfile.py' from the appropriate visual studio Native Tools Command Prompt. Getting cython to work from setuptools with your compiler doesn't automatically make numba work with it.