Returns the full path to the default package configuration file.

    Args:
    package (str): name of the python package to return a path for.
543342
def _package_path(package):
    
    from os import path
    confdir = config_dir()
    return path.join(confdir, "{}.cfg".format(package))
1284462
def _import_module(name, package=None):
    
    if name.startswith('.'):
        name = '{package}.{module}'.format(package=package, module=str(name).strip('.'))
    __import__(name)
    return sys.modules[name]
1157406
def list_config(root_package = 'vlcp'):
    '''
    
    '''
    pkg = __import__(root_package, fromlist=['_'])
    return_dict = OrderedDict()
    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, Configurable) \
                    and v is not Configurable \
                    and hasattr(v, '__dict__') and 'configkey' in v.__dict__ \
                    and v.__module__ == module:
                configkey = v.__dict__['configkey']
                if configkey not in return_dict:
                    configs = OrderedDict()
                    v2 = v
                    parents = [v2]
                    while True:
                        parent = None
                        for c in v2.__bases__:
                            if issubclass(c, Configurable):
                                parent = c
                        if parent is None or parent is Configurable:
                            break
                        if hasattr(parent, '__dict__') and 'configkey' not in parent.__dict__:
                            parents.append(parent)
                            v2 = parent
                        else:
                            break
                    for v2 in reversed(parents):
                        tmp_configs = {}
                        for k, default_value in v2.__dict__.items():
                            if k.startswith('_default_'):
                                config_attr = k[len('_default_'):]
                                if config_attr in v.__dict__:
                                    continue
                                configname = configkey + '.' + config_attr
                                tmp_configs.setdefault(configname, OrderedDict())['default'] = \
                                    pformat(default_value, width=10)
                        # Inspect the source lines to find remarks for these configurations
                        lines, _ = getsourcelines(v2)
                        last_remark = []
                        for l in lines:
                            l = l.strip()
                            if not l:
                                continue
                            if l.startswith('#'):
                                last_remark.append(l[1:])
                            else:
                                if l.startswith('_default_'):
                                    key, sep, _ = l.partition('=')
                                    if sep and key.startswith('_default_'):
                                        configname = configkey + '.' +  key[len('_default_'):].strip()
                                        if configname in tmp_configs and configname not in configs:
                                            configs[configname] = tmp_configs.pop(configname)
                                        if configname in configs and last_remark:
                                            configs[configname]['description'] = cleandoc('\n' + '\n'.join(last_remark))
                                del last_remark[:]
                        for key in tmp_configs:
                            if key not in configs:
                                configs[key] = tmp_configs[key]
                    if configs:
                        return_dict[configkey] = OrderedDict((('class', v.__module__ + '.' + name),
                                                             ('classdescription', getdoc(v)),
                                                             ('configs', configs)))
    return return_dict
