PyCUDA on Mac OS X El Capitan

PyCUDA doesn’t seem to build on El Capitan:

ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here’s how I fixed it:

tar -xzvf pycuda-2015.1.3.tar.gz
cd pycuda-2015.1.3
python --cuda-root=/usr/local/cuda --ldflags="-F/Library/Frameworks -framework CUDA" --cxxflags="-arch x86_64"
sudo make install