Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wolfv/7ca864345f38bfe31b846b04e4eba3c1 to your computer and use it in GitHub Desktop.
Save wolfv/7ca864345f38bfe31b846b04e4eba3c1 to your computer and use it in GitHub Desktop.
Problems explorations for libmambapy
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "6804a4e2",
"metadata": {},
"outputs": [],
"source": [
"import libmambapy\n",
"from mamba.utils import load_channels\n",
"\n",
"libmambapy.PackageInfo.__str__ = lambda self: self.name + \"-\" + self.version + \"-\" + self.build_string"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b1118a5b",
"metadata": {},
"outputs": [],
"source": [
"pool = libmambapy.Pool()\n",
"repos = []\n",
"\n",
"# change this to point where you cloned mamba\n",
"\n",
"channels = [\n",
" \"file:///Users/wolfvollprecht/Programs/mamba/mamba/tests/channel_a\"\n",
"]\n",
"\n",
"subdirs = load_channels(pool, channels, repos, prepend=False, platform=\"linux-64\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b753bd4f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(<libmambapy.bindings.SubdirData at 0x106b54930>,\n",
" {'platform': 'linux-64',\n",
" 'url': 'file:///Users/wolfvollprecht/Programs/mamba/mamba/tests/channel_a/linux-64',\n",
" 'channel': channel_a[linux-64,noarch]}),\n",
" (<libmambapy.bindings.SubdirData at 0x106b4e1b0>,\n",
" {'platform': 'noarch',\n",
" 'url': 'file:///Users/wolfvollprecht/Programs/mamba/mamba/tests/channel_a/noarch',\n",
" 'channel': channel_a[linux-64,noarch]})]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"subdirs"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0689068c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"specs = [\n",
" \"A=0.1.0\", \"A=0.2.0\"\n",
"]\n",
"\n",
"solver_options = [(libmambapy.SOLVER_FLAG_ALLOW_DOWNGRADE, 1)]\n",
"solver = libmambapy.Solver(pool, solver_options)\n",
"\n",
"solver.add_jobs(specs, libmambapy.SOLVER_INSTALL)\n",
"success = solver.solve()\n",
"print(success)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fc0bf159",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[<libmambapy.bindings.SolverProblem object at 0x106b820b0>, <libmambapy.bindings.SolverProblem object at 0x106b82470>, <libmambapy.bindings.SolverProblem object at 0x106b827b0>]\n"
]
}
],
"source": [
"problems = solver.all_problems_structured()\n",
"print(problems)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0fc80384",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SolverRuleinfo.SOLVER_RULE_PKG_SAME_NAME : 3 ➔ 0 ➔ 2\n",
" SolverRuleinfo.SOLVER_RULE_JOB : 2 ➔ -2147483641 ➔ 259\n",
" SolverRuleinfo.SOLVER_RULE_JOB : 0 ➔ -2147483642 ➔ 259\n"
]
}
],
"source": [
"for p in problems:\n",
" print(\"{_type:>40} : {source} ➔ {dep} ➔ {target}\".format(\n",
" _type=str(p.type),\n",
" source=str(p.source_id),\n",
" dep=p.dep_id,\n",
" target=str(p.target_id)\n",
" ))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8b818ae4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SolverRuleinfo.SOLVER_RULE_PKG_SAME_NAME : a-0.2.0-abc ➔ None ➔ a-0.1.0-abc\n",
" SolverRuleinfo.SOLVER_RULE_JOB : a-0.1.0-abc ➔ a 0.2.0** ➔ None\n",
" SolverRuleinfo.SOLVER_RULE_JOB : None ➔ a 0.1.0** ➔ None\n"
]
}
],
"source": [
"for p in problems:\n",
" print(\"{_type:>40} : {source} ➔ {dep} ➔ {target}\".format(\n",
" _type=str(p.type),\n",
" source=str(p.source()),\n",
" dep=p.dep(),\n",
" target=str(p.target())\n",
" ))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "396954d6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SolverRuleinfo.SOLVER_RULE_PKG_SAME_NAME : cannot install both a-0.2.0-abc and a-0.1.0-abc\n",
" SolverRuleinfo.SOLVER_RULE_JOB : conflicting requests\n",
" SolverRuleinfo.SOLVER_RULE_JOB : conflicting requests\n"
]
}
],
"source": [
"for p in problems:\n",
" print(\"{_type:>40} : {problemstr}\".format(\n",
" _type=str(p.type),\n",
" problemstr=str(p),\n",
" ))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2083ad45",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment