Why did South Africa have nuclear weapons?

by calebmateo99

So I learned recently that South Africa is the only nation to have voluntarily dismantled all its nuclear weapons. But why did it have nukes in the first place? All the other nuclear powers have them as a deterrent in some sort of arms race or Cold War (US/Russia, India/Pakistan, Israel/pretty much the entire Middle East). But what threat compelled South Africa to want to build nuclear weapons?

QuickSpore

/u/The_Alaskan provided a good answer in this thread last year.

I doubt that's all that could be said on the matter, but you may find it illuminating.

CheetoBenitoBurrito

Follow up question: I've heard that nuclear weapons were seen as a sort of insurance policy by the Apartheid regime. Is there any truth to this? Also, how could have SA developed this type of weapons back then?