1253911
def Package(env, target=None, source=None, **kw):
    
    # check if we need to find the source files ourself
    if not source:
        source = env.FindInstalledFiles()

    if len(source)==0:
        raise UserError("No source for Package() given")

    # decide which types of packages shall be built. Can be defined through
    # four mechanisms: command line argument, keyword argument,
    # environment argument and default selection( zip or tar.gz ) in that
    # order.
    try: kw['PACKAGETYPE']=env['PACKAGETYPE']
    except KeyError: pass

    if not kw.get('PACKAGETYPE'):
        from SCons.Script import GetOption
        kw['PACKAGETYPE'] = GetOption('package_type')

    if kw['PACKAGETYPE'] == None:
        if 'Tar' in env['BUILDERS']:
            kw['PACKAGETYPE']='targz'
        elif 'Zip' in env['BUILDERS']:
            kw['PACKAGETYPE']='zip'
        else:
            raise UserError("No type for Package() given")

    PACKAGETYPE=kw['PACKAGETYPE']
    if not is_List(PACKAGETYPE):
        PACKAGETYPE=PACKAGETYPE.split(',')

    # load the needed packagers.
    def load_packager(type):
        try:
            file,path,desc=imp.find_module(type, __path__)
            return imp.load_module(type, file, path, desc)
        except ImportError as e:
            raise EnvironmentError("packager %s not available: %s"%(type,str(e)))

    packagers=list(map(load_packager, PACKAGETYPE))

    # set up targets and the PACKAGEROOT
    try:
        # fill up the target list with a default target name until the PACKAGETYPE
        # list is of the same size as the target list.
        if not target: target = []

        size_diff      = len(PACKAGETYPE)-len(target)
        default_name   = "%(NAME)s-%(VERSION)s"

        if size_diff>0:
            default_target = default_name%kw
            target.extend( [default_target]*size_diff )

        if 'PACKAGEROOT' not in kw:
            kw['PACKAGEROOT'] = default_name%kw

    except KeyError as e:
        raise SCons.Errors.UserError( "Missing Packagetag '%s'"%e.args[0] )

    # setup the source files
    source=env.arg2nodes(source, env.fs.Entry)

    # call the packager to setup the dependencies.
    targets=[]
    try:
        for packager in packagers:
            t=[target.pop(0)]
            t=packager.package(env,t,source, **kw)
            targets.extend(t)

        assert( len(target) == 0 )

    except KeyError as e:
        raise SCons.Errors.UserError( "Missing Packagetag '%s' for %s packager"\
                                      % (e.args[0],packager.__name__) )
    except TypeError as e:
        # this exception means that a needed argument for the packager is
        # missing. As our packagers get their "tags" as named function
        # arguments we need to find out which one is missing.
        from inspect import getargspec
        args,varargs,varkw,defaults=getargspec(packager.package)
        if defaults!=None:
            args=args[:-len(defaults)] # throw away arguments with default values
        args.remove('env')
        args.remove('target')
        args.remove('source')
        # now remove any args for which we have a value in kw.
        args=[x for x in args if x not in kw]

        if len(args)==0:
            raise # must be a different error, so re-raise
        elif len(args)==1:
            raise SCons.Errors.UserError( "Missing Packagetag '%s' for %s packager"\
                                          % (args[0],packager.__name__) )
        else:
            raise SCons.Errors.UserError( "Missing Packagetags '%s' for %s packager"\
                                          % (", ".join(args),packager.__name__) )

    target=env.arg2nodes(target, env.fs.Entry)
    targets.extend(env.Alias( 'package', targets ))
    return targets
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)
987017
def default(cls, package):
        
        core_properties_part = cls._new(package)
        core_properties = core_properties_part.core_properties
        core_properties.title = 'Word Document'
        core_properties.last_modified_by = 'python-docx'
        core_properties.revision = 1
        core_properties.modified = datetime.utcnow()
        return core_properties_part
712483
def _get_package_name(module):
    
    try:
        # if __package__ is defined, use it
        package_name = module.__package__
    except AttributeError:
        package_name = None  
        
    if package_name is None:
        # if __path__ is defined, the package name is the module name
        package_name = module.__name__
        if not hasattr(module, '__path__'):
            # if __path__ is not defined, the package name is the
            # string before the last "." of the fully-qualified module name
            package_name = package_name.rpartition('.')[0]
           
    return package_name
508285
def import_modules_from_package(package):
    
    path = [os.path.dirname(__file__), '..'] + package.split('.')
    path = os.path.join(*path)
    for root, dirs, files in os.walk(path):
        for filename in files:
            if filename.startswith('__') or not filename.endswith('.py'):
                continue
            new_package = ".".join(root.split(os.sep)).split("....")[1]
            module_name = '%s.%s' % (new_package, filename[:-3])
            if module_name not in sys.modules:
                __import__(module_name)
1220875
def default_config_file(self):
        
        import os.path as p
        import pyemma
        return p.join(pyemma.__path__[0], Config.DEFAULT_CONFIG_FILE_NAME)
