我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用site._init_pathinfo()。
def test_init_pathinfo(self): dir_set = site._init_pathinfo() for entry in [site.makepath(path)[1] for path in sys.path if path and os.path.isdir(path)]: self.assertIn(entry, dir_set, "%s from sys.path not found in set returned " "by _init_pathinfo(): %s" % (entry, dir_set))
def _install_namespace_package(self, tmp_sitedir): # Install our test namespace package in such a way that both py27 and # py36 can find it. from setuptools import namespaces installer = namespaces.Installer() class Distribution: namespace_packages = ['namespace_package'] installer.distribution = Distribution() installer.target = os.path.join(tmp_sitedir, 'namespace_package.pth') installer.outputs = [] installer.dry_run = False installer.install_namespaces() site.addsitedir(tmp_sitedir, known_paths=site._init_pathinfo())