title: Using py.test with compiled library code
body: <p>I have a python library with the following repository structure:</p>
  
  <pre><code>repobase
   |- mylibrary
   |  |- __init__.py
   |- tests
      |- test_mylibrary.py
  </code></pre>
  
  <p>Up to now, running the tests could simply be done by calling <code>py.test</code> in the repobase directory. The <code>import mylibrary</code> in <em>test_mylibrary.py</em> then used the local code in <em>repobase/mylibrary</em>.</p>
  
  <p>Now, I've extended the library to use compiled code. Therefore the source code at <em>repobase/mylibrary</em> is not functional on its own. I have to do a <code>setup.py build</code>. This creates <em>repobase/build/lib.linux-x86_64-2.7/mylibrary</em>.</p>
  
  <p><strong>Is there a reasonable way to make py.test use this directory for importing mylibrary? Given these constraints:</strong> </p>
  
  <ol>
  <li><p>I do not want to include any <code>sys.path</code> / import magic in <em>test_mylibrary.py</em> because this may break tests in other envrionments.</p></li>
  <li><p>I don't want to give up the possibility to run <code>py.test</code> from <em>repobase</em>. Therefore modifying the PYTHONPATH does not help because <code>.</code> will still be first in <code>sys.path</code>. And thus <em>repobase/mylibrary</em> would be favored over <em>repobase/build/lib.linux-x86_64-2.7/mylibrary</em>.</p></li>
  </ol>
  
  <p><strong>If not, what's the standard way for testing python libraries, that need building?</strong></p>