For a given package, returns a list of required packages. Recursive.
184807
def get_deps_list(self, pkg_name, installed_distros=None):
        
        # https://github.com/Miserlou/Zappa/issues/1478.  Using `pkg_resources`
        # instead of `pip` is the recommended approach.  The usage is nearly
        # identical.
        import pkg_resources
        deps = []
        if not installed_distros:
            installed_distros = pkg_resources.WorkingSet()
        for package in installed_distros:
            if package.project_name.lower() == pkg_name.lower():
                deps = [(package.project_name, package.version)]
                for req in package.requires():
                    deps += self.get_deps_list(pkg_name=req.project_name, installed_distros=installed_distros)
        return list(set(deps))
395607
def parse_requirements_list(requirements_list):
    
    req_list = []

    for requirement in requirements_list:
        requirement_no_comments = requirement.split('#')[0].strip()

        # if matching requirement line (Thing==1.2.3), update dict, continue
        req_match = re.match(
            r'\s*(?P<package>[^\s\[\]]+)(?P<extras>\[\S+\])?==(?P<version>\S+)',
            requirement_no_comments
        )
        if req_match:
            req_list.append({
                'package': req_match.group('package'),
                'version': req_match.group('version'),
            })

    return req_list
202779
def requirements(fname):
        
        packages = Setup.read(fname, fail_silently=True).split('\n')
        packages = (p.strip() for p in packages)
        packages = (p for p in packages if p and not p.startswith('#'))
        return list(packages)
1112451
def get_modules(self):
        
        plugins = []
        for path in self.package.__path__:
            if os.path.isdir(path):
                plugins.extend(self._find_plugins_in_dir(path))

        return plugins
391936
def items(self) -> Tuple[Tuple[str, "Package"], ...]:  # type: ignore
        
        item_dict = {
            name: self.build_dependencies.get(name) for name in self.build_dependencies
        }
        return tuple(item_dict.items())
524544
def list_modules(root_package = 'vlcp'):
    '''
    
    '''
    pkg = __import__(root_package, fromlist=['_'])
    module_dict = OrderedDict()
    _server = Server()
    for imp, module, _ in walk_packages(pkg.__path__, root_package + '.'):
        m = __import__(module, fromlist = ['_'])
        for name, v in vars(m).items():
            if v is not None and isinstance(v, type) and issubclass(v, Module) \
                    and v is not Module \
                    and not isinstance(v, _ProxyModule) \
                    and hasattr(v, '__dict__') and 'configkey' in v.__dict__ \
                    and v.__module__ == module:
                module_name = v.__name__.lower()
                if module_name not in module_dict:
                    _inst = v(_server)
                    module_info = OrderedDict((('class', v.__module__ + '.' + v.__name__),
                                                ('dependencies', [d.__name__.lower()
                                                                  for d in v.depends]),
                                                ('classdescription', getdoc(v)),
                                                ('apis', [])))
                    if hasattr(_inst, 'apiHandler'):
                        apidefs = _inst.apiHandler.apidefs
                        module_info['apis'] = [(d[0], d[3])
                                               for d in apidefs
                                               if len(d) > 3 and \
                                               not d[0].startswith('public/')]
                    module_dict[module_name] = module_info
    return module_dict
1149281
function packRequirements() {
  if (this.options.zip) {
    if (this.serverless.service.package.individually) {
      return BbPromise.resolve(this.targetFuncs)
        .map(f => {
          if (!get(f, 'module')) {
            set(f, ['module'], '.');
          }
          return f;
        })
        .then(funcs => uniqBy(funcs, f => f.module))
        .map(f => {
          this.serverless.cli.log(
            `Zipping required Python packages for ${f.module}...`
          );
          f.package.include.push(`${f.module}/.requirements.zip`);
          return addTree(
            new JSZip(),
            `.serverless/${f.module}/requirements`
          ).then(zip => writeZip(zip, `${f.module}/.requirements.zip`));
        });
    } else {
      this.serverless.cli.log('Zipping required Python packages...');
      this.serverless.service.package.include.push('.requirements.zip');
      return addTree(new JSZip(), '.serverless/requirements').then(zip =>
        writeZip(zip, path.join(this.servicePath, '.requirements.zip'))
      );
    }
  }
}
962446
public Set<Class<?>> getPackageAllClasses(String basePackage,
                                              boolean recursive) {
        Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
        String packageName = basePackage;
        if (packageName.endsWith(".")) {
            packageName = packageName
                    .substring(0, packageName.lastIndexOf('.'));
        }
        String package2Path = packageName.replace('.', '/');

        Enumeration<URL> dirs;
        try {
            dirs = Thread.currentThread().getContextClassLoader().getResources(
                    package2Path);
            while (dirs.hasMoreElements()) {
                URL url = dirs.nextElement();
                String protocol = url.getProtocol();
                if ("file".equals(protocol)) {
                    String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
                    doScanPackageClassesByFile(classes, packageName, filePath, recursive);
                } else if ("jar".equals(protocol)) {
                    doScanPackageClassesByJar(packageName, url, recursive, classes);
                }
            }
        } catch (IOException e) {
            throw new LtsRuntimeException(e);
        }
        return classes;
    }
