This womans dream house is a nightmare.

Not long after the death of her husband in 1881, Sarah Winchester began building a 24,000-square-foot home in San Jose, Calif., that includes 161 rooms, six kitchens and countless spooky curiosities. She spent nearly four decades constructing it up until her own death in 1922.

Nobody knows exactly why Winchester, who had inherited millions, sunk much of her vast fortune into its construction. Some say it was her way of grieving for her husband, William, treasurer of his familys Winchester Repeating Arms Co. Others speculate that a medium told her she was cursed by the victims of rifles made by her family, whose ghosts demanded she build them a house out West.

Whatever the reason, the widows magnum opus is now the setting of the new horror movie, Winchester, out Friday, starring Helen Mirren as Sarah. Re-creating the seven-story house, which still stands today as a tourist attraction, was no easy task for the filmmakers.

Trying to replicate what Sarah Winchester did 150 years ago is a big challenge, Matt Putland, the films set decorator, tells The Post by phone from Brisbane, Australia. Its such a complex of twists and turns, of hallways and staircases, and rooms within rooms doors that open to nothing and doors that open to two-story drops. Doors you think are covered, but actually open into hallways. Doors in floors! It was anything goes in that house.

Putland spent four days exploring the mammoth manse. He snapped more than 300 photos of doorknobs and hinges, and took particular note of the collection of rare, 19th-century Lincrusta wallpaper, still in its original packaging, meant for rooms that were never built. By the end, the designer still couldnt navigate his way through the maze.

But, Putland says, he could sense its spirits.

I dont know if I was scared, but definitely in certain areas of the house you could feel a presence, or a strangeness, he says. It just felt a bit off.

While Winchester had 30-odd years to perfect her devilish dwelling, Putland and his crew lacked the luxury of time.

We had six weeks to design and build the sets that we needed, before we started filming, he says. And we were in a totally different country, which added a whole level of challenges.

The film was shot far from San Jose in Melbourne, Australia. For certain indoor scenes, the team searched exhaustively for local buildings from the same era to add authenticity. The trouble was, most of those Australian homes were made of stone, whereas the Winchester House is largely timber. CGI trickery aided with blending the locations into one.

Some of the houses most unique features, however, had to be built from scratch. One was the switchback staircase, which ultimately travels just one story, but comprises seven flights of stairs that fold back in on themselves. Each step only rises two inches, meant to help the frail Winchester easily move about her property.

Other items were either so strange or expensive to duplicate that they had to be shipped from the house itself.

Such was the case with the annunciator, an early visual intercom system that indicated to servants which room Winchester was in, using a signal button. When it arrived, we had to get it functioning back to how it wouldve [worked] 120 years ago, and amazingly all we had to do was attach a battery, Putland says. That thing was still working.

Most of all, the designer cherished the guidance of Winchesters proxy Helen Mirren.

She was quite an amazing person to work with, he says. She was very interested in her hand props and the way that she talked to the spirits. Also, just getting into the vibe of who Sarah Winchester was and how she would decorate her house That was quite a bonus that came with this job.

The ghoulish gig also gave him new insight into the millionairess, who, Putland says, history got wrong.

I felt that she was massively misunderstood by the society she was living in. She came across as a very private person, and a bit of a recluse, he says. But also, on the other side, theres aspects of the house that show a great generosity and a kindness to her staff she was basically giving lifelong employment to the people who worked on that place.

In all its weird kookiness, he says, its quite an achievement for a woman of that time to pull off.