title: Pip package a django project
body: <p>The target is to create a pip package of a Django project. </p>
  
  <p>The goal is to make the web application quickly installable anywhere just by doing <code>pip install</code>.</p>
  
  <p>The use cases are 2 that I can think of:</p>
  
  <ol>
  <li><p>Manually start the application using a console_scripts like <code>client-web-up</code> that should be the equivalent to type <code>manage.py runserver</code>. 
  This is what I'm focused on right now. </p></li>
  <li><p>create some sort of script to generate configuration files for apache, nginx etc... for later.</p></li>
  </ol>
  
  <h3>Steps taken</h3>
  
  <ul>
  <li>Created a main folder <code>client_web</code> for my pip package. </li>
  <li>Moved all my project into <code>client_web</code> folder.</li>
  <li>Created a setup.py as shown below.</li>
  <li>Edited manage.py file so its content can be executed by an function named <code>entry()</code>.</li>
  <li><p>Publish the pip package which downloads and installs correctly.</p>
  
  <pre><code>from setuptools import setup
  
  setup(
    name="client-web",
    ...,
    version="2018.08.03.3",
    packages=[
      "client_web",
      "client_web.controller",
      "client_web.measurement",
      "client_web.webapp",
      "client_web.controller.migrations",
      "client_web.measurement.migrations",
    ],
    include_package_data=True,
    install_requires=[
      ...
    ],
    entry_points={
      "console_scripts": [
        "client-web-up=client_web.manage:entry"
      ]
    }
  )
  </code></pre></li>
  </ul>
  
  <h3>The problem</h3>
  
  <p>If i type the following in the terminal:</p>
  
  <pre><code>$ client-web-up
  
  Traceback (most recent call last):
    File "/usr/local/bin/client-web-up", line 26, in &lt;module&gt;
      sys.exit(entry())
    File "/usr/local/lib/python3.7/site-packages/client_web/manage.py", line 33, in entry
      main();
    File "/usr/local/lib/python3.7/site-packages/client_web/manage.py", line 30, in main
      execute_from_command_line(sys.argv)
    File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute_from_command_line
      utility.execute()
    File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 352, in execute
      django.setup()
    File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
      app_config = AppConfig.create(entry)
    File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
      mod = import_module(mod_path)
    File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 953, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 965, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'webapp'
  </code></pre>
  
  <p>But if I do: </p>
  
  <pre><code>$ pip3 show client-web
  
    Name: client-web
    Version: 2018.8.3.3
    Location: /usr/local/lib/python3.7/site-packages
    Requires: ...
    Required-by: ...
  
  $ python3 /usr/local/lib/python3.7/site-packages/client_web/manage.py 
  
    Available subcommands:
  
    [auth]
        changepassword
        createsuperuser
  
    [contenttypes]
        remove_stale_contenttypes
  
    [django]
        ...
  </code></pre>
  
  <p>Could someone help me find a way to make the console_script work?</p>