Get the package_dir dictionary from source
        :return:
178405
def extract_package_dir(self):  # type: () -> Optional[str]
        
        # package_dir={'': 'lib'},
        source = self.setup_py_source()
        if not source:
            # this happens when the setup.py file is missing
            return None

        # sometime
        # 'package_dir'      : {'': 'src'},
        # sometimes
        # package_dir={...}
        if "package_dir=" in source:
            line = source.replace("\n", "")
            line = line.split("package_dir")[1]
            fixed = ""
            for char in line:
                fixed += char
                if char == "}":
                    break
            line = fixed

            simplified_line = line.strip(" ,").replace("'", '"')

            parts = simplified_line.split("=")

            dict_src = parts[1].strip(" \t")
            if not dict_src.endswith("}"):
                raise JiggleVersionException(
                    "Either this is hard to parse or we have 2+ src foldrs"
                )
            try:
                paths_dict = ast.literal_eval(dict_src)
            except ValueError as ve:
                logger.error(source + ": " + dict_src)
                return ""

            if "" in paths_dict:
                candidate = paths_dict[""]
                if os.path.isdir(candidate):
                    return unicode(candidate)
            if len(paths_dict) == 1:
                candidate = first_value_in_dict(paths_dict)
                if os.path.isdir(candidate):
                    return unicode(candidate)
            else:
                raise JiggleVersionException(
                    "Have path_dict, but has more than one path."
                )
        return None
1278945
def get_url_map():
    
    map = {}
    path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),  # current working dir ../
        "custom",  # ../custom/
        "pypi",  # ../custom/pypi/
        "map.txt"  # ../custom/pypi/map.txt
    )
    with open(path) as f:
        for line in f.readlines():
            package, url = line.strip().split(": ")
            map[package] = url
    return map
1021980
def name_from_setup_py(self):  # type: () -> str
        
        source = self.setup_py_source()
        if not source:
            return ""
        for row in source.split("\n"):
            #
            if "packages=" in row:
                simplified_row = row.replace(" ", "").replace("'", '"').strip(" \t\n")
                if '"' in simplified_row:
                    return simplified_row.split('"')[1]

            if "name=" in row:
                simplified_row = row.replace(" ", "").replace("'", '"').strip(" \t\n")
                if '"' in simplified_row:
                    return simplified_row.split('"')[1]
        return ""
880811
def _get_packages():
    # type: () -> List[Package]
    
    return [Package(pkg_obj=pkg) for pkg in sorted(pkg_resources.working_set,
                                                   key=lambda x: str(x).lower())]
489673
def build_dirs(self):
        

        arch = self.arch_name()

        build_path = os.path.join('build', arch)
        output = os.path.join('build', 'output')
        test = os.path.join('build', 'test', arch)

        return {'build': build_path, 'output': output, 'test': test}
276779
def _find_pkg_info(self):
        
        dist = pkg_resources.require(self.package_name)[0]
        self._pkg_resources_locations = [dist.location]
        ver, url = self._dist_version_url(dist)
        return {'version': ver, 'url': url}
778299
def getPrefixDirectories(self, engineRoot, delimiter=' '):
		
		return delimiter.join(self.resolveRoot(self.prefixDirs, engineRoot))
714293
def get_package_data(name, extlist):
    """"""
    flist = []
    # Workaround to replace os.path.relpath (not available until Python 2.6):
    offset = len(name)+len(os.pathsep)
    for dirpath, _dirnames, filenames in os.walk(name):
        for fname in filenames:
            if not fname.startswith('.') and osp.splitext(fname)[1] in extlist:
                flist.append(osp.join(dirpath, fname)[offset:])
    return flist
551957
def get_source_folders(self):
        """"""
        if self.root is None:
            return []
        result = list(self._custom_source_folders)
        result.extend(self.pycore._find_source_folders(self.root))
        return result
907633
def get_package_filename(filename, package_dir=None):
    ''''''
    if getattr(sys, 'frozen', False):
        package_dir = os.path.join(
            sys._MEIPASS,
            os.path.basename(os.path.dirname(__file__))
        )
    elif not package_dir:
        package_dir = os.path.dirname(__file__)

    return os.path.join(package_dir, filename)
562393
def __get_cfg_pkgs_dpkg(self):
        '''
        
        '''
        # Get list of all available packages
        data = dict()

        for pkg_name in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None,
                                                        '-Wf', "${binary:Package}\\n")[0]).split(os.linesep):
            pkg_name = pkg_name.strip()
            if not pkg_name:
                continue
            data[pkg_name] = list()
            for pkg_cfg_item in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None, '-Wf', "${Conffiles}\\n",
                                                                pkg_name)[0]).split(os.linesep):
                pkg_cfg_item = pkg_cfg_item.strip()
                if not pkg_cfg_item:
                    continue
                pkg_cfg_file, pkg_cfg_sum = pkg_cfg_item.strip().split(" ", 1)
                data[pkg_name].append(pkg_cfg_file)

            # Dpkg meta data is unreliable. Check every package
            # and remove which actually does not have config files.
            if not data[pkg_name]:
                data.pop(pkg_name)

        return data
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
1008599
def charm_dir():
    """"""
    d = os.environ.get('JUJU_CHARM_DIR')
    if d is not None:
        return d
    return os.environ.get('CHARM_DIR')
167389
def _get_installer_paths(self, base):
    
    return {
      'purelib': base,
      'headers': os.path.join(base, 'headers'),
      'scripts': os.path.join(base, 'bin'),
      'platlib': base,
      'data': base
    }
1261912
def resource_path(package_name: str, relative_path: typing.Union[str, Path]) -> Path:
    
    relative_path = Path(relative_path)
    methods = [
        _get_from_dev,
        _get_from_package,
        _get_from_sys,
    ]
    for method in methods:
        path = method(package_name, relative_path)
        if path.exists():
            return path

    raise FileNotFoundError(relative_path)
722599
def get_dist(dist_name, lookup_dirs=None):
    
    # note: based on pip/utils/__init__.py, get_installed_version(...)

    # Create a requirement that we'll look for inside of setuptools.
    req = pkg_resources.Requirement.parse(dist_name)

    # We want to avoid having this cached, so we need to construct a new
    # working set each time.
    if lookup_dirs is None:
        working_set = pkg_resources.WorkingSet()
    else:
        working_set = pkg_resources.WorkingSet(lookup_dirs)

    # Get the installed distribution from our working set
    return working_set.find(req)
1026923
def _get_template_dirs():
    """"""
    return filter(lambda x: os.path.exists(x), [
        # user dir
        os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
        # system wide dir
        os.path.join('/', 'usr', 'share', 'py2pack', 'templates'),
        # usually inside the site-packages dir
        os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'),
    ])