The best way for the wizard to defend a spellbook is the same as the best way for you to protect your precious computer files - have multiple backups.
But, if he hasn't had time to make a copy, if he knows someone is trying to steal the book back, he wouldn't leave the book in the shop overnight. He'd keep it on himself, likely guarded by as many guards as a 7th level wizard can afford to hire on a temporary basis.
If he must leave the book in the shop for plot points, he'd certainly have the book very well protected and secured. He's 7th level, so he knows 4th level spells. He might, for example, use Stone Shape to fabricate a 'doorless' safe in a wall or floor block. And he'd certainly know to keep the book in a lead box to block scrying and detection attempts. He could also use illusions to hide/conceal the book. And decoy books and safes to waste the thieves' time. And of course, a 1st level Alarm spell on the shop would work wonders. He might hire a dozen men at arms who hang out in a neighboring building waiting for the alarm to go off.
You say he can't use anything too damaging in terms of traps. Well, poison gas doesn't cause much physical damage and dissipates after a while. And while you say its illegal for him to create fatal traps, a) he may not care, b) bribes and Charm Person can get the well-to-do out of trouble, and c) dead thieves can't report you to the town guard. If you don't want to do that, you can always fill the shop with a Web.
Beyond defending his shop, since he knows there's likely going to be a break-in, he might have a familiar watch the shop from a distance and follow the thieves back to their home/inn/hideout. And when they aren't looking, he can rob them blind.
Best Answer
The Sword & Sorcery book, Book of Eldritch Might III: The Nexus, written by Monte Cook (one of the authors of 3e DMG), has 3.5e-compatible rules for intelligent magic items as NPCs. These rules contain a 20-level class for intelligent items, skills and feats. The catch is that the items cannot gain XP themselves, but need to be fed by others; but you could think of something as the DM.
As an "official" example guideline; the TSR AD&D 2e sourcebook Books of Artifacts has a short section that describes the way intelligent magical items are made. For this a high-level spellcaster has to put her own life force into the item. The caster looses all prior race and class features and all physical statistics; effectively starting the game as a new character with 0 XP. She retains alignment, can speak in previously known languages. As an item it only gains XP for activities it participates in; for example a "sword only earns XP for slaying monsters", not from achieving story goals. At each 100k XP earned, it gains one new power.