當前位置: 首頁>>代碼示例>>Python>>正文


Python pkg_resources.safe_version方法代碼示例

本文整理匯總了Python中pkg_resources.safe_version方法的典型用法代碼示例。如果您正苦於以下問題:Python pkg_resources.safe_version方法的具體用法?Python pkg_resources.safe_version怎麽用?Python pkg_resources.safe_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pkg_resources的用法示例。


在下文中一共展示了pkg_resources.safe_version方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def run(self):
        metadata = self.distribution.metadata
        project_name = metadata.get_name()
        version = safe_version(metadata.get_version())
        print("Collecting artifacts for %s==%s in 'dist' folder:" %
              (project_name, version))
        dist_files = []
        for filename in os.listdir('dist'):
            try:
                _, file_version, pyversion, command = parse_filename(
                    filename, project_name=project_name)
                if file_version != version:
                    continue
            except ValueError:
                continue
            filepath = os.path.join('dist', filename)
            dist_files.append((command, pyversion, filepath))

        if not dist_files:
            raise DistutilsOptionError(
                "No file collected from the 'dist' folder")

        for command, pyversion, filepath in dist_files:
            self.upload_file(command, pyversion, filepath) 
開發者ID:ogrisel,項目名稱:wheelhouse-uploader,代碼行數:26,代碼來源:cmd.py

示例2: _parse_exe_filename

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def _parse_exe_filename(basename, project_name=None, return_tags=True):
    remainder, pythontag = basename.rsplit('-', 1)
    if not pythontag.startswith('py'):
        # There was no python tag with this file, therefore it must be
        # python version independent
        pythontag = 'py' + '.'.join(str(x) for x in sys.version_info[:2])
        remainder = basename
    name_and_version, platform = remainder.rsplit('.', 1)
    distname, version = name_and_version.rsplit('-', 1)
    distname = _wheel_escape(distname)
    if project_name is not None and distname != _wheel_escape(project_name):
        raise ValueError('File %s.exe does not match project name %s'
                         % (basename, project_name))
    pyversion = pythontag[2:]
    if return_tags:
        tags = {
            'python': pythontag.replace('.', ''),
            'platform': _wheel_escape(platform),
        }
        return (distname, safe_version(version), pyversion, 'bdist_wininst',
                tags)
    return (distname, safe_version(version), pyversion, 'bdist_wininst') 
開發者ID:ogrisel,項目名稱:wheelhouse-uploader,代碼行數:24,代碼來源:utils.py

示例3: safe_version

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def safe_version(*args, **kwargs) -> str:
    """
    Package resources is a very slow load
    """
    import pkg_resources

    return pkg_resources.safe_version(*args, **kwargs) 
開發者ID:MolSSI,項目名稱:QCElemental,代碼行數:9,代碼來源:importing.py

示例4: safer_version

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def safer_version(version):
    return safe_version(version).replace("-", "_") 
開發者ID:microsoft,項目名稱:botbuilder-python,代碼行數:4,代碼來源:azure_bdist_wheel.py

示例5: patch_missing_pkg_info

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:dist.py

示例6: safer_version

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def safer_version(version):
    return safe_version(version).replace('-', '_') 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:bdist_wheel.py

示例7: wheel_filename

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def wheel_filename(self) -> str:
        name = to_filename(self.meta.project_name)
        version = to_filename(safe_version(self.meta.version))
        return f"{name}-{version}-{self.tag}.whl" 
開發者ID:frostming,項目名稱:pdm,代碼行數:6,代碼來源:wheel.py

示例8: dist_info_name

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def dist_info_name(self) -> str:
        name = to_filename(self.meta.project_name)
        version = to_filename(safe_version(self.meta.version))
        return f"{name}-{version}.dist-info" 
開發者ID:frostming,項目名稱:pdm,代碼行數:6,代碼來源:wheel.py

示例9: build

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def build(self, build_dir: str, **kwargs):
        if not os.path.exists(build_dir):
            os.makedirs(build_dir, exist_ok=True)

        stream.echo("- Building {}...".format(stream.cyan("sdist")))
        version = to_filename(safe_version(self.meta.version))

        target = os.path.join(
            build_dir, "{}-{}.tar.gz".format(self.meta.project_name, version)
        )
        tar = tarfile.open(target, mode="w:gz", format=tarfile.PAX_FORMAT)

        try:
            tar_dir = "{}-{}".format(self.meta.project_name, version)

            files_to_add = self.find_files_to_add(True)

            for relpath in files_to_add:
                tar.add(
                    relpath,
                    arcname=os.path.join(tar_dir, str(relpath)),
                    recursive=False,
                )
                stream.echo(f" - Adding: {relpath}", verbosity=stream.DETAIL)

            fd, temp_name = tempfile.mkstemp(prefix="pkg-info")
            pkg_info = self.format_pkginfo(False).encode("utf-8")
            with open(fd, "wb") as f:
                f.write(pkg_info)
            tar.add(
                temp_name, arcname=os.path.join(tar_dir, "PKG-INFO"), recursive=False
            )
            stream.echo(" - Adding: PKG-INFO", verbosity=stream.DETAIL)
        finally:
            tar.close()

        stream.echo("- Built {}".format(stream.cyan(os.path.basename(target))))

        return target 
開發者ID:frostming,項目名稱:pdm,代碼行數:41,代碼來源:sdist.py

示例10: _parse_wheel_filename

# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import safe_version [as 別名]
def _parse_wheel_filename(basename, project_name=None, return_tags=False):
    components = basename.split('-')
    distname = components[0]
    if (project_name is not None and
            distname != _wheel_escape(project_name)):
        raise ValueError('File %s.whl does not match project name %s'
                         % (basename, project_name))

    if len(components) < 3 or not len(components[2]) >= 3:
        raise ValueError('Invalid wheel filename %s.whl' % basename)
    version = components[1]
    pytag = components[2]
    abitag = components[3]
    platformtag = components[4]

    if pytag == 'py2.py3':
        # special handling of the universal Python version tag:
        pyversion = '.'.join(str(x) for x in sys.version_info[:2])
    elif pytag[:2] == 'py' and len(pytag) == 3:
        pyversion = '%s' % pytag[2]
    elif pytag[:2] == 'py' and len(pytag) == 4:
        pyversion = '%s.%s' % (pytag[2], pytag[3])
    elif pytag[:2] == 'cp':
        pyversion = '%s.%s' % (pytag[2], pytag[3])
    else:
        raise ValueError('Invalid or unsupported Python version tag in '
                         'filename %s.whl' % basename)
    if return_tags:
        tags = {
            'python': pytag,
            'abi': abitag,
            'platform': platformtag,
        }
        return (distname, safe_version(version), pyversion, 'bdist_wheel',
                tags)
    else:
        return (distname, safe_version(version), pyversion, 'bdist_wheel') 
開發者ID:ogrisel,項目名稱:wheelhouse-uploader,代碼行數:39,代碼來源:utils.py


注:本文中的pkg_resources.safe_version方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。