本文整理汇总了Python中setuptools.dist.Distribution.fetch_build_eggs方法的典型用法代码示例。如果您正苦于以下问题:Python Distribution.fetch_build_eggs方法的具体用法?Python Distribution.fetch_build_eggs怎么用?Python Distribution.fetch_build_eggs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.dist.Distribution
的用法示例。
在下文中一共展示了Distribution.fetch_build_eggs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_requires
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import fetch_build_eggs [as 别名]
def test_requires(self, main):
d = Distribution({'script_name': 'setup.py',
'script_args': ['green'],
'install_requires': ['six'],
'tests_require': ['mock', 'unittest2']})
d.fetch_build_eggs = MagicMock()
cmd = command.green(d)
cmd.run()
d.fetch_build_eggs.assert_has_calls([
call(['six']),
call(['mock', 'unittest2']),
])
示例2: test_parse_setup_requires_fetcher_uses_index_url_from_command_line
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import fetch_build_eggs [as 别名]
def test_parse_setup_requires_fetcher_uses_index_url_from_command_line():
setup_cfg = """
[metadata]
name = test3
setup_requires =
foo
"""
index_url = "http://my_super_duper_index/simplesteversimple"
t = namedtuple("Distribution", ['requires', 'insert_on', 'location'])
dist = t(lambda *_1, **_2: [], lambda *_1, **_2: None, "")
def easy_install(self, *args, **kwargs): # @UnusedVariable
assert self.index_url == index_url
return dist
add_mock = Mock()
class AssertCmd(_develop):
def run(self):
assert self.index_url == index_url
with ExitStack() as stack:
p = stack.enter_context
p(patch("pkglib.setuptools._setup.set_working_dir"))
p(patch(configparser.__name__ + ".ConfigParser",
_create_config_parser(setup_cfg)))
p(patch('setuptools.command.easy_install.easy_install.check_site_dir'))
p(patch("setuptools.command.easy_install.easy_install.easy_install",
new=easy_install))
p(patch("pkg_resources.WorkingSet.add", new=add_mock))
p(patch("pkglib.setuptools.dist.fetch_build_eggs", new=lambda r,
dist=None: Distribution.fetch_build_eggs(dist, r)))
sys.argv[1:] = ['develop', '-i', index_url]
pkgutils_setup(cmdclass={'develop': AssertCmd})
add_mock.assert_called_with(dist)
示例3: add_to_stsci_package_index
# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import fetch_build_eggs [as 别名]
def add_to_stsci_package_index(data):
"""
A releaser.after hook to copy the source distribution to STScI's local
package index and update the index using basketweaver.
"""
if not is_stsci_project(data['workingdir']):
return
if not data['tagdir'] or not os.path.exists(data['tagdir']):
# Do nothing if a tag checkout was not performed
return
if not ask('Copy source package to STScI package index'):
return
package_path = DEFAULT_PACKAGE_INDEX_PATH
if not os.path.exists(package_path):
package_path = ''
question = 'Path to package directory'
if package_path:
# A default exists; let the user know
question += ' [%s]' % package_path
question += ': '
answer = ''
while not answer:
try:
answer = raw_input(question).strip()
if not answer:
if package_path:
# The user simple pressed enter, so use the supplied
# default
answer = package_path
else:
continue
if not os.path.exists(answer):
print ('The supplied path %s does not exist. Please enter a '
'different path or press Ctrl-C to cancel.' % answer)
if not os.access(answer, os.W_OK):
print ('The supplied path %s is not writeable. Either change '
'the permissions of the directory or have someone '
'grant you access and try again, enter a different '
'directory, or press Ctrl-C to cancel.' % answer)
package_path = answer
break
# The default was not supplied, so keep asking
except KeyboardInterrupt:
return
# A tag checkout was made and an sdist created, this is where it would be
# (the sdist is a .zip on Windows, a .tar.gz elsewhere--normally this
# should be .tar.gz; don't make releases on Windows)
sdist_file = ''
while not sdist_file:
try:
sdist_file = glob.glob(os.path.join(data['tagdir'], 'dist',
'*.tar.gz'))[0]
except IndexError:
try:
sdist_file = glob.glob(os.path.join(data['tagdir'], 'dist',
'*.zip'))[0]
except IndexError:
try:
print (
"Could not find a source distribution in %s; did you "
"do a source checkout for upload? If possible, try "
"to cd to %s and manually create a source "
"distribution by running `python setup.py sdist`. "
"Then press enter to try again (or hit Ctrl-C to "
"cancel). Go ahead, I'll wait..." %
(data['tagdir'], data['tagdir']))
raw_input()
except KeyboardInterrupt:
return
# Almost ready go to--now we just need to check if basketweaver is
# available, and get it if not.
try:
import basketweaver.makeindex
except ImportError:
# Use setuptools' machinery to fetch a package and add it to the path;
# we could do this without using setuptools directly, but it would
# basically end up reimplementing much of the same code.
dist = Distribution({'dependency_links': [PACKAGE_INDEX_URL]})
try:
dist.fetch_build_eggs(['basketweaver'])
except:
# There are so many things that could possibly go wrong here...
print ('Failed to get basketweaver, which is required to rebuild '
'the package index. To manually complete the release, '
'install basketweaver manually, then copy %s into %s, cd '
'to %s, and then run `makeindex *`, where makeindex is the '
'command installed by basketweaver.' %
(sdist_file, package_path, package_path))
import basketweaver.makeindex
# Now we should have everything we need...
shutil.copy(sdist_file, package_path)
#.........这里部分代码省略.........