After reading this thread I went on to the other threads and found this;
https://www.electro-tech-online.com/threads/other-uses-for-garage-door-eyes.114086/
Why couldn't you use the sensors from a garage door? Make new end caps to mount the light and sensor slightly above the top surface of the railing. The sunlight would keep it from working in the day time, which is a good thing. After dark a hand put on the railing would break the beam turning on the lights, a timer keeping them on for whatever time you need to get up the steps.
The end caps holding the sensor/light could be made decorative. These units work over a 16-18 foot garage door opening, don't know how long the railing is, so you might need two or more if its a long distance.