Numba cant run on both windows and macos. How so solve

I work on a Macbook with Apple silicon, but most of my colleagues work on windows. If I run numba I get a type error for int32. This can be resolved by changing them to int64, but then my colleagues get an Type error for that.

What can I do so we can both work on the same code base?

@njit(types.int32[:, :], # needs to be int64 in macos
        types.int32[:], # needs to be int64 in macos
        types.float64[:, :],
        types.int64[:, :],
        types.int32[:], # needs to be int64 in macos
)
def stuff_for_numba(D, Nxd, X3_np, ind0_np, maxInd1): 
      pass

Solved it by just inferring dynamically in @njit decorator (ie removing explicit types) and adding explicit types in function.

@njit
def stuff_numba(D, Nxd, X3_np, ind0_np, maxInd1):
    # Explicitly cast the inferred int32 arrays to int64
    D = D.astype(np.int64)
    Nxd = Nxd.astype(np.int64)
    ind0_np = ind0_np.astype(np.int64)
    maxInd1 = maxInd1.astype(np.int64)

Hey @hvdveer ,

Great that you were able to solve the issue.
Would it be possible to use a global variable int_type within the function signatures, too?
Another option could be to provide a list of signatures to cover both systems.
What do you think?

import sys
import numpy as np
from numba import njit, types, typeof

# Determine the architecture for type compatibility
if sys.maxsize > np.iinfo(np.int32).max:  # 64-bit system
    int_type = types.int64
else:  # 32-bit system
    int_type = types.int32

# or let numba infer the type
int_type = typeof(1)
1 Like

Ah pretty nice solution. Thanks!

But obviously the current solution works better.
Very strange that it was an issue in the first place, obviously those intel machines also have an 64bit architecture.