Find all of mdtraj's python packages.
    Adapted from IPython's setupbase.py. Copyright IPython
    contributors, licensed under the BSD license.
480010
def find_packages():
    
    packages = ['mdtraj.scripts']
    for dir,subdirs,files in os.walk('MDTraj'):
        package = dir.replace(os.path.sep, '.')
        if '__init__.py' not in files:
            # not a package
            continue
        packages.append(package.replace('MDTraj', 'mdtraj'))
    return packages
576592
def get_modules(pkg_name, module_filter = None):
    
    path = app_path(pkg_name)
    #py_filter = lambda f: all((fnmatch(f, "*.py"), not f.startswith("__"), module_filter and module_filter(f) or True))
    py_filter = lambda f: all((fnmatch(f, "*.pyc") or fnmatch(f, "*.py"), not f.startswith("__"), module_filter and module_filter(f) or True))
    names = [splitext(n)[0] for n in os.listdir(path) if py_filter(n)]
    return [__import__("{0}.{1}".format(pkg_name, n)).__dict__[n] for n in names]
98265
def hack_find_packages(include_str):
    
    new_list = [include_str]
    for element in find_packages(include_str):
        new_list.append(include_str + '.' + element)

    return new_list
23084
def find_packages(path: str) -> List[str]:
    
    for root, _dir, files in os.walk(path):
        if '__init__.py' in files:
            yield root.replace("/", ".")
794213
def build_pypackage_basename(self, pytree, base):
        
        dirname = os.path.dirname(pytree)
        parsed_package_name = base.replace(dirname, '').strip('/')
        return parsed_package_name
1340894
def getPackages(self, distribution = "rawhide"):
		
		if self._packages == {}:
			file_location = "%s/data/distribution_packages.json" % getScriptDir(__file__)
			with open(file_location, "r") as f:
				packages = json.load(f)
			for pkg in packages:
				for distro in pkg["distributions"]:
					try:
						self._packages[distro].append(pkg["package"])
					except KeyError:
						self._packages[distro] = [pkg["package"]]

		return self._packages[distribution]
117688
def _get_all_packages(mirror=DEFAULT_MIRROR,
                      cyg_arch='x86_64'):
    '''
    
    '''
    if 'cyg.all_packages' not in __context__:
        __context__['cyg.all_packages'] = {}
    if mirror not in __context__['cyg.all_packages']:
        __context__['cyg.all_packages'][mirror] = []
    if not __context__['cyg.all_packages'][mirror]:
        pkg_source = '/'.join([mirror, cyg_arch, 'setup.bz2'])

        file_data = _urlopen(pkg_source).read()
        file_lines = bz2.decompress(file_data).decode('utf_8',
                                                      errors='replace'
                                                     ).splitlines()

        packages = [re.search('^@ ([^ ]+)', line).group(1) for
                    line in file_lines if re.match('^@ [^ ]+', line)]

        __context__['cyg.all_packages'][mirror] = packages

    return __context__['cyg.all_packages'][mirror]
976
def _build_package_finder(self, options, index_urls):
        
        return PackageFinder(find_links=options.find_links,
                             index_urls=index_urls,
                             use_mirrors=options.use_mirrors,
                             mirrors=options.mirrors)
104344
def find_packages(recursive=True, maxdepth=None):
    
    import utool
    if utool.VERBOSE:
        print('[util_setup] find_packages(recursive=%r, maxdepth=%r)' % (recursive, maxdepth))
    from os.path import relpath
    cwd = os.getcwd()
    init_files = utool.glob(cwd, '__init__.py', recursive=recursive, maxdepth=maxdepth)
    package_paths = list(map(dirname, init_files))
    package_relpaths = [relpath(path, cwd) for path in package_paths]

    packages = []
    for path in package_relpaths:
        base = utool.dirsplit(path)[0]
        if exists(join(base, '__init__.py')):
            package = path.replace('/', '.').replace('\\', '.')
            packages.append(package)
    return packages
1290359
def _GetPkgResources(package_name, filepath):
  """"""
  requirement = pkg_resources.Requirement.parse(package_name)
  try:
    return pkg_resources.resource_filename(requirement, filepath)
  except pkg_resources.DistributionNotFound:
    # It may be that the working set is not in sync (e.g. if sys.path was
    # manipulated). Try to reload it just in case.
    pkg_resources.working_set = pkg_resources.WorkingSet()
    try:
      return pkg_resources.resource_filename(requirement, filepath)
    except pkg_resources.DistributionNotFound:
      logging.error("Distribution %s not found. Is it installed?", package_name)
      return None
1359197
def installed_packages(self):
        
        freeze_options = ['-l', '--all'] if self.pip_version >= (8, 1, 0) else ['-l']
        return list(map(split_package_name, filter(None, self._execute_pip(
                ['freeze'] + freeze_options).split(linesep))))
1319520
def trace_toolchain(toolchain):
    

    pkgs = []
    for cls in getmro(type(toolchain)):
        if not issubclass(cls, Toolchain):
            continue
        dist = _cls_lookup_dist(cls)
        value = {
            'project_name': dist.project_name,
            'version': dist.version,
        } if dist else {}
        key = '%s:%s' % (cls.__module__, cls.__name__)
        pkgs.append({key: value})
    return pkgs
542660
def get_packages():
    

    packages = find_packages(exclude=['tests'])
    packages.append('')
    packages.append('js')
    packages.append(LOCALES_DIRECTORY)

    for directory in os.listdir(LOCALES_DIRECTORY):
        packages.append(LOCALES_DIRECTORY + '.' + directory)
    return packages
33378
def find_csv_packages(m, downloader):
    """"""
    from metapack.package import CsvPackageBuilder

    pkg_dir = m.package_root
    name = m.doc.get_value('Root.Name')

    package_path, cache_path = CsvPackageBuilder.make_package_path(pkg_dir, name)

    if package_path.exists():
        return open_package(package_path, downloader=downloader)
234380
def find_vext_files(self):
        
        packages = self.depends_on("vext")
        vext_files = []
        for location in [package.get("location") for package in packages]:
            if not location:
                continue
            vext_files.extend(glob(join(location, "*.vext")))
        return vext_files
1347918
def find(self, package, **kwargs):
        
        if not exists(package):
            return None
        name, path = None, None
        enforce_init = kwargs.pop('enforce_init', True)
        if isdir(package):
            if isfile(join(package, '__init__.py')) or not enforce_init:
                name, path = basename(package), package
        elif isfile(package) and package.endswith('.py'):
            name, path = splitext(basename(package))[0], package
        if name and path:
            return PackageSpec(name, path)
        return None
869832
def pip(usr_pswd=None):
	
	# see if pip is installed
	try: cmd('which pip')
	except:
		return

	print('-[pip]----------')
	p = cmd('pip list --outdated')
	if not p: return
	pkgs = getPackages(p)

	# update pip and setuptools first
	for i, p in enumerate(pkgs):
		if p in ['pip', 'setuptools']:
			cmd('pip install -U ' + p, usr_pwd=usr_pswd, run=global_run)
			pkgs.pop(i)

	# update the rest of them
	for p in pkgs:
		cmd('pip install -U ' + p, usr_pwd=usr_pswd, run=global_run)