#!/bin/bash

# Download code from github
cd /tmp
rm -rf numpy
git clone https://github.com/numpy/numpy.git -b v1.19.1

# Patch
# issue: https://github.com/numpy/numpy/issues/13622

sed -i 's#MOV V8.4s, V9.4s#MOV V8.16b, V9.16b#g' numpy/core/src/npymath/npy_math_internal.h.src
sed -i 's#MOV v10.4s, v11.4s#MOV v10.16b, v11.16b#g' 8x8-dq-aarch64-neon.S

-NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
+NPY_INPLACE __attribute__((optimize("-O0"))) @type@ npy_@kind@@c@(@type@ x, @type@ y)


# Install numpy
cd /tmp/numpy
python setup.py install

# Package
python setup.py bdist_wheel
