mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
Merge pull request #816 from adityahase/py3
fix: Initialise bench with Python 3
This commit is contained in:
commit
ac51286f3c
@ -2,7 +2,7 @@ import click
|
|||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument('path')
|
@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('--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")
|
||||||
@ -17,7 +17,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, clone_without_update,
|
no_auto_update, clone_from, verbose, skip_redis_config_generation, clone_without_update,
|
||||||
ignore_exist = False,
|
ignore_exist = False,
|
||||||
python = 'python'): # Let's change we're ready. - <achilles@frappe.io>
|
python = 'python3'):
|
||||||
'''
|
'''
|
||||||
Create a New Bench Instance.
|
Create a New Bench Instance.
|
||||||
'''
|
'''
|
||||||
|
@ -81,8 +81,8 @@ def setup_backups():
|
|||||||
setup_backups()
|
setup_backups()
|
||||||
|
|
||||||
@click.command('env')
|
@click.command('env')
|
||||||
@click.option('--python', type = str, default = 'python', help = 'Path to Python Executable.')
|
@click.option('--python', type = str, default = 'python3', help = 'Path to Python Executable.')
|
||||||
def setup_env(python='python'):
|
def setup_env(python='python3'):
|
||||||
"Setup virtualenv for bench"
|
"Setup virtualenv for bench"
|
||||||
from bench.utils import setup_env
|
from bench.utils import setup_env
|
||||||
setup_env(python=python)
|
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,
|
verbose=False, clone_from=None, skip_redis_config_generation=False,
|
||||||
clone_without_update=False,
|
clone_without_update=False,
|
||||||
ignore_exist = 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 .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
|
||||||
@ -169,7 +169,7 @@ def which(executable, raise_err = False):
|
|||||||
|
|
||||||
return exec_
|
return exec_
|
||||||
|
|
||||||
def setup_env(bench_path='.', python = 'python'):
|
def setup_env(bench_path='.', python = 'python3'):
|
||||||
python = which(python, raise_err = True)
|
python = which(python, raise_err = True)
|
||||||
pip = os.path.join('env', 'bin', 'pip')
|
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
|
import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ def install_bench(args):
|
|||||||
success = run_os_command({
|
success = run_os_command({
|
||||||
'apt-get': [
|
'apt-get': [
|
||||||
'sudo apt-get update',
|
'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': [
|
'yum': [
|
||||||
'sudo yum groupinstall -y "Development tools"',
|
'sudo yum groupinstall -y "Development tools"',
|
||||||
@ -46,7 +46,7 @@ def install_bench(args):
|
|||||||
})
|
})
|
||||||
|
|
||||||
success = run_os_command({
|
success = run_os_command({
|
||||||
'python': 'sudo python get-pip.py --force-reinstall'
|
'python3': 'sudo python3 get-pip.py --force-reinstall'
|
||||||
})
|
})
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
@ -85,7 +85,6 @@ 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')
|
raise Exception('Please run this script as a non-root user with sudo privileges, but without using sudo or pass --user=USER')
|
||||||
|
|
||||||
# Python executable
|
# Python executable
|
||||||
if not args.production:
|
|
||||||
dist_name, dist_version = get_distribution_info()
|
dist_name, dist_version = get_distribution_info()
|
||||||
if dist_name=='centos':
|
if dist_name=='centos':
|
||||||
args.python = 'python3.6'
|
args.python = 'python3.6'
|
||||||
@ -157,27 +156,6 @@ def get_distribution_info():
|
|||||||
current_dist = platform.mac_ver()
|
current_dist = platform.mac_ver()
|
||||||
return "macos", current_dist[0].rsplit('.', 1)[0]
|
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):
|
def install_package(package):
|
||||||
package_exec = find_executable(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')
|
parser.add_argument('--bench-name', dest='bench_name', help='Create bench with specified name. Default name is frappe-bench')
|
||||||
|
|
||||||
# Python interpreter to be used
|
# Python interpreter to be used
|
||||||
parser.add_argument('--python', dest='python', default='python',
|
parser.add_argument('--python', dest='python', default='python3',
|
||||||
help=argparse.SUPPRESS
|
help=argparse.SUPPRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -421,12 +399,6 @@ def parse_commandline_args():
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
|
||||||
import argparse
|
|
||||||
except ImportError:
|
|
||||||
# install python2.7
|
|
||||||
install_python27()
|
|
||||||
|
|
||||||
args = parse_commandline_args()
|
args = parse_commandline_args()
|
||||||
|
|
||||||
install_bench(args)
|
install_bench(args)
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
creates: "{{ bench_path }}"
|
creates: "{{ bench_path }}"
|
||||||
when: not bench_stat.stat.exists and not production
|
when: not bench_stat.stat.exists and not production
|
||||||
|
|
||||||
- name: python2 bench init for production
|
- name: python3 bench init for production
|
||||||
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }}
|
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
|
||||||
args:
|
args:
|
||||||
creates: "{{ bench_path }}"
|
creates: "{{ bench_path }}"
|
||||||
when: not bench_stat.stat.exists and production
|
when: not bench_stat.stat.exists and production
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
- libffi-dev
|
- libffi-dev
|
||||||
- ntp # Clock synchronization
|
- ntp # Clock synchronization
|
||||||
- postfix # Mail Server
|
- postfix # Mail Server
|
||||||
- python-dev # Installing python developer suite
|
- python3-dev # Installing python developer suite
|
||||||
- python3-dev # For python3 compatibility
|
|
||||||
- python-tk
|
- 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!?
|
- vim # Is that supposed to be a question!?
|
||||||
|
@ -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
|
- include_tasks: debian_family.yml
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
@ -27,6 +27,5 @@
|
|||||||
- mariadb-client
|
- mariadb-client
|
||||||
- mariadb-common
|
- mariadb-common
|
||||||
- libmariadbclient18
|
- libmariadbclient18
|
||||||
- python-mysqldb
|
|
||||||
- python3-mysqldb
|
- python3-mysqldb
|
||||||
...
|
...
|
@ -23,5 +23,5 @@
|
|||||||
- libmariadbclient18
|
- libmariadbclient18
|
||||||
|
|
||||||
- name: Install MySQLdb Python package for secure installations.
|
- 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
|
when: mysql_secure_installation and mysql_root_password is defined
|
||||||
|
@ -23,5 +23,5 @@
|
|||||||
- libmariadbclient18
|
- libmariadbclient18
|
||||||
|
|
||||||
- name: Install MySQLdb Python package for secure installations.
|
- 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
|
when: mysql_secure_installation and mysql_root_password is defined
|
||||||
|
Loading…
Reference in New Issue
Block a user