From d1ff01bd3d73a59a8706011eeed5fce9b3611179 Mon Sep 17 00:00:00 2001 From: Jean-Francois Thuong Date: Tue, 29 Mar 2022 06:34:17 +0000 Subject: [PATCH] #1077: Added support of Python3 on top of Python 2.7 --- README.md | 6 +++--- hooks/post-checkout | 32 +++++++++++++++++--------------- hooks/post-merge | 12 ++++++------ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 582845f92c..b51d38e09c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ It's important to use precise minor version numbers where specified. `nodegit`/ $ curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0 -4.) python 2.7.16 (if you need multiple Python environments on your machine, we recommend [pyenv](https://github.com/pyenv/pyenv)) +4.) python 2.7 or 3.x (if you need multiple Python environments on your machine, we recommend [pyenv](https://github.com/pyenv/pyenv)) 5.) libgcrypt (required for nodegit native bindings) $ brew install libgcrypt @@ -54,7 +54,7 @@ Assuming a clean Windows 10, open a PowerShell with admin rights: Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # Install git -choco install git python2 -y +choco install git python -y # Install nodejs choco install nodejs-lts -y --version 8.15.1 @@ -81,7 +81,7 @@ yarn electron-rebuild ### Linux OS dependencies * Install a desktop environment like Gnome, XFCE, or KDE if machine does not already have one -* Install dependences from system repositories: `apt install git curl python2 build-essential libgcrypt20 libcurl4-openssl-dev libssl-dev libgtk-3-0 libgconf-2-4 libnss3` +* Install dependences from system repositories: `apt install git curl python3 build-essential libgcrypt20 libcurl4-openssl-dev libssl-dev libgtk-3-0 libgconf-2-4 libnss3` * Install nvm: `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash` * Install node 8.15.1: `nvm install 8.15.1 && nvm alias default 8.15.1 && nvm use 8.15.1` * Install yarn 1.13.0: `curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0` diff --git a/hooks/post-checkout b/hooks/post-checkout index 83cabe1807..97c049397d 100755 --- a/hooks/post-checkout +++ b/hooks/post-checkout @@ -1,24 +1,26 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python +import os import sys -from os import environ -from os import path import json import subprocess is_branch_checkout = sys.argv[3] -if is_branch_checkout == '0' or environ.get('SKIP_HAIKU_HOOKS', '0') == '1': - # This is a file checkout or we have been expliticly asked to do nothing. - sys.exit(0) +if is_branch_checkout == '0' or os.environ.get('SKIP_HAIKU_HOOKS', '0') == '1': + # This is a file checkout or we have been expliticly asked to do nothing. + sys.exit(0) -current_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip() -with open(path.join('packages', 'haiku-common', 'config', 'experiments.json')) as experiments_file: - experiments = json.load(experiments_file) +current_branch = subprocess.check_output( + ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip() +with open(os.path.join('packages', 'haiku-common', 'config', 'experiments.json')) as experiments_file: + experiments = json.load(experiments_file) if sys.argv[1] != sys.argv[2]: - print 'Syncing dependencies....' - subprocess.call(['yarn', 'install']) + print('Syncing dependencies....') + subprocess.call(['yarn', 'install']) -print 'The following experiments are enabled:' -print '\n'.join([ - ' - {}'.format(experiment) for experiment in experiments if experiments.get(experiment, False) -]) +print('The following experiments are enabled:') +print( + '\n'.join([ + ' - {}'.format(experiment) for experiment in experiments if experiments.get(experiment, False) + ]) +) diff --git a/hooks/post-merge b/hooks/post-merge index dcd8d066c1..c75ac070df 100755 --- a/hooks/post-merge +++ b/hooks/post-merge @@ -1,11 +1,11 @@ -#!/usr/bin/env python2.7 -from os import environ +#!/usr/bin/env python +import os import subprocess import sys -if environ.get('SKIP_HAIKU_HOOKS', '0') == '1': - # We have been expliticly asked to do nothing. - sys.exit(0) +if os.environ.get('SKIP_HAIKU_HOOKS', '0') == '1': + # We have been expliticly asked to do nothing. + sys.exit(0) -print 'Syncing dependencies....' +print('Syncing dependencies....') subprocess.call(['yarn', 'install'])