mirror of
https://github.com/frappe/bench.git
synced 2025-01-23 15:08:24 +00:00
fix: Initialize bench with Python 3
This commit is contained in:
parent
d88a327dee
commit
e24ca16c90
@ -2,7 +2,7 @@ import click
|
||||
|
||||
@click.command()
|
||||
@click.argument('path')
|
||||
@click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.')
|
||||
@click.option('--python', type = str, default = 'python3', help = 'Path to Python Executable.')
|
||||
@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('--frappe-path', default=None, help="path to frappe repo")
|
||||
@ -17,7 +17,7 @@ import click
|
||||
def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups,
|
||||
no_auto_update, clone_from, verbose, skip_redis_config_generation, clone_without_update,
|
||||
ignore_exist = False,
|
||||
python = 'python'): # Let's change we're ready. - <achilles@frappe.io>
|
||||
python = 'python3'):
|
||||
'''
|
||||
Create a New Bench Instance.
|
||||
'''
|
||||
|
@ -81,8 +81,8 @@ def setup_backups():
|
||||
setup_backups()
|
||||
|
||||
@click.command('env')
|
||||
@click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.')
|
||||
def setup_env(python='python'):
|
||||
@click.option('--python', type = str, default = 'python3', help = 'Path to Python Executable.')
|
||||
def setup_env(python='python3'):
|
||||
"Setup virtualenv for bench"
|
||||
from bench.utils import setup_env
|
||||
setup_env(python=python)
|
||||
|
@ -38,7 +38,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
verbose=False, clone_from=None, skip_redis_config_generation=False,
|
||||
clone_without_update=False,
|
||||
ignore_exist = False,
|
||||
python = 'python'): # Let's change when we're ready. - <achilles@frappe.io>
|
||||
python = 'python3'): # Let's change when we're ready. - <achilles@frappe.io>
|
||||
from .app import get_app, install_apps_from_path
|
||||
from .config.common_site_config import make_config
|
||||
from .config import redis
|
||||
@ -169,7 +169,7 @@ def which(executable, raise_err = False):
|
||||
|
||||
return exec_
|
||||
|
||||
def setup_env(bench_path='.', python = 'python'):
|
||||
def setup_env(bench_path='.', python = 'python3'):
|
||||
python = which(python, raise_err = True)
|
||||
pip = os.path.join('env', 'bin', 'pip')
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# wget setup_frappe.py | python
|
||||
# wget setup_frappe.py | python3
|
||||
import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
@ -14,7 +14,7 @@ def install_bench(args):
|
||||
success = run_os_command({
|
||||
'apt-get': [
|
||||
'sudo apt-get update',
|
||||
'sudo apt-get install -y git build-essential python-setuptools python-dev libffi-dev libssl-dev'
|
||||
'sudo apt-get install -y git build-essential python3-setuptools python3-dev libffi-dev libssl-dev'
|
||||
],
|
||||
'yum': [
|
||||
'sudo yum groupinstall -y "Development tools"',
|
||||
@ -46,7 +46,7 @@ def install_bench(args):
|
||||
})
|
||||
|
||||
success = run_os_command({
|
||||
'python': 'sudo python get-pip.py --force-reinstall'
|
||||
'python3': 'sudo python3 get-pip.py --force-reinstall'
|
||||
})
|
||||
|
||||
if success:
|
||||
@ -85,12 +85,11 @@ def install_bench(args):
|
||||
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
|
||||
|
||||
# Python executable
|
||||
if not args.production:
|
||||
dist_name, dist_version = get_distribution_info()
|
||||
if dist_name=='centos':
|
||||
args.python = 'python3.6'
|
||||
else:
|
||||
args.python = 'python3'
|
||||
dist_name, dist_version = get_distribution_info()
|
||||
if dist_name=='centos':
|
||||
args.python = 'python3.6'
|
||||
else:
|
||||
args.python = 'python3'
|
||||
|
||||
# create user if not exists
|
||||
extra_vars = vars(args)
|
||||
@ -157,27 +156,6 @@ def get_distribution_info():
|
||||
current_dist = platform.mac_ver()
|
||||
return "macos", current_dist[0].rsplit('.', 1)[0]
|
||||
|
||||
def install_python27():
|
||||
version = (sys.version_info[0], sys.version_info[1])
|
||||
|
||||
if version == (2, 7):
|
||||
return
|
||||
|
||||
print('Installing Python 2.7')
|
||||
|
||||
# install python 2.7
|
||||
success = run_os_command({
|
||||
'apt-get': 'sudo apt-get install -y python-dev',
|
||||
'yum': 'sudo yum install -y python27',
|
||||
'brew': 'brew install python'
|
||||
})
|
||||
|
||||
if not success:
|
||||
could_not_install('Python 2.7')
|
||||
|
||||
# replace current python with python2.7
|
||||
os.execvp('python2.7', ([] if is_sudo_user() else ['sudo']) + ['python2.7', __file__] + sys.argv[1:])
|
||||
|
||||
def install_package(package):
|
||||
package_exec = find_executable(package)
|
||||
|
||||
@ -407,7 +385,7 @@ def parse_commandline_args():
|
||||
parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench')
|
||||
|
||||
# Python interpreter to be used
|
||||
parser.add_argument('--python', dest='python', default='python',
|
||||
parser.add_argument('--python', dest='python', default='python3',
|
||||
help=argparse.SUPPRESS
|
||||
)
|
||||
|
||||
@ -421,12 +399,6 @@ def parse_commandline_args():
|
||||
return args
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
import argparse
|
||||
except ImportError:
|
||||
# install python2.7
|
||||
install_python27()
|
||||
|
||||
args = parse_commandline_args()
|
||||
|
||||
install_bench(args)
|
||||
|
@ -34,8 +34,8 @@
|
||||
creates: "{{ bench_path }}"
|
||||
when: not bench_stat.stat.exists and not production
|
||||
|
||||
- name: python2 bench init for production
|
||||
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }}
|
||||
- name: python3 bench init for production
|
||||
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
|
||||
args:
|
||||
creates: "{{ bench_path }}"
|
||||
when: not bench_stat.stat.exists and production
|
||||
|
@ -21,10 +21,9 @@
|
||||
- libffi-dev
|
||||
- ntp # Clock synchronization
|
||||
- postfix # Mail Server
|
||||
- python-dev # Installing python developer suite
|
||||
- python3-dev # For python3 compatibility
|
||||
- python3-dev # Installing python developer suite
|
||||
- python-tk
|
||||
- screen # To aid ssh sessions with connectivity problems
|
||||
- screen # To aid ssh sessions with connectivity problems
|
||||
- vim # Is that supposed to be a question!?
|
||||
- xfonts-75dpi
|
||||
- xfonts-base
|
||||
@ -34,7 +33,7 @@
|
||||
- libldap2-dev
|
||||
- libcups2-dev
|
||||
- pv # Show progress during database restore
|
||||
|
||||
|
||||
- include_tasks: debian.yml
|
||||
when: ansible_distribution == 'Debian'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev
|
||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python3-dev
|
||||
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
@ -27,6 +27,5 @@
|
||||
- mariadb-client
|
||||
- mariadb-common
|
||||
- libmariadbclient18
|
||||
- python-mysqldb
|
||||
- python3-mysqldb
|
||||
...
|
@ -12,7 +12,7 @@
|
||||
# FLUSH PRIVILEGES;
|
||||
|
||||
- name: Set root Password
|
||||
mysql_user: login_password={{ mysql_root_password }} check_implicit_admin=yes name=root host={{ item }} password={{ mysql_root_password }} state=present
|
||||
mysql_user: login_password={{ mysql_root_password }} check_implicit_admin=yes name=root host={{ item }} password={{ mysql_root_password }} state=present
|
||||
with_items:
|
||||
- localhost
|
||||
- 127.0.0.1
|
||||
|
@ -23,5 +23,5 @@
|
||||
- libmariadbclient18
|
||||
|
||||
- name: Install MySQLdb Python package for secure installations.
|
||||
apt: pkg=python-mysqldb state=present
|
||||
apt: pkg=python3-mysqldb state=present
|
||||
when: mysql_secure_installation and mysql_root_password is defined
|
||||
|
@ -23,5 +23,5 @@
|
||||
- libmariadbclient18
|
||||
|
||||
- name: Install MySQLdb Python package for secure installations.
|
||||
apt: pkg=python-mysqldb state=present
|
||||
apt: pkg=python3-mysqldb state=present
|
||||
when: mysql_secure_installation and mysql_root_password is defined
|
||||
|
Loading…
x
Reference in New Issue
Block a user