title: Installing a python C package into a bin folder
body: <p>I would like to know how to have setup.py install c modules locally.  Locally as in not in <code>/usr/local/python..</code> and not in <code>~/local/python...</code>, but in <code>[where_all_my_code_is]/bin</code> and I can import it from scripts within the [where_all_my_code_is] folder.</p>
  
  <p>I have some c code.  src/foo/foo.c</p>
  
  <pre><code>#include &lt;Python.h&gt;
  static PyObject * foo(PyObject* o) {
      PyObject* five = PyInt_FromLong(5);
      return PyNumber_Add(&amp;o, &amp;five);
  }
  static PyMethodDef funcs[] = {
      {"foo", (PyCFunction)foo, METH_VARARGS, "foo, foo and more foo"},
      {NULL, NULL, 0, NULL}
  };
  PyMODINIT_FUNC initaddList(void){
      Py_InitModule3("foo", funcs, "do the foo");
  }
  </code></pre>
  
  <p>setup.py</p>
  
  <pre><code>from distutils.core import setup, Extension
  
  setup(name='foo', version='1.0',
      ext_modules=[Extension('foo', ['src/foo/foo.c'])])
  </code></pre>
  
  <p>Now, instead of installing this into my whatever /local/python folders or whatever, I want the code to be in a bin folder right there next to the module.</p>
  
  <p>e.g.</p>
  
  <pre><code>~/My_python_project
       ./src
           ./foo
               ./foo.c
           ./some_code_that_imports_foo.py
       ./bin
           ./foo
               ./my_importable_foo.so
  </code></pre>
  
  <p>some_code_that_imports_foo.py:</p>
  
  <pre><code>import foo
  print(foo.foo(10))
  # prints 15
  </code></pre>
  
  <p>What is the appropriate/nicest way to accomplish this thing?</p>