DELTA, B.C. -- Mat Beren and his friends used to drive by the vast greenhouses of southern British Columbia and joke about how much weed they could grow there.

Years later, it's no joke. The tomato and pepper plants that once filled some of those greenhouses have been replaced with a new cash crop: marijuana. Beren and other formerly illicit growers are helping cultivate it. The buyers no longer are unlawful dealers or dubious medical dispensaries; it's the Canadian government.

On Oct. 17, Canada becomes the second and largest country with a legal national marijuana marketplace. Uruguay launched legal sales last year, after several years of planning.

It's a profound social shift promised by Canadian Prime Minister Justin Trudeau and fueled by a desire to bring the black market into a regulated, taxed system after nearly a century of prohibition.

It also stands in contrast to the United States, where the federal government outlaws marijuana while most states allow medical or recreational use for people 21 and older. Canada's national approach has allowed for unfettered industry banking, inter-province shipments of cannabis, online ordering, postal delivery and billions of dollars in investment; national prohibition in the U.S. has stifled greater industry expansion there.

Hannah Hetzer, who tracks international marijuana policy for the New York-based Drug Policy Alliance, called Canada's move "extremely significant," given that about 25 countries have already legalized the medical use of marijuana or decriminalized possession of small amounts of the drug. A few, including Mexico, have expressed an interest in regulating recreational use.

"It's going to change the global debate on drug policy," she said. "There's no other country immediately considering legalizing the nonmedical use of cannabis, but I think Canada will provide almost the permission for other countries to move forward."

At least 109 legal pot shops are expected to open across the nation of 37 million people next Wednesday, with many more to come, according to an Associated Press survey of the provinces. For now, they'll offer dried flower, capsules, tinctures and seeds, with sales of marijuana-infused foods and concentrates expected to begin next year.

The provinces are tasked with overseeing marijuana distribution. For some, including British Columbia and Alberta, that means buying cannabis from licensed producers, storing it in warehouses and then shipping it to retail shops and online customers. Others, like Newfoundland, are having growers ship directly to stores or through the mail.

Federal taxes will total $1 per gram or 10 per cent, whichever is more. The feds will keep one-fourth of that and return the rest to the provinces, which can add their own markups. Consumers also will pay local sales taxes.

Some provinces have chosen to operate their own stores, like state-run liquor stores in the U.S., while others have OK'd private outlets. Most are letting residents grow up to four plants at home.

Canada's most populous province, Ontario, won't have any stores open until next April, after the new conservative government scrapped a plan for state-owned stores in favour of privately run shops. Until then, the only legal option for Ontario residents will be mail delivery -- a prospect that didn't sit well with longtime pot fan Ryan Bose, 48, a Lyft driver.

"Potheads are notoriously very impatient. When they want their weed, they want their weed," he said after buying a half-ounce at an illicit medical marijuana dispensary in Toronto. "Waiting one or two three days for it by mail, I'm not sure how many will want to do that."

British Columbia, home of the "B.C. Bud" long cherished by American pot connoisseurs, has had a prevalent marijuana culture since the 1970s, after U.S. draft-dodgers from the Vietnam War settled on Vancouver Island and in the province's southeastern mountains. But a change in government last year slowed cannabis distribution plans there, too, and it will have just one store ready next Wednesday: a state-run shop in Kamloops, a few hours' drive northeast of Vancouver. By contrast, Alberta expects to open 17 next week and 250 within a year.

There is no immediate crackdown expected for the dozens of illicit-but-tolerated medical marijuana dispensaries operating in British Columbia, though officials eventually plan to close any without a license. Many are expected to apply for private retail licenses, and some have sued, saying they have a right to remain open.

British Columbia's ministry of public safety is forming a team of 44 inspectors to root out unlawful operations, seize product and issue fines. They'll have responsibility for a province of 4.7 million people and an area twice as large as California, where the black market still dwarfs the legal market that arrived in January.

Chris Clay, a longtime Canadian medical marijuana activist, runs Warmland Centre dispensary in an old shopping mall in Mill Bay, on Vancouver Island. He is closing the store Monday until he gets a license; he feared continuing to operate post-legalization would jeopardize his chances. Some of his eight staff members will likely have to file for unemployment benefits in the meantime.

"That will be frustrating, but overall I'm thrilled," Clay said. "I've been waiting decades for this."

The federal government has licensed 120 growers, some of them enormous. Canopy Growth, which recently received an investment of $4 billion from Constellation Brands, whose holdings include Corona beer, Robert Mondavi wines and Black Velvet whiskey, is approved for 5.6 million square feet (520,000 square meters) of production space across Canada. Its two biggest greenhouses are near the U.S. border in British Columbia.

Beren, a 23-year cannabis grower, is a Canopy consultant.

"We used to joke around all the time when we'd go to Vancouver and drive by the big greenhouses on the highway," he said. "Like, 'Oh man, someday. It'd be so awesome if we could grow cannabis in one of these greenhouses.' We drive by now and we're like, 'Oh, we're here."'

Next to Canopy's greenhouse in Delta is another huge facility, Pure Sunfarms, a joint venture between a longtime tomato grower, Village Farms International, and a licensed medical marijuana producer, Emerald Health Therapeutics. Workers pulled out the remaining tomato plants last winter and got to work renovating the greenhouse as a marijuana farm, installing equipment that includes lights and accordion-shaped charcoal vents to control the plant's odour. By 2020, the venture expects to move more than 165,000 pounds (75,000 kg) of bud per year.

Some longtime illegal growers who operate on a much smaller scale worry they won't get licensed or will get steamrolled by much larger producers. Provinces can issue "micro-producer" licenses, but in British Columbia, where small-time pot growers helped sustain rural economies as the mining and forestry industries cratered, the application period hasn't opened yet.

Sarah Campbell of the Craft Cannabis Association of BC said many small operators envision a day when they can host visitors who can tour their operations and sample the product, as wineries do.

Officials say they intend to accommodate craft growers but first need to ensure there is enough cannabis to meet demand when legalization arrives. Hiccups are inevitable, they say, and tweaks will be needed.

"Leaving it to each province to decide what's best for their communities and their citizens is something that's good," said Gene Makowsky, the Saskatchewan minister who oversees the province's Liquor and Gaming Authority. "We'll be able to see if each law is successful or where we can do better in certain areas."

British Columbia safety minister Mike Farnworth said he learned two primary lessons by visiting Oregon and Washington, U.S. states with recreational marijuana. One was not to look at the industry as an immediate cash cow, as it will take time to displace the black market. The other was to start with relatively strict regulations and then loosen them as needed, because it's much harder to tighten them after the fact.

Legalization will be a process more than a date, Farnworth said.

"Oct. 17th is actually not going to look much different than it does today," he said.

------

Rob Gillies reported from Toronto. Gene Johnson is a member of AP's marijuana beat team