Jim Carrey will star in “I Love You Phillip Morris,” a dark comedy that was written and will mark the directing debut of Glenn Ficarra and John Requa, the writing team behind “Bad Santa.”

Andrew Lazar and Far Shariat will produce.

Carrey will play a conman whose love for a cellmate leads him to make several prison escapes.

A financing deal for the less-than-$20 million film is about to close with Luc Besson’s Europacorp, which bested several rival bids when the project was shopped in Cannes.

Based on a book by Houston Chronicle crime reporter Steve McVicker, the fact-based film casts Carrey as Steven Russell, a married father whose exploits landed him in the Texas criminal justice system.

He fell madly in love with his cellmate, who eventually was set free, which led Russell to escape from Texas prisons four times. Script has some of the dark edges of “Bad Santa” but is grounded by the affable and lovesick character of Russell. Project was pitched to financiers as “Catch Me if You Can” meets “Brokeback Mountain.” It went to Besson, who recently declared an intention to take Europacorp public with an initial offering in Paris.

Lazar bought the book while it was in galleys four years ago and enlisted Ficarra and Requa, who wrote “Cats & Dogs” for the producer. Carrey was the first actor to whom he showed it.

The timing of the film hasn’t yet been resolved. Like many stars, Carrey is plotting back-to-back films that can be completed before the SAG contract expires next summer.

This project is one of the finalists for those slots; another is “Ripley’s Believe It or Not!,” the film Paramount put the brakes on last year. Studio, director Tim Burton and Carrey all sparked to a rewrite just turned in by Steve Oedekerk.

The “Phillip Morris” deal was put together by Carrey managers Jimmy Miller and Eric Gold and CAA, along with the writer-directors’ Endeavor reps and John Nichols, the attorney who reps Europacorp and Lazar.