title: Compiling Python code into an exe file calling just the required DLLs
body: <p>There seems to be little information out there on this subject - I have tried <code>py2exe</code> to no avail (errors out w/ Python 3.5), as well as <code>pyinstaller.</code>  The latter seems to include EVERY extension module installed on the system unless they are specifically excluded during build time, which ends up being 50+ on even a small build.  I have also seen <code>pyinst</code> and <code>cxFreeze</code> where you can specify which packages to include and it bundles Python with it, BUT I want simple and small.  All the work I do involves AT MOST <code>NumPy</code>, <code>SciPy</code>, and <code>Pandas</code>.  Typically these can all be reduced to <code>NumPy</code> only functions, and most complex ones I rewrite in Cython (with <code>memoryviews</code>).  Looking around the internet I've found that <code>python.exe</code> is a C++ program that only calls <code>Python.h</code> and loads <code>python35.dll</code> - this suggests something as simple as this C++ code sample would allow one to access all of Python and <code>NumPy</code> functionality as so:</p>
  
  <pre><code>#include "Python.h"
  #include &lt;\numpy\core\include\numpy\ required includes&gt;
  
  int
  wmain(int argc, wchar_t **argv)
  {
      wchar_t *myargs[3] = { argv[0], L"-m", L"myscript.py" };
      return Py_Main(3, myargs);
  }
  </code></pre>
  
  <p>Example is from:
  <a href="https://blogs.msdn.microsoft.com/pythonengineering/2016/04/26/cpython-embeddable-zip-file/" rel="nofollow">https://blogs.msdn.microsoft.com/pythonengineering/2016/04/26/cpython-embeddable-zip-file/</a></p>
  
  <p>Does anyone have a good way or a good reference to generate a small build which includes only what you need for the exe to run?  Or can confirm the above would actually work with modifications?  Much appreciated, I think this skill is a niche subject...</p>