Wander into any physiotherapy department and mention piriformis stretches and you will provoke a debate about the best way to do it. The problem is the action of piriformis - it does different things depending on the position of the hip.
Some of my colleagues use a different stretch but this is the one I particularly like. I have found this to be a very successful stretch for many of my patients with this problem.
This video shows the foot being turned inwards, If it doesn't work it is worth trying a variation on it by turning the foot outwards.
If the muscle is sore you could try warming it first with heat therapy. Make sure you don't cause a burn though, properly wrap up whatever you are using for warmth and don't lie or sit on the heat source pressing it against your skin.