Skip to content

Commit

Permalink
fix(easy-install): compatibility for easy install on PY2 (frappe#937)
Browse files Browse the repository at this point in the history
* fix: compatibility for easy install on PY2

* test: remove python-distutils from travis

* chore: handle specific CalledProcessError for setuptools

Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
  • Loading branch information
gavindsouza and Thunderbottom authored Feb 27, 2020
1 parent d701fe8 commit 495a038
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install:
- sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1
- sudo apt-get purge -y mysql-common mysql-server mysql-client
- sudo apt-get install --only-upgrade -y git
- sudo apt-get install hhvm python-distutils && rm -rf /home/travis/.kiex/
- sudo apt-get install hhvm && rm -rf /home/travis/.kiex/
- mkdir -p ~/.bench
- mkdir -p /tmp/.bench
- cp -r $TRAVIS_BUILD_DIR/* ~/.bench
Expand Down
18 changes: 11 additions & 7 deletions playbooks/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,21 @@ def parse_commandline_args():

if __name__ == '__main__':
if sys.version[0] == '2':
try:
from disutils.spawn import find_executable
except ImportError:
print("Please install distutils or use Python3 to run the script")
print("$ pip install distutils")
sys.exit(1)
shutil.which = find_executable
if not os.environ.get('CI'):
if not raw_input("It is recommended to run this script with Python 3\nDo you still wish to continue? [Y/n]: ").lower() == "y":
sys.exit()

try:
from distutils.spawn import find_executable
except ImportError:
try:
subprocess.check_call('pip install --upgrade setuptools')
except subprocess.CalledProcessError:
print("Install distutils or use Python3 to run the script")
sys.exit(1)

shutil.which = find_executable

if not is_sudo_user():
log("Please run this script as a non-root user with sudo privileges", level=3)
sys.exit()
Expand Down

0 comments on commit 495a038

Please sign in to comment.