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

[fix] update setuptools and pip before creating virtual env and use system default python

This commit is contained in:
Saurabh 2018-02-09 10:56:17 +05:30
parent cfe169ab4b
commit 8876a40175
4 changed files with 10 additions and 7 deletions

View File

@ -135,6 +135,9 @@ def migrate_env(python, no_backup = False):
pvenv = pvenv pvenv = pvenv
), cwd = path) ), cwd = path)
pip = osp.join(pvenv, 'bin', 'pip')
exec_cmd('{pip} install --upgrade pip'.format(pip=pip))
exec_cmd('{pip} install --upgrade setuptools'.format(pip=pip))
# TODO: Options # TODO: Options
papps = osp.join(path, 'apps') papps = osp.join(path, 'apps')
@ -143,7 +146,6 @@ def migrate_env(python, no_backup = False):
for app in apps: for app in apps:
papp = osp.join(papps, app) papp = osp.join(papps, app)
if osp.isdir(papp) and osp.exists(osp.join(papp, 'setup.py')): if osp.isdir(papp) and osp.exists(osp.join(papp, 'setup.py')):
pip = osp.join(pvenv, 'bin', 'pip')
exec_cmd('{pip} install -e {app}'.format( exec_cmd('{pip} install -e {app}'.format(
pip = pip, app = papp pip = pip, app = papp
)) ))

View File

@ -2,7 +2,7 @@ import click
@click.command() @click.command()
@click.argument('path') @click.argument('path')
@click.option('--python', type = str, default = 'python2', help = 'Path to Python Executable.') @click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.')
@click.option('--ignore-exist', is_flag = True, default = False, help = "Ignore if Bench instance exists.") @click.option('--ignore-exist', is_flag = True, default = False, help = "Ignore if Bench instance exists.")
@click.option('--apps_path', default=None, help="path to json files with apps to install after init") @click.option('--apps_path', default=None, help="path to json files with apps to install after init")
@click.option('--frappe-path', default=None, help="path to frappe repo") @click.option('--frappe-path', default=None, help="path to frappe repo")
@ -16,7 +16,7 @@ import click
def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups, def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups,
no_auto_update, clone_from, verbose, skip_redis_config_generation, no_auto_update, clone_from, verbose, skip_redis_config_generation,
ignore_exist = False, ignore_exist = False,
python = 'python2'): # Let's change we're ready. - <achilles@frappe.io> python = 'python'): # Let's change we're ready. - <achilles@frappe.io>
''' '''
Create a New Bench Instance. Create a New Bench Instance.
''' '''

View File

@ -68,10 +68,11 @@ def setup_backups():
setup_backups() setup_backups()
@click.command('env') @click.command('env')
def setup_env(): @click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.')
def setup_env(python='python'):
"Setup virtualenv for bench" "Setup virtualenv for bench"
from bench.utils import setup_env from bench.utils import setup_env
setup_env() setup_env(python=python)
@click.command('firewall') @click.command('firewall')
@click.option('--ssh_port') @click.option('--ssh_port')

View File

@ -29,7 +29,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None, no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None,
verbose=False, clone_from=None, skip_redis_config_generation=False, verbose=False, clone_from=None, skip_redis_config_generation=False,
ignore_exist = False, ignore_exist = False,
python = 'python2'): # Let's change when we're ready. - <achilles@frappe.io> python = 'python'): # Let's change when we're ready. - <achilles@frappe.io>
from .app import get_app, install_apps_from_path from .app import get_app, install_apps_from_path
from .config.common_site_config import make_config from .config.common_site_config import make_config
from .config import redis from .config import redis
@ -152,7 +152,7 @@ def which(executable, raise_err = False):
return exec_ return exec_
def setup_env(bench_path='.', python = 'python2'): def setup_env(bench_path='.', python = 'python'):
python = which(python, raise_err = True) python = which(python, raise_err = True)
exec_cmd('virtualenv -q {} -p {}'.format('env', python), cwd=bench_path) exec_cmd('virtualenv -q {} -p {}'.format('env', python), cwd=bench_path)