The first time Catwoman made a comic-book appearance, back in 1940, Batman cheekily threatened to spank her. Now she’s on the verge of slapping him right back and stealing Friday’s “The Dark Knight Rises” right out from under his pointy-eared cowl.

“Of course Catwoman is more popular than Batman,” Julie Newmar, who played the character in the 1960s TV series, tells The Post. “Catwoman’s her own boss, she makes up her own mind. Catwoman will go on just about forever.”

So far so good. The feline villainess, who’s been around in various forms for some 70 years, is now being reanimated by Anne Hathaway in the conclusion of director Christopher Nolan’s Batman trilogy. Oscar-nominated Hathaway adds gravitas to a character frequently played as a campy vamp by everyone from Eartha Kitt to Halle Berry.

“We felt very strongly that we should have Catwoman in this film, but we always look for an organic way of grounding the characters in our world,” Nolan says. “We needed to find the balance between the classic image of the character and a believable person you care about. Casting Anne Hathaway in the role was the key to that.”

Initially, the choice wasn’t popular with fanboys. Catwoman has always been portrayed as a coquettish sexpot and Hathaway is more theater geek than bombshell. When the first photos of the character surfaced last year, Gawker wrote that she looked like an “awkward old lady.”

But in truth, Hathaway isn’t even playing the feline fox. Her role is Selina Kyle, Catwoman’s alter ego. (“Catwoman” is never explicitly mentioned in the film.) Kyle is a thief and a con artist who helps draw out Batman; the hero has been in seclusion for eight years after being blamed for the death of DA Harvey Dent in “The Dark Knight.” The two costumed figures team up to fight Bane (Tom Hardy), a brutish, masked terrorist who’s trying to destroy Gotham.

The Catwoman presented in “The Dark Knight Rises” is another subtle evolution of the character that was created by Bob Kane and Bill Finger. When she first appeared in “Batman,” No. 1, Kyle was called simply the Cat, wore no costume and was nabbed by Batman after a robbery. When she resisted, the Caped Crusader says, “Quiet or papa spank.”

Ten years later, her origin was finally revealed. Kyle claimed to be a flight attendant who was driven to a life of crime after being hit on the head and suffering amnesia. In the 1980s, her back story was tweaked to that of a former prostitute who had honed her fighting skills in order to survive on the street.

The 1960s TV series left Catwoman’s story ambiguous, while 1992’s “Batman Returns” cast Michelle Pfeiffer as a mousy secretary who is killed by her evil boss only to be magically resurrected by alley cats.

(Then there was 2004’s “Catwoman” with Halle Berry, but honestly, like you, we didn’t see that one.)

Even with Hathaway in place, Nolan struggled to incorporate the character into his version of Batman’s cinematic world, which is far darker and more realistic than previous takes.

He started with the costume.

While audiences have been able to swallow a story about a grown man dressing in a rubber bat suit, believing that a sane woman would wander around rooftops wearing cat ears seemed to be a step too far.

“It was crucial that there be a reason for the appearance of the character, not just as Selina but as Catwoman,” Nolan says. “For me, the jumping off point was figuring out how to derive a cat-ear shape for her without it literally being a pair of ears.”

After trial and error, Nolan and costumer Lindy Hemming settled on giving Kyle a pair of night-vision goggles, much like she wears in her current comic-book incarnation. When flipped on top of her head, the goggles almost accidentally create that familiar silhouette.

Kyle’s bodysuit is also utilitarian and is not meant to be that of some costumed alter ego. The black, skintight duds are what she uses to disappear in the darkness while committing burglaries.

“I loved that the focus was on who she was as Selina, and that there wasn’t a schism within her,” Hathaway says. “She didn’t change when she put on the suit. It was kind of her uniform for her job.”

The costume consists of two pieces made of polyurethane coated spandex — pants and a top — but a thick utility belt around the character’s waist makes it appears to be a seamless bodysuit. Catwoman also wears elbow-length gloves and a nasty pair of spike-heeled boots that double as weapons.

Although it was more breathable than it looks, the costume was still uncomfortable.

