本文整理汇总了Python中enstaller.versions.enpkg.EnpkgVersion.from_upstream_and_build方法的典型用法代码示例。如果您正苦于以下问题:Python EnpkgVersion.from_upstream_and_build方法的具体用法?Python EnpkgVersion.from_upstream_and_build怎么用?Python EnpkgVersion.from_upstream_and_build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enstaller.versions.enpkg.EnpkgVersion
的用法示例。
在下文中一共展示了EnpkgVersion.from_upstream_and_build方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_package_from_requirement
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def find_package_from_requirement(self, requirement):
"""Search for latest package matching the given requirement.
Parameters
----------
requirement : Requirement
The requirement to match for.
Returns
-------
package : RemotePackageMetadata
The corresponding metadata.
"""
name = requirement.name
version = requirement.version
build = requirement.build
if version is None:
return self.find_latest_package(name)
else:
if build is None:
upstream = PEP386WorkaroundVersion.from_string(version)
candidates = [p for p in self.find_packages(name)
if p.version.upstream == upstream]
candidates.sort(key=operator.attrgetter("version"))
if len(candidates) == 0:
msg = "No package found for requirement {0!r}"
raise NoSuchPackage(msg.format(requirement))
return candidates[-1]
else:
version = EnpkgVersion.from_upstream_and_build(version, build)
return self.find_package(name, str(version))
示例2: _version_factory
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def _version_factory(upstream, build):
if (upstream, build) in cache:
version = cache[(upstream, build)]
else:
version = EnpkgVersion.from_upstream_and_build(upstream, build)
cache[(upstream, build)] = version
return version
示例3: from_json_dict
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def from_json_dict(cls, key, json_dict):
version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
json_dict["build"])
return cls(key, json_dict["name"], version, json_dict["packages"],
json_dict["python"], json_dict["size"], json_dict["md5"],
json_dict.get("mtime", 0.0), json_dict.get("product", None),
json_dict.get("available", True),
json_dict["store_location"])
示例4: from_json_dict
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def from_json_dict(cls, key, json_dict):
"""
Create an instance from a key (the egg filename) and metadata passed as
a dictionary
"""
version = EnpkgVersion.from_upstream_and_build(json_dict["version"],
json_dict["build"])
return cls(key, json_dict["name"], version, json_dict["packages"],
json_dict["python"])
示例5: test_no_egg_install
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def test_no_egg_install(self):
# Given
prefix = self.prefix
package_name = "enstaller"
r_version = EnpkgVersion.from_upstream_and_build(enstaller.__version__,
1)
# When
version = _get_enstaller_comparable_version(prefix, package_name)
# Then
self.assertEqual(version, r_version)
示例6: from_installed_meta_dict
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def from_installed_meta_dict(cls, json_dict, prefix=None):
prefix = prefix or sys.prefix
key = json_dict["key"]
name = json_dict["name"]
upstream_version = json_dict["version"]
build = json_dict.get("build", 1)
version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
packages = json_dict.get("packages", [])
python = json_dict.get("python", PY_VER)
ctime = json_dict.get("ctime", time.ctime(0.0))
return cls(key, name, version, packages, python, ctime, prefix)
示例7: from_installed_meta_dict
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def from_installed_meta_dict(cls, json_dict):
key = json_dict["key"]
name = json_dict["name"]
upstream_version = json_dict["version"]
build = json_dict.get("build", 1)
version = EnpkgVersion.from_upstream_and_build(upstream_version, build)
packages = json_dict.get("packages", [])
python = json_dict.get("python", PY_VER)
ctime = json_dict.get("ctime", time.ctime(0.0))
store_location = json_dict.get("store_location", "")
return cls(key, name, version, packages, python, ctime,
store_location)
示例8: dummy_repository_package_factory
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def dummy_repository_package_factory(name, version, build, key=None,
py_ver=PY_VER, store_location="",
dependencies=None, mtime=0.0):
dependencies = dependencies or []
key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
fake_size = FAKE_SIZE
fake_md5 = FAKE_MD5
fake_mtime = mtime
version = EnpkgVersion.from_upstream_and_build(version, build)
return RepositoryPackageMetadata(key, name.lower(), version,
dependencies, py_ver, fake_size,
fake_md5, fake_mtime, "commercial",
True, store_location)
示例9: _get_enstaller_comparable_version
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def _get_enstaller_comparable_version(prefix, package_name):
runtime_version = \
EnpkgVersion.from_upstream_and_build(enstaller.__version__, 1)
egg_info_dir = os.path.join(prefix, EGG_INFO, package_name)
try:
# Installed as an egg in sys.prefix
enstaller_package = \
InstalledPackageMetadata.from_meta_dir(egg_info_dir)
if str(enstaller_package.version.upstream) != enstaller.__version__:
# It is both installed as an egg and from sources/develop mode, the
# latter takes precedence
current_comparable_version = runtime_version
else:
current_comparable_version = enstaller_package.version
except EnstallerException:
# Installed from sources, no build number
current_comparable_version = runtime_version
return current_comparable_version
示例10: test_egg_install_different_versions
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def test_egg_install_different_versions(self):
# ensure that we use the build number from installed metadata if
# version and enstaller.__version__ are the same
# Given
prefix = self.prefix
package_name = "enstaller"
version_string = "2.7.6"
build = 4
json_dict = {
"arch": None,
"build": build,
"ctime": "Mon Oct 20 15:49:19 2014",
"hook": False,
"key": "enstaller-{0}-1.egg".format(version_string),
"name": "enstaller",
"osdist": None,
"packages": [],
"platform": None,
"python": "2.7",
"type": "egg",
"version": version_string,
}
r_version = EnpkgVersion.from_upstream_and_build("4.8.0", 1)
meta_info_path = meta_info_from_prefix(prefix, package_name)
ensure_dir(meta_info_path)
with open(meta_info_path, "wt") as fp:
json.dump(json_dict, fp)
# When
with mock.patch("enstaller.__version__", "4.8.0"):
version = _get_enstaller_comparable_version(prefix, package_name)
# Then
self.assertEqual(version, r_version)
示例11: _ensure_valid_version
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def _ensure_valid_version(version, build_number):
full_version = EnpkgVersion.from_upstream_and_build(version,
build_number)
if full_version.upstream.is_worked_around:
raise InvalidVersion(version)
示例12: dummy_installed_package_factory
# 需要导入模块: from enstaller.versions.enpkg import EnpkgVersion [as 别名]
# 或者: from enstaller.versions.enpkg.EnpkgVersion import from_upstream_and_build [as 别名]
def dummy_installed_package_factory(name, version, build, key=None,
py_ver=PY_VER, store_location=""):
key = key if key else "{0}-{1}-{2}.egg".format(name, version, build)
version = EnpkgVersion.from_upstream_and_build(version, build)
return InstalledPackageMetadata(key, name.lower(), version, [], py_ver,
"", store_location)