357165
def via_find_packages(self):  # type: () -> List[str]
        
        packages = []  # type: List[str]
        source = self.setup_py_source()
        if not source:
            return packages
        find_package_args = ""
        for row in source.split("\n"):
            if "find_packages" in row:
                logger.debug(row)
                if "find_packages()" in row:
                    packages = find_packages()
                else:
                    try:

                        find_package_args_source = row.split("(")[1].split(")")[0]
                        find_package_args = ast.literal_eval(find_package_args_source)
                        logger.debug(packages)
                    except:
                        logger.debug(source)
                        # raise
        if not find_package_args:
            packages = find_packages()
        else:
            try:
                # signature find(cls, where='.', exclude=(), include=('*',)):
                packages = find_packages(find_package_args)
            except:
                packages = find_packages()

        return packages
154227
def get_package_dir(nb_path):
    
    doc = get_metatab_doc(nb_path)
    doc.update_name(force=True, create_term=True)
    pkg_name = doc['Root'].get_value('Root.Name')
    assert pkg_name

    return ensure_source_package_dir(nb_path, pkg_name), pkg_name
478821
def package_url(self):
        """"""

        if self.resource_file == DEFAULT_METATAB_FILE or self.target_format in ('txt','ipynb'):
            u = self.inner.clone().clear_fragment()
            u.path = dirname(self.path) + '/'
            u.scheme_extension = 'metapack'
        else:
            u = self

        return MetapackPackageUrl(str(u.clear_fragment()), downloader=self._downloader)
144804
def finder(package):
    
    if package in _finder_cache:
        result = _finder_cache[package]
    else:
        if package not in sys.modules:
            __import__(package)
        module = sys.modules[package]
        path = getattr(module, '__path__', None)
        if path is None:
            raise DistlibException('You cannot get a finder for a module, '
                                   'only for a package')
        loader = getattr(module, '__loader__', None)
        finder_maker = _finder_registry.get(type(loader))
        if finder_maker is None:
            raise DistlibException('Unable to locate finder for %r' % package)
        result = finder_maker(module)
        _finder_cache[package] = result
    return result
476706
def get_module_name(package):
    
    distribution = get_distribution(package.DISTRIBUTION_NAME)
    entry_info = distribution.get_entry_info(package.DIST_GROUP, package.ENTRY_POINT)
    if not entry_info:
        raise RuntimeError(
            "Can't find entry info for distribution: %r (group: %r, entry point: %r)" % (
                package.DISTRIBUTION_NAME, package.DIST_GROUP, package.ENTRY_POINT
            )
        )
    return entry_info.module_name
789262
private static Path getConfigFilePath(Path projectPath) {
        String pathString = SystemProperty.CONFIGURATION_FILE.value();
        Path path;
        if (pathString == null) {
            path = DEFAULT_CONFIG_FILE;
        } else {
            path = Paths.get(pathString);
        }
        return projectPath.resolve(path);
    }
163026
def find_package(name: str) -> Tuple[Optional[Path], Path]:
    
    module = name.split(".")[0]
    loader = pkgutil.get_loader(module)
    if name == "__main__" or loader is None:
        package_path = Path.cwd()
    else:
        if hasattr(loader, 'get_filename'):
            filename = loader.get_filename(module)  # type: ignore
        else:
            __import__(name)
            filename = sys.modules[name].__file__
        package_path = Path(filename).resolve().parent
        if hasattr(loader, 'is_package'):
            is_package = loader.is_package(module)  # type: ignore
            if is_package:
                package_path = Path(package_path).resolve().parent
    sys_prefix = Path(sys.prefix).resolve()
    try:
        package_path.relative_to(sys_prefix)
    except ValueError:
        return None, package_path
    else:
        return sys_prefix, package_path
741319
def fetch_local_package(self, config):
        
        # Update sys.path & merge in remote configs (if necessary)
        self.update_paths_and_config(config=config,
                                     pkg_dir_name=config['source'],
                                     pkg_cache_dir=os.getcwd())