From f032fc0b86f6891399d3dba41cca782319667ed3 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 14 Aug 2020 20:29:46 +0530 Subject: [PATCH 1/3] fix: Check if Py3.5+ before installing distro --- install.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/install.py b/install.py index d62f6ddf..2b70d7f4 100644 --- a/install.py +++ b/install.py @@ -20,6 +20,7 @@ execution_time = "{:%H:%M}".format(execution_timestamp) log_file_name = "easy-install__{0}__{1}.log".format(execution_day, execution_time.replace(':', '-')) log_path = os.path.join(tmp_log_folder, log_file_name) log_stream = sys.stdout +distro_required = not ((sys.version_info.major < 3) or (sys.version_info.major == 3 and sys.version_info.minor < 5)) def log(message, level=0): @@ -93,10 +94,10 @@ def check_distribution_compatibility(): else: log("Sorry, the installer doesn't support {0}. Aborting installation!".format(dist_name), level=2) + def import_with_install(package): # copied from https://discuss.erpnext.com/u/nikunj_patel # https://discuss.erpnext.com/t/easy-install-setup-guide-for-erpnext-installation-on-ubuntu-20-04-lts-with-some-modification-of-course/62375/5 - # need to move to top said v13 for fully python3 era import importlib @@ -115,14 +116,11 @@ def import_with_install(package): def get_distribution_info(): # return distribution name and major version if platform.system() == "Linux": - if sys.version_info.major == 3 and sys.version_info.minor > 7: - install_package('pip3', 'python3-pip') - - import_with_install('distro') - + if distro_required: current_dist = distro.linux_distribution(full_distribution_name=True) else: current_dist = platform.dist() + return current_dist[0].lower(), current_dist[1].rsplit('.')[0] elif platform.system() == "Darwin": @@ -391,6 +389,12 @@ def run_playbook(playbook_name, sudo=False, extra_vars=None): return success +def setup_script_requirements(): + if distro_required: + install_package('pip3', 'python3-pip') + import_with_install('distro') + + def parse_commandline_args(): import argparse @@ -433,6 +437,7 @@ def parse_commandline_args(): return args + if __name__ == '__main__': if sys.version[0] == '2': if not os.environ.get('CI'): @@ -459,6 +464,7 @@ if __name__ == '__main__': with warnings.catch_warnings(): warnings.simplefilter("ignore") setup_log_stream(args) + setup_script_requirements() check_distribution_compatibility() check_system_package_managers() check_environment() @@ -466,4 +472,3 @@ if __name__ == '__main__': install_bench(args) log("Bench + Frappe + ERPNext has been successfully installed!") - \ No newline at end of file From 892b449cd607d570c7b3da7f262f35b988b17a02 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 14 Aug 2020 20:45:50 +0530 Subject: [PATCH 2/3] chore: Use 3.4, 3.6 and 3.8 to test install.py Previously, tests were run for 3.6, 3.7 and 3.8; Changed the targets to have more range of the versions --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 295e057d..379add08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,13 +65,13 @@ matrix: env: TEST=bench script: python -m unittest -v bench.tests.test_init - - name: "Python 3.6 Easy Install" - python: 3.6 + - name: "Python 3.4 Easy Install" + python: 3.4 env: TEST=easy_install script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - - name: "Python 3.7 Easy Install" - python: 3.7 + - name: "Python 3.6 Easy Install" + python: 3.6 env: TEST=easy_install script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose From 5c8e9f2e556fddff55f26063bad249a8babf6d5a Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Sat, 15 Aug 2020 11:20:19 +0530 Subject: [PATCH 3/3] chore: Use 3.5, 3.7 and 3.8 to test install.py 3.4 isn't available so let's not! --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 379add08..8bc96c6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,13 +65,13 @@ matrix: env: TEST=bench script: python -m unittest -v bench.tests.test_init - - name: "Python 3.4 Easy Install" - python: 3.4 + - name: "Python 3.5 Easy Install" + python: 3.5 env: TEST=easy_install script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - - name: "Python 3.6 Easy Install" - python: 3.6 + - name: "Python 3.7 Easy Install" + python: 3.7 env: TEST=easy_install script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose