当前位置: 首页>>代码示例>>Python>>正文


Python site.getsitepackages方法代码示例

本文整理汇总了Python中site.getsitepackages方法的典型用法代码示例。如果您正苦于以下问题:Python site.getsitepackages方法的具体用法?Python site.getsitepackages怎么用?Python site.getsitepackages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在site的用法示例。


在下文中一共展示了site.getsitepackages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_getsitepackages

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def test_getsitepackages(self):
        site.PREFIXES = ['xoxo']
        dirs = site.getsitepackages()

        if sys.platform in ('os2emx', 'riscos'):
            self.assertEqual(len(dirs), 1)
            wanted = os.path.join('xoxo', 'Lib', 'site-packages')
            self.assertEqual(dirs[0], wanted)
        elif os.sep == '/':
            # OS X, Linux, FreeBSD, etc
            self.assertEqual(len(dirs), 2)
            wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
                                  'site-packages')
            self.assertEqual(dirs[0], wanted)
            wanted = os.path.join('xoxo', 'lib', 'site-python')
            self.assertEqual(dirs[1], wanted)
        else:
            # other platforms
            self.assertEqual(len(dirs), 2)
            self.assertEqual(dirs[0], 'xoxo')
            wanted = os.path.join('xoxo', 'lib', 'site-packages')
            self.assertEqual(dirs[1], wanted) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_site.py

示例2: install

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def install(setup_py, prefix, lib_dir, bin_dir):
    __file__ = setup_py

    with getattr(tokenize, "open", open)(setup_py) as f:
        code = f.read().replace("\\r\\n", "\n")
    if os.path.exists(os.path.join(lib_dir, "site.py")):
        # Remove the custom site.py for editable install.
        # It will be added back after installation is done.
        os.remove(os.path.join(lib_dir, "site.py"))
    sys.argv[1:] = [
        "develop",
        "--install-dir={0}".format(lib_dir),
        "--no-deps",
        "--prefix={0}".format(prefix),
        "--script-dir={0}".format(bin_dir),
        "--site-dirs={0}".format(lib_dir),
    ]
    if os.path.normpath(lib_dir) not in site.getsitepackages():
        # Patches the script writer to inject library path
        easy_install.ScriptWriter.template = easy_install.ScriptWriter.template.replace(
            "import sys",
            "import sys\nsys.path.insert(0, {0!r})".format(lib_dir.replace("\\", "/")),
        )
    exec(compile(code, __file__, "exec")) 
开发者ID:frostming,项目名称:pdm,代码行数:26,代码来源:_editable_install.py

示例3: wmi

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def wmi():
    try:
        # PyMI depends on the MI API, not available by default on systems older
        # than Windows 8 / Windows Server 2012
        import wmi
        return wmi
    except ImportError:
        LOG.debug("Couldn't load PyMI module, using legacy WMI")

        wmi_path = None
        for packages_path in site.getsitepackages():
            path = os.path.join(packages_path, "wmi.py")
            if os.path.isfile(path):
                wmi_path = path
                break
        if wmi_path is None:
            raise exception.ItemNotFoundException("wmi module not found")

        return imp.load_source("wmi", wmi_path) 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:21,代码来源:wmi_loader.py

示例4: get_site_packages

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def get_site_packages():
    """
    This is a hack to work around site.getsitepackages() not working in
    virtualenv. See https://github.com/pypa/virtualenv/issues/355
    """
    # Another hack...
    # Relies on the fact that os.py is in the dir above site_packages
    os_location = os.path.dirname(os.__file__)
    site_packages = []
    # Consider Debain/Ubuntu custom
    for site in ["site-packages", "dist-packages"]:
        site_path = os.path.join(os_location, site)
        if os.path.isdir(site_path):
            site_packages.append(site_path)
    try:
        site_packages += _site.getsitepackages()
    except AttributeError, ex:
        print("WARNING: Error trying to call site.getsitepackages(). Exception: %r" % ex)
        print("         Do you have sufficient permissions?") 
        print("         Otherwise this could probably be virtualenv issue#355") 
开发者ID:tintinweb,项目名称:scapy-ssl_tls,代码行数:22,代码来源:setup.py

示例5: get_site_packages

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def get_site_packages():  # pragma: no cover
    try:
        paths = site.getsitepackages()
        if site.ENABLE_USER_SITE:
            paths.append(site.getusersitepackages())
        return paths

    # virtualenv does not ship with a getsitepackages impl so we fallback
    # to using distutils if we can
    # https://github.com/pypa/virtualenv/issues/355
    except Exception:
        try:
            from distutils.sysconfig import get_python_lib

            return [get_python_lib()]

        # just incase, don't fail here, it's not worth it
        except Exception:
            return []


################################################
# cross-compatible metaclass implementation
# Copyright (c) 2010-2012 Benjamin Peterson 
开发者ID:Pylons,项目名称:hupper,代码行数:26,代码来源:compat.py

示例6: clean_mod

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def clean_mod():
    r"""
    清除已產生的 site-packages\comtypes\gen\*.py
    """
    pkgdirs = site.getsitepackages()
    for pkgdir in pkgdirs:
        if not pkgdir.endswith('site-packages'):
            continue

        gendir = pkgdir + r'\comtypes\gen'
        if not os.path.isdir(gendir):
            continue

        logger = logging.getLogger('helper')
        logger.info('  路徑 %s', gendir)

        for item in os.listdir(gendir):
            if item.endswith('.py'):
                logger.info('  移除 %s', item)
                os.remove(gendir + '\\' + item)

        cache_dir = gendir + '\\' + '__pycache__'
        if os.path.isdir(cache_dir):
            logger.info('  移除 __pycache__')
            shutil.rmtree(cache_dir) 
开发者ID:tacosync,项目名称:skcom,代码行数:27,代码来源:helper.py

示例7: _extract_toplevel_packages

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def _extract_toplevel_packages(pip_output):
  """Extract the list of toplevel packages associated with a pip install."""
  # Account for default installations and --user installations (most common).
  # Note: we should possibly also account for --root, --prefix, & -t/--target.
  sitepackages = site.getsitepackages() + [site.getusersitepackages()]
  for package in _extract_installed_packages(pip_output):
    infodir = _get_distinfo_path(package, sitepackages)
    if not infodir:
      continue
    toplevel = os.path.join(infodir, "top_level.txt")
    if not os.path.exists(toplevel):
      continue
    for line in open(toplevel):
      line = line.strip()
      if line:
        yield line 
开发者ID:googlecolab,项目名称:colabtools,代码行数:18,代码来源:_pip.py

示例8: get_install_directory

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def get_install_directory():
    """
    Return the installation directory, or None
    """
    if '--user' in sys.argv:
        paths = site.getusersitepackages()
    else:
        paths = site.getsitepackages()

    if isinstance(paths, str):
        paths = [paths]

    for path in paths:
        if platform.system() == "Windows":
            path += "\\qibullet"
        else:
            path += "/qibullet"

        if os.path.exists(path):
            return path

    return None 
开发者ID:softbankrobotics-research,项目名称:qibullet,代码行数:24,代码来源:setup.py

示例9: generate_poses

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def generate_poses(object_folder, output_folder, renders_per_product, blender_attributes):
    "Make a call to Blender to generate poses"
    # python_sites = site.getsitepackages()[0]
    # python_sites = '/vol/project/2017/530/g1753002/ocadovenv/ocadovenv/lib/python3.5/site-packages'

    blender_path = '/vol/project/2017/530/g1753002/Blender/blender-2.79-linux-glibc219-x86_64/blender'
    blender_script_path = os.path.join(src_dir, 'rendering', 'render_poses.py')
    config_file_path = os.path.join(src_dir, 'rendering', 'config.json')

    blender_args = [blender_path, '--background', '--python', blender_script_path, '--',
                    src_dir,
                    # config_file_path,
                    object_folder,
                    output_folder,
                    str(renders_per_product),
                    json.dumps(blender_attributes)]

    # blender_args = [blender_path, '--background', '--python']

    print('Rendering...')
    subprocess.check_call(blender_args)
    print('Rendering done!') 
开发者ID:921kiyo,项目名称:3d-dl,代码行数:24,代码来源:render_example.py

示例10: __init__

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def __init__(self):
        """Initialize a new DistFilesFinder."""
        try:
            self.sitedirs = set(site.getsitepackages() + [site.getusersitepackages()])
        except AttributeError:
            self.sitedirs = [get_python_lib()] 
开发者ID:src-d,项目名称:modelforge,代码行数:8,代码来源:environment.py

示例11: _find_install_path

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def _find_install_path():
    if "--user" in sys.argv:
        inst = site.getusersitepackages()
        prefix = site.getuserbase()
    else:
        inst = site.getsitepackages()[0]
        prefix = sys.prefix
    return inst, prefix 
开发者ID:encarsia,项目名称:gpt,代码行数:10,代码来源:setup.py

示例12: pytorch_import_fix

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def pytorch_import_fix() -> None:
    """Hackfix needed before pytorch import ("dlopen: cannot load any more object with static TLS")
    See issue #305
    """
    try:
        for packages in site.getsitepackages():
            for lib in glob.glob(f'{packages}/torch/lib/libgomp*.so*'):
                ctypes.cdll.LoadLibrary(lib)
    except Exception:  # pylint: disable=broad-except
        pass 
开发者ID:facebookresearch,项目名称:nevergrad,代码行数:12,代码来源:tools.py

示例13: run_cstm_cmd

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def run_cstm_cmd(self):
    # append binary folder to PYTHON PATH
    if self.tools:
        with open(os.path.join(site.getsitepackages()[0], 'nanopype.pth'), 'w') as fp:
            print('import os; os.environ["PATH"] = "{dir}" + os.pathsep + os.environ["PATH"]'.format(dir=os.path.abspath(self.tools)), file=fp) 
开发者ID:giesselmann,项目名称:nanopype,代码行数:7,代码来源:setup.py

示例14: main

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def main():
    locations = [site.getusersitepackages()]
    locations += site.getsitepackages()
    for root in locations:
        if os.path.isdir(root):
            for name in os.listdir(root):
                if PKGNAME in name:
                    abspath = os.path.join(root, name)
                    rmpath(abspath) 
开发者ID:giampaolo,项目名称:psutil,代码行数:11,代码来源:purge_installation.py

示例15: test_getsitepackages

# 需要导入模块: import site [as 别名]
# 或者: from site import getsitepackages [as 别名]
def test_getsitepackages(self):
        site.PREFIXES = ['xoxo']
        dirs = site.getsitepackages()

        if sys.platform in ('os2emx', 'riscos'):
            self.assertEqual(len(dirs), 1)
            wanted = os.path.join('xoxo', 'Lib', 'site-packages')
            self.assertEqual(dirs[0], wanted)
        elif (sys.platform == "darwin" and
            sysconfig.get_config_var("PYTHONFRAMEWORK")):
            # OS X framework builds
            site.PREFIXES = ['Python.framework']
            dirs = site.getsitepackages()
            self.assertEqual(len(dirs), 3)
            wanted = os.path.join('/Library',
                                  sysconfig.get_config_var("PYTHONFRAMEWORK"),
                                  sys.version[:3],
                                  'site-packages')
            self.assertEqual(dirs[2], wanted)
        elif os.sep == '/':
            # OS X non-framwework builds, Linux, FreeBSD, etc
            self.assertEqual(len(dirs), 2)
            wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
                                  'site-packages')
            self.assertEqual(dirs[0], wanted)
            wanted = os.path.join('xoxo', 'lib', 'site-python')
            self.assertEqual(dirs[1], wanted)
        else:
            # other platforms
            self.assertEqual(len(dirs), 2)
            self.assertEqual(dirs[0], 'xoxo')
            wanted = os.path.join('xoxo', 'lib', 'site-packages')
            self.assertEqual(dirs[1], wanted) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:35,代码来源:test_site.py


注:本文中的site.getsitepackages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。