title: Enforce package separation (avoid imports from specific modules)
body: <p>I'm working on a python app that contains the following root folders:</p>
  
  <pre><code> +---FrontEnd 
   +---BackEnd
   +---Common
  </code></pre>
  
  <p>FrontEnd and BackEnd import from Common but Common should not import from the former. I'd like to enforce this rule programatically so my team (especially new team members) do not accidentally import FrontEnd or BackEnd into Common.</p>
  
  <p>I heard import hooks could help here but I haven't found much info on this. My first attempt didn't go so well either:</p>
  
  <p><strong><code>Common.__init__.py</code></strong></p>
  
  <pre><code>class NoForeignDependencies(object):
  
      PATH_TRIGGERS = ['FrontEnd', 'BackEnd']
  
      def __init__(self, path_entry):
          if path_entry not in self.PATH_TRIGGERS:
              raise ImportError()
  
      def find_module(self, fullname, path=None):
          print 'Import not allowed for this module'
          return None
  
  sys.path_hooks.append(NoForeignDependencies)
  </code></pre>
  
  <p>Any ideas on how I can accomplish this?</p>