本文整理匯總了Python中setuptools.setup.cfg方法的典型用法代碼示例。如果您正苦於以下問題:Python setup.cfg方法的具體用法?Python setup.cfg怎麽用?Python setup.cfg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類setuptools.setup
的用法示例。
在下文中一共展示了setup.cfg方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_egg_info_save_version_info_setup_empty
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def test_egg_info_save_version_info_setup_empty(self, tmpdir_cwd, env):
"""
When the egg_info section is empty or not present, running
save_version_info should add the settings to the setup.cfg
in a deterministic order, consistent with the ordering found
on Python 2.7 with PYTHONHASHSEED=0.
"""
setup_cfg = os.path.join(env.paths['home'], 'setup.cfg')
dist = Distribution()
ei = egg_info(dist)
ei.initialize_options()
ei.save_version_info(setup_cfg)
with open(setup_cfg, 'r') as f:
content = f.read()
assert '[egg_info]' in content
assert 'tag_build =' in content
assert 'tag_date = 0' in content
expected_order = 'tag_build', 'tag_date',
self._validate_content_order(content, expected_order)
示例2: _set_fetcher_options
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def _set_fetcher_options(self, base):
"""
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
"""
# find the fetch options from easy_install and write them out
# to the setup.cfg file.
ei_opts = self.distribution.get_option_dict('easy_install').copy()
fetch_directives = (
'find_links', 'site_dirs', 'index_url', 'optimize',
'site_dirs', 'allow_hosts',
)
fetch_options = {}
for key, val in ei_opts.items():
if key not in fetch_directives:
continue
fetch_options[key.replace('_', '-')] = val[1]
# create a settings dictionary suitable for `edit_config`
settings = dict(easy_install=fetch_options)
cfg_filename = os.path.join(base, 'setup.cfg')
setopt.edit_config(cfg_filename, settings)
示例3: _set_fetcher_options
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def _set_fetcher_options(self, base):
"""
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
"""
# find the fetch options from easy_install and write them out
# to the setup.cfg file.
ei_opts = self.distribution.get_option_dict('easy_install').copy()
fetch_directives = (
'find_links', 'site_dirs', 'index_url', 'optimize',
'site_dirs', 'allow_hosts',
)
fetch_options = {}
for key, val in ei_opts.items():
if key not in fetch_directives: continue
fetch_options[key.replace('_', '-')] = val[1]
# create a settings dictionary suitable for `edit_config`
settings = dict(easy_install=fetch_options)
cfg_filename = os.path.join(base, 'setup.cfg')
setopt.edit_config(cfg_filename, settings)
示例4: _set_fetcher_options
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def _set_fetcher_options(self, base):
"""
When easy_install is about to run bdist_egg on a source dist, that
source dist might have 'setup_requires' directives, requiring
additional fetching. Ensure the fetcher options given to easy_install
are available to that command as well.
"""
# find the fetch options from easy_install and write them out
# to the setup.cfg file.
ei_opts = self.distribution.get_option_dict('easy_install').copy()
fetch_directives = (
'find_links', 'site_dirs', 'index_url', 'optimize', 'allow_hosts',
)
fetch_options = {}
for key, val in ei_opts.items():
if key not in fetch_directives:
continue
fetch_options[key.replace('_', '-')] = val[1]
# create a settings dictionary suitable for `edit_config`
settings = dict(easy_install=fetch_options)
cfg_filename = os.path.join(base, 'setup.cfg')
setopt.edit_config(cfg_filename, settings)
示例5: env
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def env(self):
with contexts.tempdir(prefix='setuptools-test.') as env_dir:
env = Environment(env_dir)
os.chmod(env_dir, stat.S_IRWXU)
subs = 'home', 'lib', 'scripts', 'data', 'egg-base'
env.paths = dict(
(dirname, os.path.join(env_dir, dirname))
for dirname in subs
)
list(map(os.mkdir, env.paths.values()))
build_files({
env.paths['home']: {
'.pydistutils.cfg': DALS("""
[egg_info]
egg-base = %(egg-base)s
""" % env.paths)
}
})
yield env
示例6: test_notoxini_noerror_in_help
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def test_notoxini_noerror_in_help(initproj, cmd):
initproj("examplepro", filedefs={})
result = cmd("-h")
msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
assert result.err != msg
示例7: test_notoxini_noerror_in_help_ini
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def test_notoxini_noerror_in_help_ini(initproj, cmd):
initproj("examplepro", filedefs={})
result = cmd("--help-ini")
msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
assert result.err != msg
示例8: extract_wininst_cfg
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def extract_wininst_cfg(dist_filename):
"""Extract configuration data from a bdist_wininst .exe
Returns a configparser.RawConfigParser, or None
"""
f = open(dist_filename, 'rb')
try:
endrec = zipfile._EndRecData(f)
if endrec is None:
return None
prepended = (endrec[9] - endrec[5]) - endrec[6]
if prepended < 12: # no wininst data here
return None
f.seek(prepended - 12)
tag, cfglen, bmlen = struct.unpack("<iii", f.read(12))
if tag not in (0x1234567A, 0x1234567B):
return None # not a valid tag
f.seek(prepended - (12 + cfglen))
cfg = configparser.RawConfigParser(
{'version': '', 'target_version': ''})
try:
part = f.read(cfglen)
# Read up to the first null byte.
config = part.split(b'\0', 1)[0]
# Now the config is in bytes, but for RawConfigParser, it should
# be text, so decode it.
config = config.decode(sys.getfilesystemencoding())
cfg.readfp(six.StringIO(config))
except configparser.Error:
return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
return None
return cfg
finally:
f.close()
示例9: extract_wininst_cfg
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import cfg [as 別名]
def extract_wininst_cfg(dist_filename):
"""Extract configuration data from a bdist_wininst .exe
Returns a configparser.RawConfigParser, or None
"""
f = open(dist_filename, 'rb')
try:
endrec = zipfile._EndRecData(f)
if endrec is None:
return None
prepended = (endrec[9] - endrec[5]) - endrec[6]
if prepended < 12: # no wininst data here
return None
f.seek(prepended - 12)
tag, cfglen, bmlen = struct.unpack("<iii", f.read(12))
if tag not in (0x1234567A, 0x1234567B):
return None # not a valid tag
f.seek(prepended - (12 + cfglen))
init = {'version': '', 'target_version': ''}
cfg = configparser.RawConfigParser(init)
try:
part = f.read(cfglen)
# Read up to the first null byte.
config = part.split(b'\0', 1)[0]
# Now the config is in bytes, but for RawConfigParser, it should
# be text, so decode it.
config = config.decode(sys.getfilesystemencoding())
cfg.readfp(six.StringIO(config))
except configparser.Error:
return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
return None
return cfg
finally:
f.close()