2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

add git cache, fix #43

This commit is contained in:
Pratik Vyas 2014-09-04 13:08:43 +05:30
parent 244dceaf3b
commit fd2cc9872c
4 changed files with 56 additions and 3 deletions

View File

@ -35,7 +35,12 @@ def new_app(app, bench='.'):
def install_app(app, bench='.'):
logger.info('installing {}'.format(app))
exec_cmd("{pip} install -e {app}".format(pip=os.path.join(bench, 'env', 'bin', 'pip'), app=os.path.join(bench, 'apps', app)))
conf = get_config()
find_links = '--find-links={}'.format(conf.get('wheel_cache_dir')) if conf.get('wheel_cache_dir') else ''
exec_cmd("{pip} install {find_links} -e {app}".format(
pip=os.path.join(bench, 'env', 'bin', 'pip'),
app=os.path.join(bench, 'apps', app),
find_links=find_links))
add_to_appstxt(app, bench=bench)
def pull_all_apps(bench='.'):

View File

@ -11,7 +11,7 @@ from .utils import set_nginx_port as _set_nginx_port
from .utils import set_default_site as _set_default_site
from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_frappe, setup_logging,
get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements,
backup_all_sites, backup_site, get_sites)
backup_all_sites, backup_site, get_sites, prime_wheel_cache)
from .app import get_app as _get_app
from .app import new_app as _new_app
from .app import pull_all_apps
@ -169,6 +169,11 @@ def _backup_all_sites():
"backup all sites"
backup_all_sites(bench='.')
@click.command('prime-wheel-cache')
def _prime_wheel_cache():
"Update wheel cache"
prime_wheel_cache(bench='.')
## Setup
@click.group()
def setup():
@ -303,3 +308,4 @@ bench.add_command(migrate_3to4)
bench.add_command(shell)
bench.add_command(_backup_all_sites)
bench.add_command(_backup_site)
bench.add_command(_prime_wheel_cache)

View File

@ -0,0 +1,26 @@
chardet
cssmin
dropbox
gunicorn
httplib2
jinja2
markdown2
markupsafe
mysql-python
pygeoip
python-dateutil
python-memcached
pytz==2013d
six
slugify
termcolor
werkzeug
semantic_version
rauth>=0.6.2
requests==1.2.3
celery
redis
selenium
unidecode
babel
pdfkit

View File

@ -25,7 +25,7 @@ def get_frappe(bench='.'):
return frappe
def init(path, apps_path=None, no_procfile=False, no_backups=False,
no_auto_update=False, frappe_path=None):
no_auto_update=False, frappe_path=None, wheel_cache_dir=None):
from .app import get_app, install_apps_from_path
if os.path.exists(path):
print 'Directory {} already exists!'.format(path)
@ -39,6 +39,9 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
setup_env(bench=path)
put_config(default_config, bench=path)
if wheel_cache_dir:
update_config({"wheel_cache_dir":wheel_cache_dir}, bench=path)
prime_wheel_cache(bench=path)
if not frappe_path:
frappe_path = 'https://github.com/frappe/frappe.git'
get_app('frappe', frappe_path, bench=path)
@ -60,6 +63,7 @@ def exec_cmd(cmd, cwd='.'):
def setup_env(bench='.'):
exec_cmd('virtualenv {} -p {}'.format('env', sys.executable), cwd=bench)
exec_cmd('./env/bin/pip install wheel', cwd=bench)
def setup_procfile(bench='.'):
with open(os.path.join(bench, 'Procfile'), 'w') as f:
@ -244,3 +248,15 @@ def backup_site(site, bench='.'):
def backup_all_sites(bench='.'):
for site in get_sites(bench=bench):
backup_site(site, bench=bench)
def prime_wheel_cache(bench='.'):
conf = get_config(bench=bench)
wheel_cache_dir = conf.get('wheel_cache_dir')
if not wheel_cache_dir:
raise Exception("Wheel cache dir not configured")
requirements = os.path.join(os.path.dirname(__file__), 'templates', 'cached_requirements.txt')
cmd = "{pip} wheel --find-links {wheelhouse} --wheel-dir {wheelhouse} -r {requirements}".format(
pip=os.path.join(bench, 'env', 'bin', 'pip'),
wheelhouse=wheel_cache_dir,
requirements=requirements)
exec_cmd(cmd)