509407
def package_list(cls, options=None):
        
        options = options or {}
        try:
            return cls.safe_call('cert.package.list', options)
        except UsageError as err:
            if err.code == 150020:
                return []
            raise
1196823
private List<PackageSummary> summaryPackages() {
		Map<String, PackageSummary> summaries = new HashMap<>();

		coverages.forEach((name, c) -> {
			Path p = Paths.get(name).getParent();
			String pkg = p != null ? p.toString().replace(File.separatorChar, '.') : "_root_";
			PackageSummary summary = summaries.computeIfAbsent(pkg, k -> new PackageSummary(pkg));
			summary.coverageInfos.addAll(c.values());
		});
		return summaries.values().stream().sorted(Comparator.comparing(p -> p.packagePath))
				.collect(Collectors.toList());

	}
341990
def needs_packages(*packages):
    '''
    '''
    def real_decorator(func):

        @wraps(func)
        def wrapper(*args, **kwargs):
            non_installed = _non_installed(packages)
            if non_installed:
                what_for = 'in order to run this task'
                install_packages(non_installed, what_for=what_for)
            return func(*args, **kwargs)

        return wrapper

    return real_decorator
79811
def get_dep_names_of_package(
        package,
        keep_version_pins=False,
        recursive=False,
        verbose=False,
        include_build_requirements=False
        ):
    

    # First, obtain the dependencies:
    dependencies = get_package_dependencies(
        package, recursive=recursive, verbose=verbose,
        include_build_requirements=include_build_requirements,
    )
    if verbose:
        print("get_dep_names_of_package_folder: " +
              "processing dependency list to names: " +
              str(dependencies))

    # Transform dependencies to their stripped down names:
    # (they can still have version pins/restrictions, conditionals, ...)
    dependency_names = set()
    for dep in dependencies:
        # If we are supposed to keep exact version pins, extract first:
        pin_to_append = ""
        if keep_version_pins and "(==" in dep and dep.endswith(")"):
            # This is a dependency of the format: 'pkg (==1.0)'
            pin_to_append = "==" + dep.rpartition("==")[2][:-1]
        elif keep_version_pins and "==" in dep and not dep.endswith(")"):
            # This is a dependency of the format: 'pkg==1.0'
            pin_to_append = "==" + dep.rpartition("==")[2]
        # Now get true (and e.g. case-corrected) dependency name:
        dep_name = get_package_name(dep) + pin_to_append
        dependency_names.add(dep_name)
    return dependency_names
625669
def nearest_subpackage(cls, package, all_packages):
    """"""
    def shared_prefix(candidate):
      zipped = zip(package.split('.'), candidate.split('.'))
      matching = itertools.takewhile(lambda pair: pair[0] == pair[1], zipped)
      return [pair[0] for pair in matching]
    shared_packages = [_f for _f in map(shared_prefix, all_packages) if _f]
    return '.'.join(max(shared_packages, key=len)) if shared_packages else package
121639
function getPackagesTasks(baseTask) {
	var packages = getPackages();
	var tasks = [];

	for (index = 0; index < packages.length; ++index) {
	    tasks.push(baseTask + '.' + packages[index]);
	}

	return tasks;
}
1033742
def package_files(directory):
    """"""
    paths = []
    for (path, _, file_names) in walk(directory):
        for filename in file_names:
            paths.append(join('..', path, filename))
    return paths
1333532
def parse_reqs(req_path='./requirements/requirements.txt'):
    """"""
    install_requires = []
    with codecs.open(req_path, 'r') as handle:
        # remove comments and empty lines
        lines = (line.strip() for line in handle
                 if line.strip() and not line.startswith('#'))

        for line in lines:
            # check for nested requirements files
            if line.startswith('-r'):
                # recursively call this function
                install_requires += parse_reqs(req_path=line[3:])
            else:
                # add the line as a new requirement
                install_requires.append(line)

    return install_requires
1062630
public static List<Class<?>> scanPackage(String... packages) throws IOException, ClassNotFoundException {
        List<Class<?>> list = new ArrayList<>();
        for (String pkg : packages) {
            list.addAll(getClasses(pkg));
        }
        return list;
    }