Commits

Brent Tubbs committed baf88a2

ver 0.3.7

Comments (0)

Files changed (2)

 
 setup(
     name='silk-deployment',
-    version='0.3.6',
+    version='0.3.7',
     author='Brent Tubbs',
     author_email='brent.tubbs@gmail.com',
 	packages=find_packages(),
     sudo('apt-get install nginx supervisor --assume-yes --quiet --no-upgrade')
 
 def push_code():
+    _green("PUSHING CODE")
     # Push the local site to the remote root, excluding files that we don't
-    # want to leave cluttering the production server
-    _green("PUSHING CODE")
-    exclude = ("--exclude=site.yaml --exclude=roles "
-               "--exclude=requirements.txt --exclude=fabfile.py")
+    # want to leave cluttering the production server.  Exclude site.yaml
+    # because we'll be writing a new one containing the site config updated
+    # with the role config.  Omit roles because they're superfluous at that
+    # point and also may contain sensitive connection credentials.
+    exclude = "--exclude=site.yaml --exclude=roles"
     _put_dir(env.local_root, env.root, exclude)
 
 def create_virtualenv():
     cmd = "virtualenv --no-site-packages %s %s" % (pyversion, env.envdir)
     sudo(cmd)
 
-# TODO: Add a means of cleaning out old pybundles.
-def install_bundle():
-    """Push the pybundle to the remote host and install it into the virtualenv"""
-    reqs_file = os.path.join(env.local_root, 'requirements.txt')
-    if not os.path.isfile(reqs_file):
-        sys.exit('No requirements.txt file found')
-    reqs = open(reqs_file, 'r').read()
+def pip_deps():
+    """Install requirements listed in the site's requirements.txt file."""
 
-    # Push the pybundle, if necessary
-    _ensure_dir(_join(SRV_ROOT, 'bundles'))
-    remote_pybundle = _join(SRV_ROOT, 'bundles', silk.lib.get_pybundle_name(reqs))
-    if not exists(remote_pybundle):
-        # If bundle hasn't already been made, then make it.
-        pybundle = silk.lib.get_pybundle_path(reqs)
-        if not os.path.isfile(pybundle):
-            _green("BUILDING PYBUNDLE")
-            archive_folder = silk.lib.get_local_archive_dir()
-            if not os.path.isdir(archive_folder):
-                os.makedirs(archive_folder)
-
-            pypi = env.config.get('pypi', 'http://pypi.python.org/pypi')
-            local('pip bundle %s -r %s -i %s' % (pybundle, reqs_file, pypi))
-        _green("PUSHING PYBUNDLE %s" % pybundle)
-        put(pybundle, remote_pybundle, use_sudo=True)
-
-    _green("INSTALLING PYBUNDLE")
-    sudo('%s/bin/pip install %s' % (env.envdir, remote_pybundle))
+    _green("INSTALLING PYTHON DEPENDENCIES")
+    reqs_file = os.path.join(env.root, 'requirements.txt')
+    pypi = env.config.get('pypi', 'http://pypi.python.org/pypi')
+    cachedir = posixpath.join(SRV_ROOT, 'pip_cache')
+    _ensure_dir(cachedir)
+    sudo('PIP_DOWNLOAD_CACHE="%s" %s/bin/pip install -r %s -i %s ' %
+         (cachedir, env.envdir, reqs_file, pypi))
 
 def configure_supervisor():
     """
 def push():
     """
     The main function.  This function will put your site on the remote host and get it
-    running.
+    rTHON DEPENDENCIES.
     """
     # Make sure nginx and supervisord are installed
     install_server_deps()
     push_code()
     # make virtualenv on the server and run pip install on the pybundle
     create_virtualenv()
-    install_bundle()
+    pip_deps()
     _write_site_yaml()
     # write supervisord config for the new site
     configure_supervisor()