X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/1424bfacd82ffc238f90f1baa99388fc1ac9f2e7..4ee58649c86d9c4bd4ac89dd46325d0a1c443122:/deployment.py diff --git a/deployment.py b/deployment.py index a9a4f580..789d3425 100644 --- a/deployment.py +++ b/deployment.py @@ -5,7 +5,7 @@ import os import sys import logging -logging.basicConfig(stream=sys.stderr, format="%(levelname)s:: %(message)s") +logging.basicConfig(stream=sys.stderr, format="%(levelname)s:: %(message)s", level=logging.INFO) from string import Template @@ -25,6 +25,9 @@ class DeploySite(object): self.env['PYTHON_BIN'] = os.path.join( self.env['PYTHON_BASE'], 'bin', 'python') + self.env['PYTHON_VERSION'] + if 'PIP_BIN' not in self.env: + self.env['PIP_BIN'] = os.path.join(self.env['PYTHON_BASE'], 'bin', 'pip') + if 'PYTHON_SITE' not in self.env: self.env['PYTHON_SITE'] = os.path.join( self.env['PYTHON_BASE'], 'lib', @@ -74,9 +77,11 @@ class DeploySite(object): self.restart_app() def find_resource(self, path): - full_path = os.path.join(self.env['APP_DIR'], path) - if os.path.isfile(full_path): - return full_path + for dir in (self.env['CONFIG_DIR'], self.env['APP_DIR']): + full_path = os.path.join(dir, path) + if os.path.isfile(full_path): + return full_path + raise ValueError("Resource '%s' not found" % path) @classmethod @@ -111,11 +116,11 @@ class PIPSite(DeploySite): def install_dependencies(self): self.info("Installing requirements") - os.system("pip install -r %s" % self.find_resource('requirements.txt')) + os.system("%s install -r %s" % (self.env['PIP_BIN'], self.find_resource('requirements.txt'))) try: self.info("Installing local requirements") - os.system("pip install -r %s" % self.find_resource('requirements_local.txt')) + os.system("%s install -r %s" % (self.env['PIP_BIN'], self.find_resource('requirements_local.txt'))) except ValueError: pass