WHEN THE EDINBURGH INTL. FILM FESTIVAL opens Aug. 14 with the world premiere of Douglas Mackinnon‘s debut movie “The Flying Scotsman,” it will mark the climax of an extraordinary odyssey for the filmmakers.

What makes “The Flying Scotsman” unusual is not the 12 years it took to get made, nor the number of times the project collapsed and was resurrected before the cameras finally rolled last year.

No, what’s remarkable is that the film, with a paper budget of $11 million, seems to have been made out of thin air, with no visible financing in place and no obvious producer (despite the 10 named in the credits).

This is a movie that never got greenlit, never had a completion bond, never closed its finance, went into administration (the U.K. equivalent of Chapter 11) during post-production and still hasn’t paid half its bills.

“It was a blooding beyond bloody for me,” says Mackinnon. “Everyone tells me it’s the worst scenario in terms of the politics and the money that they’ve ever come across.”

“In hindsight, everyone was completely bonkers,” says one industry veteran who was centrally involved in the project, but requests anonymity to spare his professional blushes.

Yet the word from those who have had a sneak preview is that the movie might, just might, deliver on the crowd-pleasing, heart-warming promise that led one participant to pitch it as ” ‘Shine’ on a bike.”

Certainly, Edinburgh topper Shane Danielsen has made a big statement of faith by opening his festival with the film.

“The Flying Scotsman” is the true story of Graham Obree, the amateur Scottish cyclist who built his own bike out of washing machine parts and rode it to gold at the world championships, despite battling mental illness and hostility from the sport’s authorities.

This classic triumph-from-adversity story attracted screenwriter Simon Rose in 1994. He hooked up with “Rob Roy” producer Peter Broughan, with Mackinnon eventually coming aboard to direct and Jonny Lee Miller to play Obree.

In 2002, the death of a key American investor caused the project to collapse just days before it was due to start shooting.

It took three years to pull it back together again. By then, Broughan had been joined by Damita Nikapota, a mysterious trans-Atlantic producer who sometimes used the pseudonym Sean Murphy.

While negotiating with financiers, Nikapota secured pre-production cash flow from specialist outfit Freewheel, headed by Sara Giles. Broughan fell out spectacularly with Mackinnon and tried to fire him, but Mackinnon refused to walk and cameras rolled last July.

It’s not unusual for indie pics to start lensing before all the paperwork is finished. But in this case, although there seemed to be financing proposals on the table, the sums never quite added up.

“It was only during editing that it became blatantly obvious the producers couldn’t close the financing,” Giles says. Everyone involved, from Obree himself to Strathclyde Police, was owed money, but there was nothing in the pot.

Giles decided the only way the creditors, including herself, would stand any chance of being repaid was to finish the film. That meant taking the production company into administration, and putting up more of her own money. Her eventual cash outlay topped $4 million.

“I inadvertently became the adoptive mother of the film,” Giles says. “I want people to understand that I was not the financier who had let everyone down. I’m the single largest creditor. Everyone is owed something, but the only person who has not been paid a penny is me.”

“It’s only because of Sarah’s faith in the film and her risk-taking that we’re here today,” testifies Mackinnon, who edited at night while shooting a TV show by day to pay his bills.

All hopes now rest on how the film plays at its world premiere. A new sales agent will be announced imminently, and any distribution deals will be used to repay the debts.

Now that really would be a triumph from adversity to rival Obree’s own remarkable story.