From fdfcf36e4ed32adbd26742bacd0c7b35b132d19b Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Thu, 12 Sep 2019 13:22:07 +0500 Subject: [PATCH] a --- app/helper.py | 92 +++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/app/helper.py b/app/helper.py index 4612d19..d4333f8 100644 --- a/app/helper.py +++ b/app/helper.py @@ -1,60 +1,60 @@ import subprocess as sp -import subprocess as sp -import requests +# import subprocess as sp +# import requests import json import os -from decouple import config +# from decouple import config # def install_available(pipfile): - """ Install Python packages or their dependencies mentioned in - pipfile if they are available in System repos - """ +# """ Install Python packages or their dependencies mentioned in +# pipfile if they are available in System repos +# """ - def is_available_in_system_repos(package): - try: - sp.check_output(['apk', 'info', f'py3-{package}']) - except: - return False - else: - return True +# def is_available_in_system_repos(package): +# try: +# sp.check_output(['apk', 'info', f'py3-{package}']) +# except: +# return False +# else: +# return True - if get_distro_name() == "alpine": - dependencies = [] +# if get_distro_name() == "alpine": +# dependencies = [] - need_to_be_installed = [] +# need_to_be_installed = [] - try: - with open(pipfile) as f: - lines = f.readlines() - try: - start_index = lines.index("[packages]\n") - end_index = lines.index("\n", start_index) - for package in lines[start_index: end_index]: - if '= "*"' in package: - package = package[:package.index(" =")] - if is_available_in_system_repos(package): - need_to_be_installed.append(f"py3-{package}") - else: - dependencies.append(package) - except ValueError: - print("Not Found") - except: - return - else: - for dependency in dependencies: - content = requests.get(f"https://libraries.io/api/pypi/{dependency}/latest/dependencies?api_key={config('LIBRARIES_IO_API')}") - content = json.loads(content.content.decode("utf-8")) - for subdependency in content["dependencies"]: - subdependency = subdependency["name"] - if is_available_in_system_repos(subdependency): - need_to_be_installed.append(f"py3-{subdependency}") +# try: +# with open(pipfile) as f: +# lines = f.readlines() +# try: +# start_index = lines.index("[packages]\n") +# end_index = lines.index("\n", start_index) +# for package in lines[start_index: end_index]: +# if '= "*"' in package: +# package = package[:package.index(" =")] +# if is_available_in_system_repos(package): +# need_to_be_installed.append(f"py3-{package}") +# else: +# dependencies.append(package) +# except ValueError: +# print("Not Found") +# except: +# return +# else: +# for dependency in dependencies: +# content = requests.get(f"https://libraries.io/api/pypi/{dependency}/latest/dependencies?api_key={config('LIBRARIES_IO_API')}") +# content = json.loads(content.content.decode("utf-8")) +# for subdependency in content["dependencies"]: +# subdependency = subdependency["name"] +# if is_available_in_system_repos(subdependency): +# need_to_be_installed.append(f"py3-{subdependency}") - for package in need_to_be_installed: - try: - sp.check_output(["apk", "add", package]) - except: - print(f"Could not install {package}") +# for package in need_to_be_installed: +# try: +# sp.check_output(["apk", "add", package]) +# except: +# print(f"Could not install {package}") def install_available(project_path): if get_distro_name() == "alpine":