def test_progess(self): index = {"This is an index": True} plan = [("PROGRESS", "2"), ("LINK", "ipython"), ("LINK", "menuinst")] def cmd(state, arg): pass # NO-OP _commands = {"PROGRESS": PROGRESS_CMD, "LINK": cmd} h = TestHandler() update_logger = getLogger("progress.update") update_logger.setLevel(DEBUG) update_logger.addHandler(h) stop_logger = getLogger("progress.stop") stop_logger.setLevel(DEBUG) stop_logger.addHandler(h) execute_instructions(plan, index, _commands=_commands) update_logger.removeHandler(h) stop_logger.removeHandler(h) expected = [("progress.update", ("ipython", 0)), ("progress.update", ("menuinst", 1)), ("progress.stop", None)] self.assertEqual(h.records, expected)
def test_progess(self): index = {'This is an index': True} plan = [ ('PROGRESS', '2'), ('LINK', 'ipython'), ('LINK', 'menuinst'), ] def cmd(state, arg): pass # NO-OP _commands = {'PROGRESS': PROGRESS_CMD, 'LINK': cmd} h = TestHandler() update_logger = getLogger('progress.update') update_logger.setLevel(DEBUG) update_logger.addHandler(h) stop_logger = getLogger('progress.stop') stop_logger.setLevel(DEBUG) stop_logger.addHandler(h) execute_instructions(plan, index, _commands=_commands) update_logger.removeHandler(h) stop_logger.removeHandler(h) expected = [('progress.update', ('ipython', 0)), ('progress.update', ('menuinst', 1)), ('progress.stop', None) ] self.assertEqual(h.records, expected)
def test_invalid_instruction(self): index = {"This is an index": True} plan = [("DOES_NOT_EXIST", ())] with self.assertRaises(exceptions.InvalidInstruction): execute_instructions(plan, index, verbose=False)
def old_clone_bundle(path, prefix): """ Clone the bundle (located at `path`) by creating a new environment at `prefix`. The directory `path` is located in should be some temp directory or some other directory OUTSITE /opt/anaconda (this function handles copying the of the file if necessary for you). After calling this funtion, the original file (at `path`) may be removed. """ assert not abspath(path).startswith(abspath(config.root_dir)) assert not isdir(prefix) fn = basename(path) assert re.match(r'share-[0-9a-f]{40}-\d+\.tar\.bz2$', fn), fn dist = fn[:-8] pkgs_dir = config.pkgs_dirs[0] if not install.is_extracted(pkgs_dir, dist): shutil.copyfile(path, join(pkgs_dir, dist + '.tar.bz2')) inst.execute_instructions([(inst.EXTRACT, (dist,))]) assert install.is_extracted(pkgs_dir, dist) with open(join(pkgs_dir, dist, 'info', 'index.json')) as fi: meta = json.load(fi) # for backwards compatibility, use "requires" when "depends" is not there dists = ['-'.join(r.split()) for r in meta.get('depends', meta.get('requires', [])) if not r.startswith('conda ')] dists.append(dist) actions = plan.ensure_linked_actions(dists, prefix) index = get_index() plan.execute_actions(actions, index, verbose=False) os.unlink(join(prefix, 'conda-meta', dist + '.json'))
def test_simple_instruction(self): index = {'This is an index': True} def simple_cmd(state, arg): simple_cmd.called = True simple_cmd.call_args = (arg,) commands['SIMPLE'] = simple_cmd plan = [('SIMPLE', ('arg1',))] execute_instructions(plan, index, verbose=False) self.assertTrue(simple_cmd.called) self.assertTrue(simple_cmd.call_args, ('arg1',))
def test_simple_instruction(self): index = {"This is an index": True} def simple_cmd(state, arg): simple_cmd.called = True simple_cmd.call_args = (arg,) commands["SIMPLE"] = simple_cmd plan = [("SIMPLE", ("arg1",))] execute_instructions(plan, index, verbose=False) self.assertTrue(simple_cmd.called) self.assertTrue(simple_cmd.call_args, ("arg1",))
def test_state(self): index = {"This is an index": True} def simple_cmd(state, expect, x): state.setdefault("x", 1) self.assertEqual(state["x"], expect) state["x"] = x simple_cmd.called = True commands["SIMPLE"] = simple_cmd plan = [("SIMPLE", (1, 5)), ("SIMPLE", (5, None))] execute_instructions(plan, index, verbose=False) self.assertTrue(simple_cmd.called)
def test_state(self): index = {'This is an index': True} def simple_cmd(state, arg): expect, x = arg state.setdefault('x', 1) self.assertEqual(state['x'], expect) state['x'] = x simple_cmd.called = True commands['SIMPLE'] = simple_cmd plan = [('SIMPLE', (1, 5)), ('SIMPLE', (5, None)), ] execute_instructions(plan, index, verbose=False) self.assertTrue(simple_cmd.called)
def execute_plan(old_plan, index=None, verbose=False): """ Deprecated: This should `conda.instructions.execute_instructions` instead """ plan = update_old_plan(old_plan) inst.execute_instructions(plan, index, verbose)
def execute_actions(actions, index=None, verbose=False): plan = plan_from_actions(actions) with History(actions[inst.PREFIX]): inst.execute_instructions(plan, index, verbose)
saw_build_link = True link(prefix, arg, index=index) elif cmd == UNLINK: install.unlink(prefix, arg) elif cmd == SYMLINK_CONDA: install.symlink_conda(prefix, arg) else: raise Exception("Did not expect command: %r" % cmd) >>>>>>> princeofdarkness76/rpath if not isinstance(actions[inst.PREFIX], (list, tuple)): actions[inst.PREFIX] = [actions[inst.PREFIX]] <<<<<<< HEAD with History(actions[inst.PREFIX][0]): inst.execute_instructions(plan, index, verbose) ======= if saw_build_link and config.post_link_patch_rpaths: print("Patching build environment...") assert prefix != config.root_dir, prefix from conda_build.dll import BuildRoot build_root = BuildRoot( prefix=prefix, forgiving=True, is_build=False, ) build_root.make_relocatable(copy=True) if saw_build_link and config.post_link_patch_rpaths: print("Patching build environment...") assert prefix != config.root_dir, prefix