Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(install): Replace platform.dist with distro.linux_distribution for PY3.8+ compatibility #1017

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ffec2d5
Replace platform.dist() with distro.linux_distribution in install.py
nikunj1222 Jun 9, 2020
62542ee
Update install.py
nikunj1222 Jun 9, 2020
10a81cb
Update install.py
nikunj1222 Jun 9, 2020
f22ef15
resolving importing of distro module error.
nikunj1222 Jun 9, 2020
2b41380
Update install.py
nikunj1222 Jun 9, 2020
941385e
Update install.py
nikunj1222 Jun 9, 2020
54c8d52
Update install.py
nikunj1222 Jun 9, 2020
c511f14
Merge branch 'develop' into patch-1
nikunj1222 Jun 10, 2020
d7b5c5a
Update install.py
nikunj1222 Jun 10, 2020
6e2e7ff
Update install.py
nikunj1222 Jun 10, 2020
578eadc
Typo online 114
nikunj1222 Jun 10, 2020
1573e92
Line 116 included to return the current_dist value in case higher ver…
nikunj1222 Jun 10, 2020
90fab6a
Update install.py
nikunj1222 Jun 10, 2020
e7b67d2
Update install.py
nikunj1222 Jun 10, 2020
4da3821
Update install.py
nikunj1222 Jun 10, 2020
d7b9e7a
Update install.py
nikunj1222 Jun 11, 2020
5b1a17e
Update install.py
nikunj1222 Jun 11, 2020
464691f
Update install.py
nikunj1222 Jun 11, 2020
d291153
Update install.py
nikunj1222 Jun 11, 2020
715d935
Changed line 20
nikunj1222 Jun 11, 2020
4f04446
Update install.py
nikunj1222 Jun 11, 2020
e949fa4
Update install.py
nikunj1222 Jun 11, 2020
4f5fce6
Update install.py
nikunj1222 Jun 13, 2020
712d9b7
fix: install pip prior to py packages
gavindsouza Jun 15, 2020
926dddc
fix: update repo pkg list
gavindsouza Jun 15, 2020
8b2d219
fix: use sys version_info instead of version string
gavindsouza Jun 15, 2020
6ea3e7a
ci: Explicitly state usage of PY3
gavindsouza Jun 24, 2020
5f464e2
fix: use changed user home
gavindsouza Jun 24, 2020
58cc44f
Merge branch 'develop' into patch-1
gavindsouza Jul 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ matrix:
- 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
script: sudo -H python3 $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose

- 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
script: sudo -H python3 $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose

- name: "Python 3.8 Easy Install"
python: 3.8
env: TEST=easy_install
script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose
script: sudo -H python3 $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose

install:
- pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1
Expand Down
45 changes: 35 additions & 10 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import platform
import warnings
import datetime
import importlib


tmp_bench_repo = os.path.join('/', 'tmp', '.bench')
Expand All @@ -20,7 +21,8 @@
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

PY2 = sys.version_info.major == 2
PY3 = not PY2

def log(message, level=0):
levels = {
Expand All @@ -34,6 +36,16 @@ def log(message, level=0):
print(start + message + end)


def import_python_package(package):
try:
importlib.import_module(package)
except ImportError:
log("Installing {0}".format(package))
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
finally:
globals()[package] = importlib.import_module(package)


def setup_log_stream(args):
global log_stream
sys.stderr = sys.stdout
Expand Down Expand Up @@ -78,7 +90,7 @@ def check_distribution_compatibility():
dist_name, dist_version = get_distribution_info()
supported_dists = {
'macos': [10.9, 10.10, 10.11, 10.12],
'ubuntu': [14, 15, 16, 18, 19],
'ubuntu': [14, 15, 16, 18, 19, 20],
'debian': [8, 9],
'centos': [7]
}
Expand All @@ -96,13 +108,12 @@ def check_distribution_compatibility():

def get_distribution_info():
# return distribution name and major version
if platform.system() == "Linux":
current_dist = platform.dist()
return current_dist[0].lower(), current_dist[1].rsplit('.')[0]
if platform.system() == 'Linux':
return (distro.id(), distro.major_version())

elif platform.system() == "Darwin":
elif platform.system() == 'Darwin':
current_dist = platform.mac_ver()
return "macos", current_dist[0].rsplit('.', 1)[0]
return ('macos', current_dist[0].rsplit('.', 1)[0])


def run_os_command(command_map):
Expand All @@ -125,7 +136,6 @@ def install_prerequisites():
# pre-requisites for bench repo cloning
run_os_command({
'apt-get': [
'sudo apt-get update',
'sudo apt-get install -y git build-essential python3-setuptools python3-dev libffi-dev'
],
'yum': [
Expand All @@ -137,7 +147,6 @@ def install_prerequisites():
install_package('curl')
install_package('wget')
install_package('git')
install_package('pip3', 'python3-pip')

success = run_os_command({
'python3': "sudo -H python3 -m pip install --upgrade setuptools cryptography ansible==2.8.5 pip"
Expand Down Expand Up @@ -172,6 +181,17 @@ def install_package(package, package_name=None):
could_not_install(package)


def install_pip():
run_os_command({
'apt-get': 'sudo apt-get update',
'yum': 'sudo yum check-update'
})
if PY3:
install_package('pip3', 'python3-pip')
else:
install_package('pip2', 'python-pip')


def install_bench(args):
# clone bench repo
if not args.run_travis:
Expand Down Expand Up @@ -408,7 +428,7 @@ def parse_commandline_args():
return args

if __name__ == '__main__':
if sys.version[0] == '2':
if PY2:
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()
Expand All @@ -433,6 +453,11 @@ def parse_commandline_args():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
setup_log_stream(args)
install_pip()
# this could break if pip isnt installed with python to begin with
# specifically on Python 2 <=2.7.9 or Python 3 <=3.4
# refs: https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip
import_python_package('distro')
check_distribution_compatibility()
check_system_package_managers()
check_environment()
Expand Down