本文整理汇总了Python中setuptools.Distribution.parse_config_files方法的典型用法代码示例。如果您正苦于以下问题:Python Distribution.parse_config_files方法的具体用法?Python Distribution.parse_config_files怎么用?Python Distribution.parse_config_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.Distribution
的用法示例。
在下文中一共展示了Distribution.parse_config_files方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_build_egg
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def fetch_build_egg(self, req):
""" Specialized version of Distribution.fetch_build_egg
that respects respects allow_hosts and index_url. """
from setuptools.command.easy_install import easy_install
dist = Distribution({'script_args': ['easy_install']})
dist.parse_config_files()
opts = dist.get_option_dict('easy_install')
keep = (
'find_links', 'site_dirs', 'index_url', 'optimize',
'site_dirs', 'allow_hosts'
)
for key in list(opts):
if key not in keep:
del opts[key] # don't use any other settings
if self.dependency_links:
links = self.dependency_links[:]
if 'find_links' in opts:
links = opts['find_links'][1].split() + links
opts['find_links'] = ('setup', links)
if self.allow_hosts:
opts['allow_hosts'] = ('test', self.allow_hosts)
if self.index_url:
opts['index_url'] = ('test', self.index_url)
install_dir_func = getattr(self, 'get_egg_cache_dir', _os.getcwd)
install_dir = install_dir_func()
cmd = easy_install(
dist, args=["x"], install_dir=install_dir,
exclude_scripts=True,
always_copy=False, build_directory=None, editable=False,
upgrade=False, multi_version=True, no_report=True, user=False
)
cmd.ensure_finalized()
return cmd.easy_install(req)
示例2: get_setuptools_script_dir
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def get_setuptools_script_dir():
" Get the directory setuptools installs scripts to for current python "
dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
dist.dry_run = True # not sure if necessary
dist.parse_config_files()
command = dist.get_command_obj('install')
command.ensure_finalized()
command.run()
return dist.install_scripts
示例3: get_setuptools_script_dir
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def get_setuptools_script_dir():
# Run the above class just to get paths
dist = Distribution({'cmdclass': {'install': GetPaths}})
dist.dry_run = True
dist.parse_config_files()
command = dist.get_command_obj('install')
command.ensure_finalized()
command.run()
src_dir = glob(os.path.join(dist.install_libbase, 'pomoxis-*', 'exes'))[0]
for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)):
print("Copying", os.path.basename(exe), '->', dist.install_scripts)
shutil.copy(exe, dist.install_scripts)
return dist.install_libbase, dist.install_scripts
示例4: getprefix
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def getprefix(self):
'''Retrieve setup tool calculated prefix
:returns: prefix
:rtype: string
'''
dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
dist.dry_run = True # not sure if necessary, but to be safe
dist.parse_config_files()
try:
dist.parse_command_line()
except (distutils.errors.DistutilsArgError, AttributeError):
pass
command = dist.get_command_obj('install')
command.ensure_finalized()
command.run()
prefix = dist.install_scripts.replace('/bin', '')
return prefix
示例5: test_dist_fetch_build_egg
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def test_dist_fetch_build_egg(tmpdir):
"""
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
index = tmpdir.mkdir('index')
index_url = urljoin('file://', pathname2url(str(index)))
def sdist_with_index(distname, version):
dist_dir = index.mkdir(distname)
dist_sdist = '%s-%s.tar.gz' % (distname, version)
make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
with dist_dir.join('index.html').open('w') as fp:
fp.write(DALS(
'''
<!DOCTYPE html><html><body>
<a href="{dist_sdist}" rel="internal">{dist_sdist}</a><br/>
</body></html>
'''
).format(dist_sdist=dist_sdist))
sdist_with_index('barbazquux', '3.2.0')
sdist_with_index('barbazquux-runner', '2.11.1')
with tmpdir.join('setup.cfg').open('w') as fp:
fp.write(DALS(
'''
[easy_install]
index_url = {index_url}
'''
).format(index_url=index_url))
reqs = '''
barbazquux-runner
barbazquux
'''.split()
with tmpdir.as_cwd():
dist = Distribution()
dist.parse_config_files()
resolved_dists = [
dist.fetch_build_egg(r)
for r in reqs
]
assert [dist.key for dist in resolved_dists if dist] == reqs
示例6: main
# 需要导入模块: from setuptools import Distribution [as 别名]
# 或者: from setuptools.Distribution import parse_config_files [as 别名]
def main(argv=None, **kw):
""" Run a test package's tests.
"""
# TODO: allow cmdline override of org config?
config.setup_org_config()
from path import path
USAGE = """\
usage: %(script)s <package name> [test options]
or: %(script)s --help
""" % {'script': sys.argv[0] or 'runtests'}
if argv is None:
argv = sys.argv[1:]
if not argv:
print "Please specify a package name."
print USAGE
sys.exit(1)
pkg_name, argv = argv[0], argv[1:]
test_pkg_name = 'test.%s' % pkg_name
# Find our
real_dist = [i for i in working_set if i.project_name == pkg_name]
if not real_dist:
print "Package %s is not installed" % pkg_name
sys.exit(1)
real_dist = real_dist[0]
test_dist = [i for i in working_set if i.project_name == test_pkg_name]
if not test_dist:
print "Test package %s is not installed" % test_pkg_name
sys.exit(1)
test_dist = test_dist[0]
# Construct a distutils.Distribtion class from the pkg_resources.Distribution
# of the real package so we can pass it into the test command class.
# We have checked that the packages are already installed so we set the install
# requirements to blank.
args = {'name': real_dist.project_name,
'install_requires': [],
'tests_require': [],
'namespace_packages': list(real_dist._get_metadata('namespace_packages')),
'packages': [real_dist.project_name],
}
real_cmd_dist = Distribution(args)
cmd = test(real_cmd_dist)
cmd.args = argv
# Read in the test options saved away during egg_info and set the command defaults,
# this would normally be done by the setup() method via the Distribution class
test_options = path(test_dist.location) / 'EGG-INFO' / 'test_options.txt'
if test_options.isfile():
real_cmd_dist.parse_config_files([test_options])
for k, v in real_cmd_dist.get_option_dict('test').items():
print "Found test option in %s: %s = %s" % (v[0], k, v[1])
setattr(cmd, k, v[1])
# Finalize and run the command, overriding the test root to be inside the test egg
cmd.finalize_options()
cmd.test_root = path(test_dist.location) / CONFIG.test_egg_namespace / \
real_dist.project_name.replace('.', '/')
# Pylint is only for regular Jenkins jobs, this in itself should not trigger even if
# running under Jenkins
cmd.no_pylint = True
cmd.run()