Mainspring clamps/vises are available from most of the blackpowder-specialist retailers. I have used a crescent wrench or small open-end wrench which fits snugly on the fully compressed spring for the purpose (on occasion, as I do have the proper clamps) by holding the hammer as far back as it will go (achieving maximum mainspring compression), then clamping the jaws of the wrench down snugly on the spring. You can also make a cramp by filing a notch of needed width and depth out of a piece of steel or brass of suitable size. If you release the pressure on the hammer, while keeping the wrench or cramp clamped on the spring, you will usually have enough freedom between the spring and the hammer/stirrup to permit removal of the spring. You will want to leave the spring in the wrench or cramp until re-assembly of the lock, unless you have the means to re-compress it and clamp it again before replacing it in the lock. The word of warning to be careful is correct: if you let the spring jump out of compression, it may break.
PRD1 - mhb - Mike