This is all extremely hacky so you'll probably need to play around with it to get it working. On a fresh Raspbian Jessie or Raspbian Stretch install, add all the build-deps we usually have on a piwheels build slave (see https://github.com/bennuttall/piwheels/blob/master/deploy_slave.sh and install all the -dev stuff and python libs, basically). Next, add a 1Gb swap file.
In the default "pi" user, make a "packaging" directory and stuff opencv-python-build
and
opencv-setup.py
under there. Make opencv-python-build
executable and edit the for-loops