From 332d48c8ea905f5f1ae2c940611fc34afdb3b39f Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 14 Nov 2016 11:17:09 -0600 Subject: [PATCH 01/17] Populate PackageInfo model with info from files.json --- conda/gateways/disk/read.py | 42 ++++++++++++++++++++++++++---------- conda/models/package_info.py | 13 +++++++---- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 425b3f03a5d..2b9c79a4394 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -10,6 +10,7 @@ from logging import getLogger from os.path import isfile, islink, join +from ..._vendor.toolz.itertoolz import pluck from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 from ...models.package_info import PackageInfoContents from ...models.record import Record @@ -45,17 +46,36 @@ def collect_all_info_for_package(extracted_package_directory): info_dir = join(extracted_package_directory, 'info') files_path = join(extracted_package_directory, 'info', 'files') - files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) - - has_prefix_files = read_has_prefix(join(info_dir, 'has_prefix')) - no_link = read_no_link(info_dir) - soft_links = read_soft_links(extracted_package_directory, files) - index_json_record = read_index_json(extracted_package_directory) - icondata = read_icondata(extracted_package_directory) - noarch = read_noarch(extracted_package_directory) - - return PackageInfoContents(files, has_prefix_files, no_link, soft_links, - index_json_record, icondata, noarch) + file_json_path = join(extracted_package_directory, 'info', 'files.json') + + if isfile(file_json_path): + with open(file_json_path) as file_json: + data = json.load(file_json) + data = data.get("files") + + files = tuple(pluck("short_path", data)) + has_prefix_files = { + f.get("short_path"): tuple([f.get("prefix_placeholder"), f.get("file_mode")]) for f in + data if f.get("prefix_placeholder") is not None} + no_link = set([f.get("no_link") for f in data if f.get("no_link") is not None]) + soft_links = tuple([f for f in list(pluck("file_type", data)) if f == "softlink"]) + index_json_record = read_index_json(extracted_package_directory) + icondata = read_icondata(extracted_package_directory) + noarch = read_noarch(extracted_package_directory) + return PackageInfoContents(files=files, has_prefix_files=has_prefix_files, no_link=no_link, + soft_links=soft_links, index_json_record=index_json_record, + icondata=icondata, noarch=noarch) + else: + files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) + + has_prefix_files = read_has_prefix(join(info_dir, 'has_prefix')) + no_link = read_no_link(info_dir) + soft_links = read_soft_links(extracted_package_directory, files) + index_json_record = read_index_json(extracted_package_directory) + icondata = read_icondata(extracted_package_directory) + noarch = read_noarch(extracted_package_directory) + return PackageInfoContents(files, has_prefix_files, no_link, soft_links, + index_json_record, icondata, noarch) def read_noarch(extracted_package_directory): diff --git a/conda/models/package_info.py b/conda/models/package_info.py index 74abe4595d1..c0aac38c92a 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -4,8 +4,9 @@ from collections import namedtuple from logging import getLogger -from .._vendor.auxlib.entity import Entity, ListField +from .._vendor.auxlib.entity import Entity, ListField, ComposableField, StringField, MapField from ..common.compat import string_types +from .record import Record log = getLogger(__name__) @@ -16,6 +17,10 @@ class PackageInfo(Entity): - - file = ListField(string_types) - # TODO: finish this + files = ListField(string_types) + has_prefix_files = ListField(string_types) + no_link = ListField(string_types) + soft_links = ListField(string_types) + index_json_record = ComposableField(Record) + icondata = StringField() + noarch = MapField() From abb6b56cb8cbe504cab0486a5c8da373261500d9 Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Mon, 14 Nov 2016 18:33:17 -0600 Subject: [PATCH 02/17] edits from Kale --- conda/gateways/disk/read.py | 40 +++++++++++++++++++++--------------- conda/models/package_info.py | 36 +++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 2b9c79a4394..0a589cb8ed8 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -10,9 +10,8 @@ from logging import getLogger from os.path import isfile, islink, join -from ..._vendor.toolz.itertoolz import pluck from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 -from ...models.package_info import PackageInfoContents +from ...models.package_info import PackageInfoContents, PackageInfo from ...models.record import Record log = getLogger(__name__) @@ -51,20 +50,29 @@ def collect_all_info_for_package(extracted_package_directory): if isfile(file_json_path): with open(file_json_path) as file_json: data = json.load(file_json) - data = data.get("files") - - files = tuple(pluck("short_path", data)) - has_prefix_files = { - f.get("short_path"): tuple([f.get("prefix_placeholder"), f.get("file_mode")]) for f in - data if f.get("prefix_placeholder") is not None} - no_link = set([f.get("no_link") for f in data if f.get("no_link") is not None]) - soft_links = tuple([f for f in list(pluck("file_type", data)) if f == "softlink"]) - index_json_record = read_index_json(extracted_package_directory) - icondata = read_icondata(extracted_package_directory) - noarch = read_noarch(extracted_package_directory) - return PackageInfoContents(files=files, has_prefix_files=has_prefix_files, no_link=no_link, - soft_links=soft_links, index_json_record=index_json_record, - icondata=icondata, noarch=noarch) + if data.get('version') != 1: + raise CondaUpgradeError() + + return PackageInfo(files=data['files'], + index_json_record=read_index_json(extracted_package_directory), + noarch=read_noarch(extracted_package_directory), + icondata=read_icondata(extracted_package_directory), + ) + + + + # files = tuple(pluck("short_path", data)) + # has_prefix_files = { + # f.get("short_path"): tuple([f.get("prefix_placeholder"), f.get("file_mode")]) for f in + # data if f.get("prefix_placeholder") is not None} + # no_link = set([f.get("no_link") for f in data if f.get("no_link") is not None]) + # soft_links = tuple([f for f in list(pluck("file_type", data)) if f == "softlink"]) + # index_json_record = read_index_json(extracted_package_directory) + # icondata = read_icondata(extracted_package_directory) + # noarch = read_noarch(extracted_package_directory) + # return PackageInfoContents(files=files, has_prefix_files=has_prefix_files, no_link=no_link, + # soft_links=soft_links, index_json_record=index_json_record, + # icondata=icondata, noarch=noarch) else: files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) diff --git a/conda/models/package_info.py b/conda/models/package_info.py index c0aac38c92a..a34a09115a8 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -2,11 +2,14 @@ from __future__ import absolute_import, division, print_function, unicode_literals from collections import namedtuple +from enum import Enum from logging import getLogger -from .._vendor.auxlib.entity import Entity, ListField, ComposableField, StringField, MapField -from ..common.compat import string_types from .record import Record +from .._vendor.auxlib.entity import (BooleanField, ComposableField, Entity, EnumField, + IntegerField, ListField, StringField) +from ..base.constants import FileMode +from ..common.compat import string_types log = getLogger(__name__) @@ -16,11 +19,30 @@ 'index_json_record', 'icondata', 'noarch')) +class NoarchInfo(Entity): + type = StringField() + entry_points = ListField(string_types, required=False) + + +class FileType(Enum): + hardlink = 1 + softlink = 2 + directory = 4 + + +class PathInfo(Entity): + path = StringField() + sha256 = StringField() + size_in_bytes = IntegerField() + file_type = EnumField(FileType) + prefix_placeholder = StringField(required=False) + file_mode = EnumField(FileMode, required=False) + no_link = BooleanField(required=False, nullable=True) + inode_paths = ListField(string_types) + + class PackageInfo(Entity): - files = ListField(string_types) - has_prefix_files = ListField(string_types) - no_link = ListField(string_types) - soft_links = ListField(string_types) + files = ListField(PathInfo) index_json_record = ComposableField(Record) icondata = StringField() - noarch = MapField() + noarch = ComposableField(NoarchInfo) From acb92d3bda5cf70b92feaf2a772bdd165d31fe42 Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 10:54:51 -0600 Subject: [PATCH 03/17] Throw CondaUpgradeError for files.json wrong ver The version should be 1 --- conda/exceptions.py | 6 ++++++ conda/gateways/disk/read.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conda/exceptions.py b/conda/exceptions.py index b4270714f96..300ea569d3d 100644 --- a/conda/exceptions.py +++ b/conda/exceptions.py @@ -405,6 +405,12 @@ def __init__(self, message): super(CondaCorruptEnvironmentError, self).__init__(msg) +class CondaUpgradeError(CondaError): + def __init__(self, message): + msg = "Conda upgrade error: %s" % message + super(CondaUpgradeError, self).__init__(msg) + + def print_conda_exception(exception): from conda.base.context import context diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 0a589cb8ed8..109200ee8a2 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -13,6 +13,7 @@ from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 from ...models.package_info import PackageInfoContents, PackageInfo from ...models.record import Record +from ...exceptions import CondaUpgradeError log = getLogger(__name__) @@ -51,7 +52,7 @@ def collect_all_info_for_package(extracted_package_directory): with open(file_json_path) as file_json: data = json.load(file_json) if data.get('version') != 1: - raise CondaUpgradeError() + raise CondaUpgradeError("Expected files.json schema to be version 1") return PackageInfo(files=data['files'], index_json_record=read_index_json(extracted_package_directory), From 1c699954a900b6a77306df4f1c4781ee411995ac Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 11:54:14 -0600 Subject: [PATCH 04/17] Add FileMode and LinkType as exports --- conda/exports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/exports.py b/conda/exports.py index 5790d64103d..8fe0080d25b 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -80,7 +80,7 @@ from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines # NOQA non_x86_linux_machines = non_x86_linux_machines -from conda.base.constants import DEFAULT_CHANNELS # NOQA +from conda.base.constants import DEFAULT_CHANNELS, FileMode, LinkType # NOQA get_prefix = partial(context_get_prefix, conda.base.context.context) get_default_urls = lambda: DEFAULT_CHANNELS From dcd785064b10d1f99e9c25f9ff3cc196b97694cd Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 14:20:13 -0600 Subject: [PATCH 05/17] Rename FileType to NodeType --- conda/models/package_info.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/conda/models/package_info.py b/conda/models/package_info.py index a34a09115a8..c0e1bfb8097 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -24,17 +24,36 @@ class NoarchInfo(Entity): entry_points = ListField(string_types, required=False) -class FileType(Enum): +class NodeType(Enum): + """ + Refers to if the file in question is hard linked or soft linked. Originally designed to be used + in files.json + """ hardlink = 1 softlink = 2 - directory = 4 + + @classmethod + def __call__(cls, value, *args, **kwargs): + if isinstance(cls, value, *args, **kwargs): + return cls[value] + return super(NodeType, cls).__call__(value, *args, **kwargs) + + @classmethod + def __getitem__(cls, name): + return cls._member_map_[name.replace('-', '').replace('_', '').lower()] + + def __int__(self): + return self.value + + def __str__(self): + return self.name class PathInfo(Entity): path = StringField() sha256 = StringField() size_in_bytes = IntegerField() - file_type = EnumField(FileType) + node_type = EnumField(NodeType) prefix_placeholder = StringField(required=False) file_mode = EnumField(FileMode, required=False) no_link = BooleanField(required=False, nullable=True) From 471d3f338fd2373ce655eec3afb54cbc0f35be4b Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 14:37:46 -0600 Subject: [PATCH 06/17] Delete commented out code --- conda/gateways/disk/read.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 109200ee8a2..5dfe6353535 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -59,21 +59,6 @@ def collect_all_info_for_package(extracted_package_directory): noarch=read_noarch(extracted_package_directory), icondata=read_icondata(extracted_package_directory), ) - - - - # files = tuple(pluck("short_path", data)) - # has_prefix_files = { - # f.get("short_path"): tuple([f.get("prefix_placeholder"), f.get("file_mode")]) for f in - # data if f.get("prefix_placeholder") is not None} - # no_link = set([f.get("no_link") for f in data if f.get("no_link") is not None]) - # soft_links = tuple([f for f in list(pluck("file_type", data)) if f == "softlink"]) - # index_json_record = read_index_json(extracted_package_directory) - # icondata = read_icondata(extracted_package_directory) - # noarch = read_noarch(extracted_package_directory) - # return PackageInfoContents(files=files, has_prefix_files=has_prefix_files, no_link=no_link, - # soft_links=soft_links, index_json_record=index_json_record, - # icondata=icondata, noarch=noarch) else: files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) From 9fb81e01c03ef8c6b4cce8f2722c5d4869bdce19 Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 15:14:54 -0600 Subject: [PATCH 07/17] Export NodeType, EntityEncoder for conda-build --- conda/exports.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conda/exports.py b/conda/exports.py index 8fe0080d25b..5de170e33e4 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -80,7 +80,9 @@ from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines # NOQA non_x86_linux_machines = non_x86_linux_machines -from conda.base.constants import DEFAULT_CHANNELS, FileMode, LinkType # NOQA +from conda.base.constants import DEFAULT_CHANNELS, FileMode # NOQA +from conda.models.package_info import NodeType +from conda._vendor.auxlib.entity import EntityEncoder get_prefix = partial(context_get_prefix, conda.base.context.context) get_default_urls = lambda: DEFAULT_CHANNELS From b2d49b47b3d1255824048b1cb59ab5fae7f39281 Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 16:33:29 -0600 Subject: [PATCH 08/17] Refactor PathInfo Entity --- conda/gateways/disk/read.py | 5 ++--- conda/models/package_info.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 5dfe6353535..9050c55de58 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -11,7 +11,7 @@ from os.path import isfile, islink, join from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 -from ...models.package_info import PackageInfoContents, PackageInfo +from ...models.package_info import PackageInfoContents, PackageInfo, PathInfoV1 from ...models.record import Record from ...exceptions import CondaUpgradeError @@ -53,8 +53,7 @@ def collect_all_info_for_package(extracted_package_directory): data = json.load(file_json) if data.get('version') != 1: raise CondaUpgradeError("Expected files.json schema to be version 1") - - return PackageInfo(files=data['files'], + return PackageInfo(files=(PathInfoV1(**f) for f in data['files']), index_json_record=read_index_json(extracted_package_directory), noarch=read_noarch(extracted_package_directory), icondata=read_icondata(extracted_package_directory), diff --git a/conda/models/package_info.py b/conda/models/package_info.py index c0e1bfb8097..4b5fc4add2b 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -51,17 +51,21 @@ def __str__(self): class PathInfo(Entity): path = StringField() - sha256 = StringField() - size_in_bytes = IntegerField() - node_type = EnumField(NodeType) prefix_placeholder = StringField(required=False) file_mode = EnumField(FileMode, required=False) no_link = BooleanField(required=False, nullable=True) - inode_paths = ListField(string_types) + + +class PathInfoV1(PathInfo): + node_type = EnumField(NodeType) + sha256 = StringField() + size_in_bytes = IntegerField() + inode_paths = ListField(string_types, required=False, nullable=True) class PackageInfo(Entity): + path_info_version = IntegerField() files = ListField(PathInfo) index_json_record = ComposableField(Record) - icondata = StringField() - noarch = ComposableField(NoarchInfo) + icondata = StringField(required=False, nullable=True) + noarch = ComposableField(NoarchInfo, required=False, nullable=True) From 1b5a3bb8cd2e171c1ce534763dc83b6e144dbb2c Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 15 Nov 2016 17:01:35 -0600 Subject: [PATCH 09/17] Refactor how packages without files.json collect info --- conda/gateways/disk/read.py | 26 +++++++++++++++++++++----- conda/models/package_info.py | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 9050c55de58..f8e0882d70d 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -11,7 +11,7 @@ from os.path import isfile, islink, join from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 -from ...models.package_info import PackageInfoContents, PackageInfo, PathInfoV1 +from ...models.package_info import NodeType, PackageInfo, PathInfoV1, PathInfo from ...models.record import Record from ...exceptions import CondaUpgradeError @@ -57,18 +57,34 @@ def collect_all_info_for_package(extracted_package_directory): index_json_record=read_index_json(extracted_package_directory), noarch=read_noarch(extracted_package_directory), icondata=read_icondata(extracted_package_directory), - ) + path_info_version=1) else: files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) has_prefix_files = read_has_prefix(join(info_dir, 'has_prefix')) no_link = read_no_link(info_dir) soft_links = read_soft_links(extracted_package_directory, files) + + path_info_files = [] + for f in files: + path_info = {"path": f} + if f in has_prefix_files.keys(): + path_info["prefix_placeholder"] = has_prefix_files[f][0] + path_info["file_mode"] = has_prefix_files[f][1] + if f in no_link: + path_info["no_link"] = True + if islink(join(extracted_package_directory, f)): + path_info["node_type"] = NodeType.softlink + else: + path_info["node_type"] = NodeType.hardlink + path_info_files.append(PathInfo(**path_info)) + index_json_record = read_index_json(extracted_package_directory) icondata = read_icondata(extracted_package_directory) noarch = read_noarch(extracted_package_directory) - return PackageInfoContents(files, has_prefix_files, no_link, soft_links, - index_json_record, icondata, noarch) + + return PackageInfo(files=path_info_files, index_json_record=index_json_record, + icondata=icondata, noarch=noarch, path_info_version=0) def read_noarch(extracted_package_directory): @@ -77,7 +93,7 @@ def read_noarch(extracted_package_directory): with open(noarch_path, 'r') as f: return json.loads(f.read()) else: - return {} + return None def read_index_json(extracted_package_directory): diff --git a/conda/models/package_info.py b/conda/models/package_info.py index 4b5fc4add2b..7e6e33f1c0b 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -54,10 +54,10 @@ class PathInfo(Entity): prefix_placeholder = StringField(required=False) file_mode = EnumField(FileMode, required=False) no_link = BooleanField(required=False, nullable=True) + node_type = EnumField(NodeType) class PathInfoV1(PathInfo): - node_type = EnumField(NodeType) sha256 = StringField() size_in_bytes = IntegerField() inode_paths = ListField(string_types, required=False, nullable=True) From 4a3be8786f0e6561c87a5b8df06c5fbe2186a9b8 Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 16 Nov 2016 11:05:57 -0600 Subject: [PATCH 10/17] Update make link to use PackageInfo --- conda/core/install.py | 19 +++++++++++-------- tests/core/test_install.py | 32 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index ae9ec3de33b..e337c8808c4 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -26,6 +26,7 @@ from ..gateways.disk.read import collect_all_info_for_package, yield_lines from ..gateways.disk.update import _PaddingError, update_prefix from ..models.record import Link +from ..models.package_info import NodeType from ..utils import on_win try: @@ -96,20 +97,22 @@ def _make_link_operations(self, requested_link_type): # no side effects in this method! package_info = self.package_info - def make_link_operation(source_short_path): - if source_short_path in package_info.has_prefix_files: + def make_link_operation(source_path_info): + if getattr(source_path_info, "prefix_placeholder", None) is not None: link_type = LinkType.copy - prefix_placehoder, file_mode = package_info.has_prefix_files[source_short_path] - elif source_short_path in concatv(package_info.no_link, package_info.soft_links): + prefix_placehoder = source_path_info.prefix_placeholder + file_mode = source_path_info.file_mode + elif (getattr(source_path_info, "no_link", None) is not None or + source_path_info.node_type == NodeType.softlink): link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: link_type = requested_link_type prefix_placehoder, file_mode = '', None - is_menu_file = bool(MENU_RE.match(source_short_path)) - dest_short_path = source_short_path - return LinkOperation(source_short_path, dest_short_path, link_type, prefix_placehoder, - file_mode, is_menu_file) + is_menu_file = bool(MENU_RE.match(source_path_info.path)) + dest_short_path = source_path_info.path + return LinkOperation(source_path_info.path, dest_short_path, link_type, + prefix_placehoder, file_mode, is_menu_file) return tuple(make_link_operation(p) for p in package_info.files) def _execute_link_operations(self, leaf_directories, link_operations): diff --git a/tests/core/test_install.py b/tests/core/test_install.py index 5d4b7308a66..8e1be15889a 100644 --- a/tests/core/test_install.py +++ b/tests/core/test_install.py @@ -7,8 +7,9 @@ from conda.core.install import (PackageInstaller, PackageUninstaller, NoarchPythonPackageInstaller, LinkOperation) from conda.models.dist import Dist -from conda.models.package_info import PackageInfoContents -from conda.models.record import Link +from conda.models.package_info import (PackageInfoContents, PathInfo, PackageInfo, NoarchInfo, + NodeType) +from conda.models.record import Link, Record from conda.utils import on_win try: @@ -20,15 +21,17 @@ class TestPackageInstaller(unittest.TestCase): def setUp(self): self.dist = Dist("channel", "dist_name") - files = tuple(["test/path/1", "test/path/2", "test/path/3", "menu/test.json"]) - has_prefix_files = {"test/path/1": ("/opt/anaconda1anaconda2anaconda3", FileMode.text)} - no_link = set(["test/path/2"]) - soft_links = tuple(["test/path/3"]) - index_json_records = {"key": "value"} + index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" noarch = None - self.package_info = PackageInfoContents(files, has_prefix_files, no_link, soft_links, - index_json_records, icondata, noarch) + files = [PathInfo(path="test/path/1", file_mode=FileMode.text, node_type=NodeType.hardlink, + prefix_placeholder="/opt/anaconda1anaconda2anaconda3",), + PathInfo(path="test/path/2", no_link=True, node_type=NodeType.hardlink), + PathInfo(path="test/path/3", node_type=NodeType.softlink), + PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + + self.package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + index_json_record=index_json_records) def test_make_link_operation(self): package_installer = PackageInstaller("prefix", {}, self.dist) @@ -54,13 +57,10 @@ def test_create_meta(self): output = package_installer._create_meta(dest_short_paths, LinkType.directory, "http://test.url") - expected_output = {"key": "value", - "icon": "icon", - "url": "http://test.url", - "files": dest_short_paths, - "link": Link(source="extracted_package_dir", type=LinkType.directory), - "icondata": "icondata" - } + expected_output = Record(icon="icon", icondata="icondata", build=0, build_number=0, + name="test_foo", version=0, url="http://test.url", + files=dest_short_paths, + link=Link(source="extracted_package_dir", type=LinkType.directory)) self.assertEquals(output, expected_output) From bdeecccc21ddcb12f4179b7ae78c12eb4f4a8027 Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 16 Nov 2016 11:19:03 -0600 Subject: [PATCH 11/17] Make noarch install use PackageInfo --- conda/core/install.py | 13 ++++++++----- tests/core/test_install.py | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index e337c8808c4..e023d8203d0 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -189,21 +189,24 @@ def _make_link_operations(self, requested_link_type): site_packages_dir = get_site_packages_dir(self.prefix) bin_dir = get_bin_directory_short_path() - def make_link_operation(source_short_path): + def make_link_operation(source_path_info): # no side effects in this method! # first part, same as parent class - if source_short_path in package_info.has_prefix_files: + if getattr(source_path_info, "prefix_placeholder", None) is not None: link_type = LinkType.copy - prefix_placehoder, file_mode = package_info.has_prefix_files[source_short_path] - elif source_short_path in concatv(package_info.no_link, package_info.soft_links): + prefix_placehoder = source_path_info.prefix_placeholder + file_mode = source_path_info.file_mode + elif (getattr(source_path_info, "no_link", None) is not None or + source_path_info.node_type == NodeType.softlink): link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: link_type = requested_link_type prefix_placehoder, file_mode = '', None - is_menu_file = bool(MENU_RE.match(source_short_path)) + is_menu_file = bool(MENU_RE.match(source_path_info.path)) + source_short_path = source_path_info.path # second part, noarch python-specific if source_short_path.startswith('site-packages/'): dest_short_path = site_packages_dir + source_short_path.replace( diff --git a/tests/core/test_install.py b/tests/core/test_install.py index 8e1be15889a..b4d4a2ff9e6 100644 --- a/tests/core/test_install.py +++ b/tests/core/test_install.py @@ -23,7 +23,6 @@ def setUp(self): self.dist = Dist("channel", "dist_name") index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - noarch = None files = [PathInfo(path="test/path/1", file_mode=FileMode.text, node_type=NodeType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3",), PathInfo(path="test/path/2", no_link=True, node_type=NodeType.hardlink), @@ -67,17 +66,18 @@ def test_create_meta(self): class TestNoarchPackageInstaller(unittest.TestCase): def setUp(self): self.dist = Dist("channel", "dist_name") - files = tuple(["site-packages/test/1", "python-scripts/test/2", "test/path/3", - "menu/test.json"]) - has_prefix_files = {"site-packages/test/1": ("/opt/anaconda1anaconda2anaconda3", - FileMode.text)} - no_link = set(["python-scripts/test/2"]) - soft_links = tuple(["test/path/3"]) - index_json_records = {"key": "value"} + index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - noarch = None - self.package_info = PackageInfoContents(files, has_prefix_files, no_link, soft_links, - index_json_records, icondata, noarch) + + files = [PathInfo(path="site-packages/test/1", file_mode=FileMode.text, + node_type=NodeType.hardlink, + prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), + PathInfo(path="python-scripts/test/2", no_link=True, node_type=NodeType.hardlink), + PathInfo(path="test/path/3", node_type=NodeType.softlink), + PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + + self.package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + index_json_record=index_json_records) @patch("conda.core.linked_data.get_python_version_for_prefix", return_value="2.4") def test_make_link_operation(self, get_site_packages_dir): @@ -102,7 +102,6 @@ def test_make_link_operation(self, get_site_packages_dir): LinkOperation("menu/test.json", "menu/test.json", LinkType.softlink, "", None, True)]) - # import pdb; pdb.set_trace() assert output == expected_output From 60e190fad3d0b9962537c8121c701bb221b1d40f Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 16 Nov 2016 13:48:45 -0600 Subject: [PATCH 12/17] Flask 8 errors --- conda/core/install.py | 4 ++-- conda/exports.py | 8 +++++--- conda/gateways/disk/read.py | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index e023d8203d0..a1b22d1db4e 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -103,7 +103,7 @@ def make_link_operation(source_path_info): prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode elif (getattr(source_path_info, "no_link", None) is not None or - source_path_info.node_type == NodeType.softlink): + source_path_info.node_type == NodeType.softlink): link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: @@ -198,7 +198,7 @@ def make_link_operation(source_path_info): prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode elif (getattr(source_path_info, "no_link", None) is not None or - source_path_info.node_type == NodeType.softlink): + source_path_info.node_type == NodeType.softlink): link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: diff --git a/conda/exports.py b/conda/exports.py index 5de170e33e4..94794248cd0 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -80,9 +80,11 @@ from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines # NOQA non_x86_linux_machines = non_x86_linux_machines -from conda.base.constants import DEFAULT_CHANNELS, FileMode # NOQA -from conda.models.package_info import NodeType -from conda._vendor.auxlib.entity import EntityEncoder +from conda.base.constants import DEFAULT_CHANNELS # NOQA +from conda.models.package_info import NodeType # NOQA +from conda._vendor.auxlib.entity import EntityEncoder # NOQA +NodeType = NodeType +EntityEncoder = EntityEncoder get_prefix = partial(context_get_prefix, conda.base.context.context) get_default_urls = lambda: DEFAULT_CHANNELS diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index f8e0882d70d..ea396fabb38 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -63,7 +63,6 @@ def collect_all_info_for_package(extracted_package_directory): has_prefix_files = read_has_prefix(join(info_dir, 'has_prefix')) no_link = read_no_link(info_dir) - soft_links = read_soft_links(extracted_package_directory, files) path_info_files = [] for f in files: From 00212d448ca50890b43ddf35f6d70407d39d5d98 Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 16 Nov 2016 16:16:45 -0600 Subject: [PATCH 13/17] Test PackageInfo model --- tests/models/test_package_info.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/models/test_package_info.py diff --git a/tests/models/test_package_info.py b/tests/models/test_package_info.py new file mode 100644 index 00000000000..a0690ef771e --- /dev/null +++ b/tests/models/test_package_info.py @@ -0,0 +1,23 @@ +from conda.models.package_info import PackageInfo, PathInfo, NodeType, NoarchInfo +from conda.base.constants import FileMode +from conda.models.record import Record +from unittest import TestCase + + +class DefaultPackageInfo(TestCase): + def test_package_info(self): + index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) + icondata = "icondata" + noarch = NoarchInfo(type="python", entry_points=["test:foo"]) + files = [PathInfo(path="test/path/1", file_mode=FileMode.text, node_type=NodeType.hardlink, + prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), + PathInfo(path="test/path/2", no_link=True, node_type=NodeType.hardlink), + PathInfo(path="test/path/3", node_type=NodeType.softlink), + PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + + package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + index_json_record=index_json_records, noarch=noarch) + self.assertIsInstance(package_info.files[0], PathInfo) + self.assertIsInstance(package_info.index_json_record, Record) + self.assertIsInstance(package_info.noarch, NoarchInfo) + self.assertEquals(package_info.files[0].path, "test/path/1") From a1d480381a39f5b1140e083c8a9a6424befe3471 Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 16 Nov 2016 16:19:51 -0600 Subject: [PATCH 14/17] Misc tweeks --- conda/core/install.py | 12 +++++------- conda/exports.py | 4 ++-- conda/gateways/disk/read.py | 16 ++++++++++------ conda/models/package_info.py | 10 ++-------- tests/core/test_install.py | 3 +-- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index a1b22d1db4e..4830f016c13 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -98,12 +98,11 @@ def _make_link_operations(self, requested_link_type): package_info = self.package_info def make_link_operation(source_path_info): - if getattr(source_path_info, "prefix_placeholder", None) is not None: + if source_path_info.prefix_placeholder: link_type = LinkType.copy prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode - elif (getattr(source_path_info, "no_link", None) is not None or - source_path_info.node_type == NodeType.softlink): + elif source_path_info.no_link or source_path_info.node_type == NodeType.softlink: link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: @@ -193,12 +192,11 @@ def make_link_operation(source_path_info): # no side effects in this method! # first part, same as parent class - if getattr(source_path_info, "prefix_placeholder", None) is not None: + if source_path_info.prefix_placeholder: link_type = LinkType.copy prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode - elif (getattr(source_path_info, "no_link", None) is not None or - source_path_info.node_type == NodeType.softlink): + elif source_path_info.no_link or source_path_info.node_type == NodeType.softlink: link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: @@ -230,7 +228,7 @@ def _execute_link_operations(self, leaf_directories, link_operations): tuple(op.dest_short_path for op in link_operations)) # create entry points - entry_points = self.package_info.noarch.get('entry_points', ()) + entry_points = self.package_info.noarch.entry_points entry_point_paths = [] for entry_point in entry_points: entry_point_paths.extend(create_entry_point(entry_point, self.prefix)) diff --git a/conda/exports.py b/conda/exports.py index 94794248cd0..0ea463db16e 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -81,8 +81,8 @@ non_x86_linux_machines = non_x86_linux_machines from conda.base.constants import DEFAULT_CHANNELS # NOQA -from conda.models.package_info import NodeType # NOQA -from conda._vendor.auxlib.entity import EntityEncoder # NOQA +from .models.package_info import NodeType # NOQA +from ._vendor.auxlib.entity import EntityEncoder # NOQA NodeType = NodeType EntityEncoder = EntityEncoder get_prefix = partial(context_get_prefix, conda.base.context.context) diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index ea396fabb38..8a799fe996d 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -52,12 +52,16 @@ def collect_all_info_for_package(extracted_package_directory): with open(file_json_path) as file_json: data = json.load(file_json) if data.get('version') != 1: - raise CondaUpgradeError("Expected files.json schema to be version 1") - return PackageInfo(files=(PathInfoV1(**f) for f in data['files']), - index_json_record=read_index_json(extracted_package_directory), - noarch=read_noarch(extracted_package_directory), - icondata=read_icondata(extracted_package_directory), - path_info_version=1) + raise CondaUpgradeError("""The current version of conda is too old to install this +package. (This version only supports files.json schema version 1.) Please update conda to install +this package.""") + + files = (PathInfoV1(**f) for f in data['files']) + index_json_record = read_index_json(extracted_package_directory) + noarch = read_noarch(extracted_package_directory) + icondata = read_icondata(extracted_package_directory) + return PackageInfo(files=files, index_json_record=index_json_record, noarch=noarch, + icondata=icondata, path_info_version=1) else: files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) diff --git a/conda/models/package_info.py b/conda/models/package_info.py index 7e6e33f1c0b..6ab5b6bbe60 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals -from collections import namedtuple from enum import Enum from logging import getLogger @@ -14,11 +13,6 @@ log = getLogger(__name__) -PackageInfoContents = namedtuple('PackageInfoContents', - ('files', 'has_prefix_files', 'no_link', 'soft_links', - 'index_json_record', 'icondata', 'noarch')) - - class NoarchInfo(Entity): type = StringField() entry_points = ListField(string_types, required=False) @@ -51,8 +45,8 @@ def __str__(self): class PathInfo(Entity): path = StringField() - prefix_placeholder = StringField(required=False) - file_mode = EnumField(FileMode, required=False) + prefix_placeholder = StringField(required=False, nullable=True) + file_mode = EnumField(FileMode, required=False, nullable=True) no_link = BooleanField(required=False, nullable=True) node_type = EnumField(NodeType) diff --git a/tests/core/test_install.py b/tests/core/test_install.py index b4d4a2ff9e6..6259144752b 100644 --- a/tests/core/test_install.py +++ b/tests/core/test_install.py @@ -7,8 +7,7 @@ from conda.core.install import (PackageInstaller, PackageUninstaller, NoarchPythonPackageInstaller, LinkOperation) from conda.models.dist import Dist -from conda.models.package_info import (PackageInfoContents, PathInfo, PackageInfo, NoarchInfo, - NodeType) +from conda.models.package_info import PathInfo, PackageInfo, NoarchInfo, NodeType from conda.models.record import Link, Record from conda.utils import on_win From d60fe718671ce2fd4b55eafe71405d7644ca6eea Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Thu, 17 Nov 2016 17:38:47 -0600 Subject: [PATCH 15/17] changes to match conda-build --- conda/core/install.py | 6 +++--- conda/exports.py | 4 ++-- conda/gateways/disk/read.py | 18 +++++++++--------- conda/models/package_info.py | 29 ++++++++++++----------------- tests/core/test_install.py | 26 +++++++++++++------------- tests/models/test_package_info.py | 16 ++++++++-------- 6 files changed, 47 insertions(+), 52 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index 4830f016c13..1e49913e0fb 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -26,7 +26,7 @@ from ..gateways.disk.read import collect_all_info_for_package, yield_lines from ..gateways.disk.update import _PaddingError, update_prefix from ..models.record import Link -from ..models.package_info import NodeType +from ..models.package_info import PathType from ..utils import on_win try: @@ -102,7 +102,7 @@ def make_link_operation(source_path_info): link_type = LinkType.copy prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode - elif source_path_info.no_link or source_path_info.node_type == NodeType.softlink: + elif source_path_info.no_link or source_path_info.path_type == PathType.softlink: link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: @@ -196,7 +196,7 @@ def make_link_operation(source_path_info): link_type = LinkType.copy prefix_placehoder = source_path_info.prefix_placeholder file_mode = source_path_info.file_mode - elif source_path_info.no_link or source_path_info.node_type == NodeType.softlink: + elif source_path_info.no_link or source_path_info.path_type == PathType.softlink: link_type = LinkType.copy prefix_placehoder, file_mode = '', None else: diff --git a/conda/exports.py b/conda/exports.py index 0ea463db16e..6f10e2fea5f 100644 --- a/conda/exports.py +++ b/conda/exports.py @@ -81,9 +81,9 @@ non_x86_linux_machines = non_x86_linux_machines from conda.base.constants import DEFAULT_CHANNELS # NOQA -from .models.package_info import NodeType # NOQA +from .models.package_info import PathType # NOQA from ._vendor.auxlib.entity import EntityEncoder # NOQA -NodeType = NodeType +PathType = PathType EntityEncoder = EntityEncoder get_prefix = partial(context_get_prefix, conda.base.context.context) get_default_urls = lambda: DEFAULT_CHANNELS diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 8a799fe996d..641fc0218b8 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -11,7 +11,7 @@ from os.path import isfile, islink, join from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8 -from ...models.package_info import NodeType, PackageInfo, PathInfoV1, PathInfo +from ...models.package_info import PathType, PackageInfo, PathInfoV1, PathInfo from ...models.record import Record from ...exceptions import CondaUpgradeError @@ -51,17 +51,17 @@ def collect_all_info_for_package(extracted_package_directory): if isfile(file_json_path): with open(file_json_path) as file_json: data = json.load(file_json) - if data.get('version') != 1: + if data.get('paths_version') != 1: raise CondaUpgradeError("""The current version of conda is too old to install this package. (This version only supports files.json schema version 1.) Please update conda to install this package.""") - files = (PathInfoV1(**f) for f in data['files']) + paths = (PathInfoV1(**f) for f in data['paths']) index_json_record = read_index_json(extracted_package_directory) noarch = read_noarch(extracted_package_directory) icondata = read_icondata(extracted_package_directory) - return PackageInfo(files=files, index_json_record=index_json_record, noarch=noarch, - icondata=icondata, path_info_version=1) + return PackageInfo(paths=paths, index_json_record=index_json_record, noarch=noarch, + icondata=icondata, paths_version=1) else: files = tuple(ln for ln in (line.strip() for line in yield_lines(files_path)) if ln) @@ -77,17 +77,17 @@ def collect_all_info_for_package(extracted_package_directory): if f in no_link: path_info["no_link"] = True if islink(join(extracted_package_directory, f)): - path_info["node_type"] = NodeType.softlink + path_info["path_type"] = PathType.softlink else: - path_info["node_type"] = NodeType.hardlink + path_info["path_type"] = PathType.hardlink path_info_files.append(PathInfo(**path_info)) index_json_record = read_index_json(extracted_package_directory) icondata = read_icondata(extracted_package_directory) noarch = read_noarch(extracted_package_directory) - return PackageInfo(files=path_info_files, index_json_record=index_json_record, - icondata=icondata, noarch=noarch, path_info_version=0) + return PackageInfo(paths=path_info_files, index_json_record=index_json_record, + icondata=icondata, noarch=noarch, paths_version=0) def read_noarch(extracted_package_directory): diff --git a/conda/models/package_info.py b/conda/models/package_info.py index 6ab5b6bbe60..7a120f5a97b 100644 --- a/conda/models/package_info.py +++ b/conda/models/package_info.py @@ -18,23 +18,13 @@ class NoarchInfo(Entity): entry_points = ListField(string_types, required=False) -class NodeType(Enum): +class PathType(Enum): """ Refers to if the file in question is hard linked or soft linked. Originally designed to be used in files.json """ - hardlink = 1 - softlink = 2 - - @classmethod - def __call__(cls, value, *args, **kwargs): - if isinstance(cls, value, *args, **kwargs): - return cls[value] - return super(NodeType, cls).__call__(value, *args, **kwargs) - - @classmethod - def __getitem__(cls, name): - return cls._member_map_[name.replace('-', '').replace('_', '').lower()] + hardlink = 'hardlink' + softlink = 'softlink' def __int__(self): return self.value @@ -44,11 +34,16 @@ def __str__(self): class PathInfo(Entity): - path = StringField() + _path = StringField() prefix_placeholder = StringField(required=False, nullable=True) file_mode = EnumField(FileMode, required=False, nullable=True) no_link = BooleanField(required=False, nullable=True) - node_type = EnumField(NodeType) + path_type = EnumField(PathType) + + @property + def path(self): + # because I don't have aliases as an option for entity fields yet + return self._path class PathInfoV1(PathInfo): @@ -58,8 +53,8 @@ class PathInfoV1(PathInfo): class PackageInfo(Entity): - path_info_version = IntegerField() - files = ListField(PathInfo) + paths_version = IntegerField() + paths = ListField(PathInfo) index_json_record = ComposableField(Record) icondata = StringField(required=False, nullable=True) noarch = ComposableField(NoarchInfo, required=False, nullable=True) diff --git a/tests/core/test_install.py b/tests/core/test_install.py index 6259144752b..54dc95d601d 100644 --- a/tests/core/test_install.py +++ b/tests/core/test_install.py @@ -7,7 +7,7 @@ from conda.core.install import (PackageInstaller, PackageUninstaller, NoarchPythonPackageInstaller, LinkOperation) from conda.models.dist import Dist -from conda.models.package_info import PathInfo, PackageInfo, NoarchInfo, NodeType +from conda.models.package_info import PathInfo, PackageInfo, NoarchInfo, PathType from conda.models.record import Link, Record from conda.utils import on_win @@ -22,13 +22,13 @@ def setUp(self): self.dist = Dist("channel", "dist_name") index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - files = [PathInfo(path="test/path/1", file_mode=FileMode.text, node_type=NodeType.hardlink, - prefix_placeholder="/opt/anaconda1anaconda2anaconda3",), - PathInfo(path="test/path/2", no_link=True, node_type=NodeType.hardlink), - PathInfo(path="test/path/3", node_type=NodeType.softlink), - PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + paths = [PathInfo(path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, + prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), + PathInfo(path="test/path/2", no_link=True, path_type=PathType.hardlink), + PathInfo(path="test/path/3", path_type=PathType.softlink), + PathInfo(path="menu/test.json", path_type=PathType.hardlink)] - self.package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + self.package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records) def test_make_link_operation(self): @@ -68,14 +68,14 @@ def setUp(self): index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - files = [PathInfo(path="site-packages/test/1", file_mode=FileMode.text, - node_type=NodeType.hardlink, + paths = [PathInfo(path="site-packages/test/1", file_mode=FileMode.text, + path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), - PathInfo(path="python-scripts/test/2", no_link=True, node_type=NodeType.hardlink), - PathInfo(path="test/path/3", node_type=NodeType.softlink), - PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + PathInfo(path="python-scripts/test/2", no_link=True, path_type=PathType.hardlink), + PathInfo(path="test/path/3", path_type=PathType.softlink), + PathInfo(path="menu/test.json", path_type=PathType.hardlink)] - self.package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + self.package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records) @patch("conda.core.linked_data.get_python_version_for_prefix", return_value="2.4") diff --git a/tests/models/test_package_info.py b/tests/models/test_package_info.py index a0690ef771e..a84838fe65d 100644 --- a/tests/models/test_package_info.py +++ b/tests/models/test_package_info.py @@ -1,4 +1,4 @@ -from conda.models.package_info import PackageInfo, PathInfo, NodeType, NoarchInfo +from conda.models.package_info import PackageInfo, PathInfo, PathType, NoarchInfo from conda.base.constants import FileMode from conda.models.record import Record from unittest import TestCase @@ -9,15 +9,15 @@ def test_package_info(self): index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" noarch = NoarchInfo(type="python", entry_points=["test:foo"]) - files = [PathInfo(path="test/path/1", file_mode=FileMode.text, node_type=NodeType.hardlink, + paths = [PathInfo(path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), - PathInfo(path="test/path/2", no_link=True, node_type=NodeType.hardlink), - PathInfo(path="test/path/3", node_type=NodeType.softlink), - PathInfo(path="menu/test.json", node_type=NodeType.hardlink)] + PathInfo(path="test/path/2", no_link=True, path_type=PathType.hardlink), + PathInfo(path="test/path/3", path_type=PathType.softlink), + PathInfo(path="menu/test.json", path_type=PathType.hardlink)] - package_info = PackageInfo(path_info_version=0, files=files, icondata=icondata, + package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records, noarch=noarch) - self.assertIsInstance(package_info.files[0], PathInfo) + self.assertIsInstance(package_info.paths[0], PathInfo) self.assertIsInstance(package_info.index_json_record, Record) self.assertIsInstance(package_info.noarch, NoarchInfo) - self.assertEquals(package_info.files[0].path, "test/path/1") + self.assertEquals(package_info.paths[0].path, "test/path/1") From 922acc4c946ad5c5b56f3fe956c76437378af98b Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Mon, 21 Nov 2016 12:10:46 -0600 Subject: [PATCH 16/17] fix errors --- conda/core/install.py | 4 ++-- conda/gateways/disk/read.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conda/core/install.py b/conda/core/install.py index 1e49913e0fb..bb019000c61 100644 --- a/conda/core/install.py +++ b/conda/core/install.py @@ -112,7 +112,7 @@ def make_link_operation(source_path_info): dest_short_path = source_path_info.path return LinkOperation(source_path_info.path, dest_short_path, link_type, prefix_placehoder, file_mode, is_menu_file) - return tuple(make_link_operation(p) for p in package_info.files) + return tuple(make_link_operation(p) for p in package_info.paths) def _execute_link_operations(self, leaf_directories, link_operations): # major side-effects in this method @@ -216,7 +216,7 @@ def make_link_operation(source_path_info): return LinkOperation(source_short_path, dest_short_path, link_type, prefix_placehoder, file_mode, is_menu_file) - return tuple(make_link_operation(p) for p in package_info.files) + return tuple(make_link_operation(p) for p in package_info.paths) def _execute_link_operations(self, leaf_directories, link_operations): dest_short_paths = super(NoarchPythonPackageInstaller, self)._execute_link_operations( diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py index 641fc0218b8..56b63401c8c 100644 --- a/conda/gateways/disk/read.py +++ b/conda/gateways/disk/read.py @@ -70,7 +70,7 @@ def collect_all_info_for_package(extracted_package_directory): path_info_files = [] for f in files: - path_info = {"path": f} + path_info = {"_path": f} if f in has_prefix_files.keys(): path_info["prefix_placeholder"] = has_prefix_files[f][0] path_info["file_mode"] = has_prefix_files[f][1] From fa6ce716b4f60e0ae27e006a177e3ac9d06027bc Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Mon, 21 Nov 2016 18:27:59 -0600 Subject: [PATCH 17/17] fix last four errors --- tests/core/test_install.py | 16 ++++++++-------- tests/models/test_package_info.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/core/test_install.py b/tests/core/test_install.py index 54dc95d601d..cdde51912c8 100644 --- a/tests/core/test_install.py +++ b/tests/core/test_install.py @@ -22,11 +22,11 @@ def setUp(self): self.dist = Dist("channel", "dist_name") index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - paths = [PathInfo(path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, + paths = [PathInfo(_path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), - PathInfo(path="test/path/2", no_link=True, path_type=PathType.hardlink), - PathInfo(path="test/path/3", path_type=PathType.softlink), - PathInfo(path="menu/test.json", path_type=PathType.hardlink)] + PathInfo(_path="test/path/2", no_link=True, path_type=PathType.hardlink), + PathInfo(_path="test/path/3", path_type=PathType.softlink), + PathInfo(_path="menu/test.json", path_type=PathType.hardlink)] self.package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records) @@ -68,12 +68,12 @@ def setUp(self): index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" - paths = [PathInfo(path="site-packages/test/1", file_mode=FileMode.text, + paths = [PathInfo(_path="site-packages/test/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), - PathInfo(path="python-scripts/test/2", no_link=True, path_type=PathType.hardlink), - PathInfo(path="test/path/3", path_type=PathType.softlink), - PathInfo(path="menu/test.json", path_type=PathType.hardlink)] + PathInfo(_path="python-scripts/test/2", no_link=True, path_type=PathType.hardlink), + PathInfo(_path="test/path/3", path_type=PathType.softlink), + PathInfo(_path="menu/test.json", path_type=PathType.hardlink)] self.package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records) diff --git a/tests/models/test_package_info.py b/tests/models/test_package_info.py index a84838fe65d..f19d202d56c 100644 --- a/tests/models/test_package_info.py +++ b/tests/models/test_package_info.py @@ -9,11 +9,11 @@ def test_package_info(self): index_json_records = Record(build=0, build_number=0, name="test_foo", version=0) icondata = "icondata" noarch = NoarchInfo(type="python", entry_points=["test:foo"]) - paths = [PathInfo(path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, + paths = [PathInfo(_path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), - PathInfo(path="test/path/2", no_link=True, path_type=PathType.hardlink), - PathInfo(path="test/path/3", path_type=PathType.softlink), - PathInfo(path="menu/test.json", path_type=PathType.hardlink)] + PathInfo(_path="test/path/2", no_link=True, path_type=PathType.hardlink), + PathInfo(_path="test/path/3", path_type=PathType.softlink), + PathInfo(_path="menu/test.json", path_type=PathType.hardlink)] package_info = PackageInfo(paths_version=0, paths=paths, icondata=icondata, index_json_record=index_json_records, noarch=noarch)