title: PyInstaller, relative imports, and entry points
body: <p>I’m trying to use PyInstaller to package a command-line tool for Linux systems. Following is the repo filesystem layout:</p>
  
  <pre><code>repo_dir/
      ReadMe.md
      setup.py
      meerkat/
          meerkat.py
          api.py
          config.py
          errors.py
          __init__.py
  </code></pre>
  
  <p>The main entry point is <code>meerkat/meerkat.py</code>, which looks like:</p>
  
  <pre><code>import click
  import requests
  
  from . import VERSION
  from . import api
  from . import config
  from . import errors
  from . import log
  
  [... logic ...]
  
  if __name__ == '__main__':
      cli(obj={})
  </code></pre>
  
  <p>When I build the executable via:</p>
  
  <pre><code>cd repo_dir
  pyinstaller -F -p $VIRTUAL_ENV/lib/python2.7/site-packages meerkat/meerkat.py
  </code></pre>
  
  <p>... and then run the resulting executable, I get this error:</p>
  
  <pre><code>File "meerkat/meerkat.py", line 4, in &lt;module&gt;
      from . import VERSION
  ValueError: Attempted relative import in non-package
  </code></pre>
  
  <p>I understand the general cause of the problem, since the same error occurs when running <code>python meerkat/meerkat.py version</code> instead of <code>python -m meerkat.meerkat version</code>. </p>
  
  <p><a href="https://pex.readthedocs.io/en/stable/buildingpex.html#pex-m" rel="nofollow">PEX allows you to specify the entry point</a> at build time via the <code>-m meerkat.meerkat:cli</code> argument, but I have no idea how to make PyInstaller do something similar. Anyone have any suggestions as to how I can fix this?</p>