“It’s almost ridiculously tight,” says Amy Staggs, a Pittsburgh actress who served as Hathaway’s stand-in and had to wear the top portion of the cat suit. “On a hanger, it looked like something that would barely fit a child. It took some deep yoga breathing to get into.”

In order for Hathaway to fill out the costume properly, filmmakers set her up with a nutritionist and trainer so she could make her body more lithe and toned, like a gymnast.

“She was putting herself under a lot of pressure to look amazing,” Staggs says. “She gave me a heads up that the cat suit is entirely unforgiving.” Or as Hathaway puts it: “If you had to wear a cat suit in front of the entire world, I guarantee you would get your butt to the gym.”

Certified nutrition coach Jackie Keller put the vegetarian actress on a diet designed to reduce inflammation and bloating, while boosting her energy levels. Meals included peanut butter-tofu spread, oatmeal, spiced lentils with fresh peas, vegetarian chili and brown-rice pasta with cauliflower. For dessert, there were brownies or almond-milk smoothies.

“She’s not a big person to begin with,” Keller says of Hathaway, who is around five-foot-seven and under 125 pounds. “It wasn’t a weight-loss issue as much as it was going for a certain look in that cat suit.”

All the body sculpting was necessary because, let’s face it, doesn’t sexuality have something to do with the popularity of the character?

“Hello? What kind of dumb question is that?” says Newmar, who designed her own costume when she played Catwoman on TV from 1966-67. “I won’t even answer that.”

Catwoman, with her hip-hugging costume, whip and flirtatious personality, was created specifically to give the Batman comic “sex appeal,” artist Kane has said. He chose a cat because he thought felines were like women — erratic and difficult to understand.

The character, with its not-so-subtle S&M subtext, actually disappeared from the comics from late 1954 to 1966, presumably because the creators felt she would run afoul of the newly instituted Comics Code, which mandated that women be “depicted in dress reasonably acceptable to society.”

One thing audiences love most about Catwoman is the way she uses that sensuality in the bubbly interplay with the stiff, seemingly asexual Batman.

“I think Catwoman is the second most important villain in “Batman” after the Joker,” says Dr. Will Brooker, author of the new book “Hunting the Dark Knight: Twenty-First Century Batman.” “All of Batman’s rogue’s gallery say something about Batman. Catwoman represents temptation, but in a more romantic way than the Joker.”

“In a weird way, she’s the yin to his yang,” says screenwriter Jonathan Nolan, director Chris’ brother. “The dynamic between them is so fresh — the playful way she kind of pokes fun at him — it sparks a connection between them and takes some of the somberness away from his character.”

It’s little surprise that pretty much every young female in Hollywood was angling for the role. Charlize Theron, Kate Beckinsale and Sienna Miller publicly voiced their desires. Megan Fox was reportedly under consideration, as were Kate Mara, Keira Knightley, Blake Lively, Natalie Portman, Naomi Watts and Rachel Weisz.

“The thing that’s always been intriguing about this part, going all the way back to the television series, [is that] people come up to me and say, ‘Now, is she a good guy or a bad guy?’ ” Pfeiffer says in the documentary “The Many Faces of Catwoman.” “It was always left ambiguous. I always liked that.”

“Playing her, I was allowed to live in this altered state for a little while where I could just soar,” Berry has said. “That feeling of freedom is something that really benefited my own life and it’s something that I can carry with me forever.”

Sean Young so desperately wanted the role in Tim Burton’s 1992 film that when she was passed over, she busted into the Warner Bros. office dressed in a homemade cat costume, reportedly yelling, “What is this bulls – – t?”

Her reasons for coveting the role were far more commercial, however.

“Hollywood has become an unfortunate situation where art and commerce are at odds,” Young said (wearing a Catwoman costume, natch) on “The Joan Rivers Show” in 1991. “The big blockbuster becomes what makes it possible to gain more power and to demand more and better roles.”

What the role does for Hathaway remains to be seen. What is sure is that this won’t be the last we see of Catwoman. If nothing else, reboot-happy Hollywood probably has a Halle Berry do-over in the works.