title: python packaging for relative imports
body: <p>First off all: I'm sorry, I know there has been lots of question about relative imports, but I just didn't find a solution. If possible I would like to use the following directory layout:</p>
  
  <pre><code>myClass/
      __init__.py
      test/
          demo.py
          benchmark.py
          specs.py
      src/
          __init__.py
          myClass.py
  </code></pre>
  
  <p>Now my questions are:</p>
  
  <ul>
  <li><p>How do the test files from within the package properly import myClass.py?</p></li>
  <li><p>How would you import the package from outside, assuming you take myClass as submodule in libs/myClass or include/myClass?</p></li>
  </ul>
  
  <p>So far I couldn't find an elegant solution for this. From what I understand <a href="http://www.python.org/dev/peps/pep-0328/#guido-s-decision" rel="noreferrer">Guido's Decision</a> it should be possible to do <code>from ..src import myClass</code> but this will error:</p>
  
  <p><code>ValueError: Attempted relative import in non-package</code></p>
  
  <p>Which looks as it doesn't treat myClass as packages. <a href="http://docs.python.org/tutorial/modules.html#packages" rel="noreferrer">Reading the docs</a>:</p>
  
  <blockquote>
    <p>The __init__.py files are required to make Python treat the directories as containing packages;</p>
  </blockquote>
  
  <p>It seems I'm missing something that specifies where the scripts of the package are, should I use .pth ?</p>