def create_dependencies_tree_by_req_file_path(requirements_file_path, allow_missing=False, dev_deps=False): # get all installed packages pkgs = get_installed_distributions(local_only=False, skip=[]) # get all installed packages's distribution object dist_index = utils.build_dist_index(pkgs) # get all installed distributions tree dist_tree = utils.construct_tree(dist_index) # create a list of dependencies from the dependencies file required = get_requirements_list(requirements_file_path, dev_deps=dev_deps) installed = [p for p in dist_index] packages = [] for r in required: if r.lower() not in installed: msg = 'Required package missing: ' + r.lower() if allow_missing: sys.stderr.write(msg + "\n") else: sys.exit(msg) else: packages.append(r) # build a tree of dependencies package_tree = create_tree_of_packages_dependencies( dist_tree, packages, requirements_file_path, allow_missing) print(json.dumps(package_tree))
def create_dependencies_tree_by_req_file_path(requirements_file_path, allow_missing=False): # get all installed packages pkgs = pip.get_installed_distributions(local_only=False, skip=[]) # get all installed packages's distribution object dist_index = utils.build_dist_index(pkgs) # get all installed distributions tree dist_tree = utils.construct_tree(dist_index) # open the requirements.txt file and create dependencies tree out of it with open(requirements_file_path, 'r') as requirements_file: required = get_requirements_list(requirements_file) installed = [p for p in dist_index] packages = [] for r in required: if r.lower() not in installed: msg = 'Required package missing: ' + r.lower() if allow_missing: sys.stderr.write(msg + "\n") else: sys.exit(msg) else: packages.append(r); package_tree = create_tree_of_packages_dependencies( dist_tree, packages, requirements_file_path, allow_missing) print(json.dumps(package_tree))
def create_dependencies_tree_by_req_file_path(requirements_file_path, allow_missing=False): # get all installed packages pkgs = pip.get_installed_distributions(local_only=False, skip=[]) # get all installed packages's distribution object dist_index = utils.build_dist_index(pkgs) # get all installed distributions tree dist_tree = utils.construct_tree(dist_index) # open the requirements.txt file and create dependencies tree out of it with open(requirements_file_path, 'r') as requirements_file: required = get_requirements_list(requirements_file) installed = [p for p in dist_index] packages = [] for r in required: if r.lower() not in installed: msg = 'Required package missing: ' + r.lower() if allow_missing: sys.stderr.write(msg + "\n") else: sys.exit(msg) else: packages.append(r) package_tree = create_tree_of_packages_dependencies( dist_tree, packages, requirements_file_path, allow_missing) print(json.dumps(package_tree))
def create_dependencies_tree_by_req_file_path(requirements_file_path): # get all installed packages pkgs = pip.get_installed_distributions(local_only=False, skip=[]) # get all installed packages's distribution object dist_index = utils.build_dist_index(pkgs) # get all installed distributions tree dist_tree = utils.construct_tree(dist_index) # open the requirements.txt file and create dependencies tree out of it with open(requirements_file_path, 'r') as requirements_file: req_list = list(requirements.parse(requirements_file)) required = [req.name for req in req_list] installed = [p for p in dist_index] for r in required: if r.lower() not in installed: sys.exit('Required package missing') package_tree = create_tree_of_packages_dependencies( dist_tree, [req.name for req in req_list], requirements_file_path) print(json.dumps(package_tree))
def create_dependencies_tree_by_req_file_path(requirements_file_path, allow_missing=False, dev_deps=False, only_provenance=False): # get all installed packages pkgs = list(pkg_resources.working_set) # get all installed packages's distribution object dist_index = utils.build_dist_index(pkgs) # get all installed distributions tree dist_tree = utils.construct_tree(dist_index) # create a list of dependencies from the dependencies file required = get_requirements_list(requirements_file_path, dev_deps=dev_deps) if not required: msg = 'No dependencies detected in manifest.' sys.exit(msg) else: installed = [canonicalize_package_name(p) for p in dist_index] top_level_requirements = [] missing_package_names = [] for r in required: if canonicalize_package_name(r.name) not in installed: missing_package_names.append(r.name) else: top_level_requirements.append(r) if missing_package_names: msg = 'Required packages missing: ' + ( ', '.join(missing_package_names)) if allow_missing: sys.stderr.write(msg + "\n") else: sys.exit(msg) # build a tree of dependencies package_tree = create_tree_of_packages_dependencies( dist_tree, top_level_requirements, requirements_file_path, allow_missing, only_provenance) print(json.dumps(package_tree))