我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pkg_resources.safe_version()。
def safer_version(version): return safe_version(version).replace('-', '_')
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
def parse_requirement(req): dumb_parse = pkg_resources.Requirement.parse(req) if dumb_parse.extras: extras = '[{}]'.format(','.join(dumb_parse.extras)) else: extras = '' return pkg_resources.Requirement.parse( dumb_parse.project_name + extras + ','.join( operator + pkg_resources.safe_version(version) for operator, version in dumb_parse.specs ) )