pulse width modulation for a relay

iam using a 1-channel 5v to test the pwm to control a light.

can anyone suggest me to do pwm with python code to drive a relay??