MCPcopy Index your code
hub / github.com/modelscope/modelscope / get

Function get

modelscope/utils/plugins.py:606–710  ·  view source on GitHub ↗
(dist_name,
            index_url=None,
            env=None,
            extra_index_url=None,
            tmpdir=None,
            ignore_errors=False)

Source from the content-addressed store, hash-verified

604 return args
605
606 def get(dist_name,
607 index_url=None,
608 env=None,
609 extra_index_url=None,
610 tmpdir=None,
611 ignore_errors=False):
612 args = _get_wheel_args(index_url, env, extra_index_url) + [dist_name]
613 scratch_dir = mkdtemp(dir=tmpdir)
614 logger.debug(
615 'wheeling and dealing',
616 scratch_dir=os.path.abspath(scratch_dir),
617 args=' '.join(args))
618 try:
619 out = check_output(
620 args, stderr=STDOUT, cwd=scratch_dir).decode('utf-8')
621 except ChildProcessError as err:
622 out = getattr(err, 'output', b'').decode('utf-8')
623 logger.warning(out)
624 if not ignore_errors:
625 raise
626 logger.debug('wheel command completed ok', dist_name=dist_name)
627 links = []
628 local_links = []
629 lines = out.splitlines()
630 for i, line in enumerate(lines):
631 line = line.strip()
632 if line.startswith('Downloading from URL '):
633 parts = line.split()
634 link = parts[3]
635 links.append(link)
636 elif line.startswith('Downloading '):
637 parts = line.split()
638 last = parts[-1]
639 if len(parts) == 3 and last.startswith('(') and last.endswith(
640 ')'):
641 link = parts[-2]
642 elif len(parts) == 4 and parts[-2].startswith(
643 '(') and last.endswith(')'):
644 link = parts[-3]
645 if not urlparse(link).scheme:
646 # newest pip versions have changed to not log the full url
647 # in the download event. it is becoming more and more annoying
648 # to preserve compatibility across a wide range of pip versions
649 next_line = lines[i + 1].strip()
650 if next_line.startswith(
651 'Added ') and ' to build tracker' in next_line:
652 link = next_line.split(
653 ' to build tracker')[0].split()[-1]
654 else:
655 link = last
656 links.append(link)
657 elif line.startswith(
658 'Source in ') and 'which satisfies requirement' in line:
659 link = line.split()[-1]
660 links.append(link)
661 elif line.startswith('Added ') and ' from file://' in line:
662 [link] = [x for x in line.split() if x.startswith('file://')]
663 local_links.append(link)

Callers 1

get_modules_from_packageFunction · 0.85

Calls 6

_get_wheel_argsFunction · 0.85
_download_distFunction · 0.85
compute_checksumFunction · 0.85
replaceMethod · 0.80
decodeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected