Last active
December 2, 2022 21:18
-
-
Save beckermr/7f64f95343a8300aa2c46706975bd226 to your computer and use it in GitHub Desktop.
test conda solver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import subprocess\nimport wurlitzer", | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "subdir = \"win-64\"", | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "from wurlitzer import sys_pipes\n\ndef is_solvable(specs, subdir, output=False):\n cmd = \"conda create -n test-test-test --dry-run \"\n for spec in specs:\n cmd += \" '%s'\" % spec\n with sys_pipes():\n r = subprocess.run(\n \"CONDA_SUBDIR=%s %s\" % (subdir, cmd),\n shell=True,\n capture_output=True,\n )\n if output:\n return r.returncode == 0, r\n else:\n return r.returncode == 0", | |
"execution_count": 20, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%time\n# test it\nassert is_solvable([\"python=3.11\"], \"linux-64\")\nassert not is_solvable([\"python=3.12\"], \"linux-64\")", | |
"execution_count": 21, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "CPU times: user 170 ms, sys: 77.6 ms, total: 247 ms\nWall time: 34.7 s\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "specs = [\n \"pexpect\",\n \"m2-bash\",\n \"mock\",\n \"m2-base\",\n \"responses\",\n \"m2-filesystem\",\n \"setuptools>=31.0.1\",\n \"tqdm>=4\",\n \"requests>=2.20.1,<3\",\n \"conda-package-handling>=1.3.0\",\n \"python_abi=3.11=*_cp311\",\n \"pluggy>=1.0.0\",\n \"pyopenssl>=16.2.0\",\n \"ruamel.yaml>=0.11.14,<0.18\",\n \"python>=3.11,<3.12.0a0\",\n \"pycosat>=0.6.3\",\n \"toolz>=0.8.1\",\n \"menuinst>=1.4.11,<2\",\n]", | |
"execution_count": 22, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "iss, r = is_solvable(specs, \"win-64\", output=True)", | |
"execution_count": 24, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"scrolled": false | |
}, | |
"cell_type": "code", | |
"source": "print(r.stdout.decode(\"utf-8\"))", | |
"execution_count": 25, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "conda-forge/win-64 Using cache\nconda-forge/noarch Using cache\n\n***\n\nNOTE: You are using the EXPERIMENTAL libmamba solver integration.\n\nIf something is not working as expected, please:\n\n1. Go to https://github.com/conda/conda/issues/new/choose\n2. Choose the \"Libmamba Solver Feedback (Experimental Feature)\" option\n\nThank you for your help!\n\n***\n\nCollect all metadata (repodata.json): ...working... done\nSolving environment: ...working... done\n\n## Package Plan ##\n\n environment location: /Users/beckermr/mambaforge/envs/test-test-test\n\n added / updated specs:\n - conda-package-handling[version='>=1.3.0']\n - m2-base\n - m2-bash\n - m2-filesystem\n - menuinst[version='>=1.4.11,<2']\n - mock\n - pexpect\n - pluggy[version='>=1.0.0']\n - pycosat[version='>=0.6.3']\n - pyopenssl[version='>=16.2.0']\n - python[version='>=3.11,<3.12.0a0']\n - python_abi==3.11[build=*_cp311]\n - requests[version='>=2.20.1,<3']\n - responses\n - ruamel.yaml[version='>=0.11.14,<0.18']\n - setuptools[version='>=31.0.1']\n - toolz[version='>=0.8.1']\n - tqdm[version='>=4']\n\n\nThe following packages will be downloaded:\n\n package | build\n ---------------------------|-----------------\n brotlipy-0.7.0 |py311ha68e1ae_1005 335 KB conda-forge\n bzip2-1.0.8 | h8ffe710_4 149 KB conda-forge\n ca-certificates-2022.9.24 | h5b45459_0 189 KB conda-forge\n cffi-1.15.1 | py311h7d9ee11_2 288 KB conda-forge\n conda-package-handling-2.0.2| pyh38be061_0 247 KB conda-forge\n conda-package-streaming-0.7.0| pyhd8ed1ab_1 17 KB conda-forge\n cryptography-38.0.4 | py311h28e9c30_0 1.0 MB conda-forge\n libffi-3.4.2 | h8ffe710_5 41 KB conda-forge\n libsqlite-3.40.0 | hcfcfb64_0 654 KB conda-forge\n libzlib-1.2.13 | hcfcfb64_4 70 KB conda-forge\n m2-base-1.0.0 | 2 4 KB conda-forge\n m2-bash-4.3.042 | 5 3.5 MB conda-forge\n m2-bash-completion-2.3 | 2 186 KB conda-forge\n m2-catgets-1.1 | 3 28 KB conda-forge\n m2-coreutils-8.25 | 102 4.5 MB conda-forge\n m2-dash-0.5.8 | 2 96 KB conda-forge\n m2-file-5.25 | 2 803 KB conda-forge\n m2-filesystem-2016.04 | 4 27 KB conda-forge\n m2-findutils-4.6.0 | 2 610 KB conda-forge\n m2-gawk-4.1.3 | 2 1.4 MB conda-forge\n m2-gcc-libs-5.3.0 | 4 1021 KB conda-forge\n m2-gettext-0.19.7 | 4 2.0 MB conda-forge\n m2-gmp-6.1.0 | 3 409 KB conda-forge\n m2-grep-2.22 | 4 261 KB conda-forge\n m2-gzip-1.7 | 2 103 KB conda-forge\n m2-inetutils-1.9.2 | 2 311 KB conda-forge\n m2-info-6.0 | 2 239 KB conda-forge\n m2-less-481 | 2 107 KB conda-forge\n m2-libasprintf-0.19.7 | 4 7 KB conda-forge\n m2-libcatgets-1.1 | 3 8 KB conda-forge\n m2-libcrypt-1.3 | 2 8 KB conda-forge\n m2-libgettextpo-0.19.7 | 4 125 KB conda-forge\n m2-libiconv-1.14 | 3 718 KB conda-forge\n m2-libintl-0.19.7 | 4 23 KB conda-forge\n m2-liblzma-5.2.2 | 2 80 KB conda-forge\n m2-libpcre-8.38 | 2 99 KB conda-forge\n m2-libreadline-6.3.008 | 8 277 KB conda-forge\n m2-libutil-linux-2.26.2 | 2 225 KB conda-forge\n m2-libxml2-2.9.2 | 3 564 KB conda-forge\n m2-mintty-1!2.2.3 | 2 171 KB conda-forge\n m2-mpfr-3.1.4 | 2 255 KB conda-forge\n m2-msys2-launcher-git-0.3.28.860c495| 2 29 KB conda-forge\n m2-msys2-runtime-2.5.0.17080.65c939c| 3 3.0 MB conda-forge\n m2-ncurses-6.0.20160220 | 2 1.6 MB conda-forge\n m2-sed-4.2.2 | 3 887 KB conda-forge\n m2-tftp-hpa-5.2 | 2 23 KB conda-forge\n m2-time-1.7 | 2 19 KB conda-forge\n m2-ttyrec-1.0.8 | 2 15 KB conda-forge\n m2-tzcode-2015.e | 2 496 KB conda-forge\n m2-util-linux-2.26.2 | 2 1.7 MB conda-forge\n m2-which-2.21 | 3 23 KB conda-forge\n m2-zlib-1.2.8 | 4 52 KB conda-forge\n menuinst-1.4.19 | py311h1ea47a8_1 108 KB conda-forge\n mock-4.0.3 | pyhd8ed1ab_4 28 KB conda-forge\n msys2-conda-epoch-20160418 | 1 3 KB conda-forge\n openssl-3.0.7 | hcfcfb64_0 7.9 MB conda-forge\n pycosat-0.6.4 | py311ha68e1ae_1 103 KB conda-forge\n pysocks-1.7.1 | pyh0701188_6 19 KB conda-forge\n python-3.11.0 |hcf16a7b_0_cpython 18.9 MB conda-forge\n python_abi-3.11 | 3_cp311 6 KB conda-forge\n responses-0.21.0 | pyhd8ed1ab_0 41 KB conda-forge\n ruamel.yaml-0.17.21 | py311ha68e1ae_2 245 KB conda-forge\n ruamel.yaml.clib-0.2.7 | py311ha68e1ae_0 104 KB conda-forge\n tk-8.6.12 | h8ffe710_0 3.5 MB conda-forge\n tzdata-2022g | h191b570_0 106 KB conda-forge\n ucrt-10.0.22621.0 | h57928b3_0 1.2 MB conda-forge\n urllib3-1.26.13 | pyhd8ed1ab_0 108 KB conda-forge\n vc-14.3 | h3d8a991_9 14 KB conda-forge\n vs2015_runtime-14.32.31332 | h1d6e394_9 1.2 MB conda-forge\n win_inet_pton-1.1.0 | pyhd8ed1ab_6 8 KB conda-forge\n xz-5.2.6 | h8d14728_0 213 KB conda-forge\n zstandard-0.19.0 | py311he5d195f_1 299 KB conda-forge\n zstd-1.5.2 | h7755175_4 401 KB conda-forge\n ------------------------------------------------------------\n Total: 63.3 MB\n\nThe following NEW packages will be INSTALLED:\n\n brotlipy conda-forge/win-64::brotlipy-0.7.0-py311ha68e1ae_1005 None\n bzip2 conda-forge/win-64::bzip2-1.0.8-h8ffe710_4 None\n ca-certificates conda-forge/win-64::ca-certificates-2022.9.24-h5b45459_0 None\n certifi conda-forge/noarch::certifi-2022.9.24-pyhd8ed1ab_0 None\n cffi conda-forge/win-64::cffi-1.15.1-py311h7d9ee11_2 None\n charset-normalizer conda-forge/noarch::charset-normalizer-2.1.1-pyhd8ed1ab_0 None\n colorama conda-forge/noarch::colorama-0.4.6-pyhd8ed1ab_0 None\n conda-package-han~ conda-forge/noarch::conda-package-handling-2.0.2-pyh38be061_0 None\n conda-package-str~ conda-forge/noarch::conda-package-streaming-0.7.0-pyhd8ed1ab_1 None\n cryptography conda-forge/win-64::cryptography-38.0.4-py311h28e9c30_0 None\n idna conda-forge/noarch::idna-3.4-pyhd8ed1ab_0 None\n libffi conda-forge/win-64::libffi-3.4.2-h8ffe710_5 None\n libsqlite conda-forge/win-64::libsqlite-3.40.0-hcfcfb64_0 None\n libzlib conda-forge/win-64::libzlib-1.2.13-hcfcfb64_4 None\n m2-base conda-forge/win-64::m2-base-1.0.0-2 None\n m2-bash conda-forge/win-64::m2-bash-4.3.042-5 None\n m2-bash-completion conda-forge/win-64::m2-bash-completion-2.3-2 None\n m2-catgets conda-forge/win-64::m2-catgets-1.1-3 None\n m2-coreutils conda-forge/win-64::m2-coreutils-8.25-102 None\n m2-dash conda-forge/win-64::m2-dash-0.5.8-2 None\n m2-file conda-forge/win-64::m2-file-5.25-2 None\n m2-filesystem conda-forge/win-64::m2-filesystem-2016.04-4 None\n m2-findutils conda-forge/win-64::m2-findutils-4.6.0-2 None\n m2-gawk conda-forge/win-64::m2-gawk-4.1.3-2 None\n m2-gcc-libs conda-forge/win-64::m2-gcc-libs-5.3.0-4 None\n m2-gettext conda-forge/win-64::m2-gettext-0.19.7-4 None\n m2-gmp conda-forge/win-64::m2-gmp-6.1.0-3 None\n m2-grep conda-forge/win-64::m2-grep-2.22-4 None\n m2-gzip conda-forge/win-64::m2-gzip-1.7-2 None\n m2-inetutils conda-forge/win-64::m2-inetutils-1.9.2-2 None\n m2-info conda-forge/win-64::m2-info-6.0-2 None\n m2-less conda-forge/win-64::m2-less-481-2 None\n m2-libasprintf conda-forge/win-64::m2-libasprintf-0.19.7-4 None\n m2-libcatgets conda-forge/win-64::m2-libcatgets-1.1-3 None\n m2-libcrypt conda-forge/win-64::m2-libcrypt-1.3-2 None\n m2-libgettextpo conda-forge/win-64::m2-libgettextpo-0.19.7-4 None\n m2-libiconv conda-forge/win-64::m2-libiconv-1.14-3 None\n m2-libintl conda-forge/win-64::m2-libintl-0.19.7-4 None\n m2-liblzma conda-forge/win-64::m2-liblzma-5.2.2-2 None\n m2-libpcre conda-forge/win-64::m2-libpcre-8.38-2 None\n m2-libreadline conda-forge/win-64::m2-libreadline-6.3.008-8 None\n m2-libutil-linux conda-forge/win-64::m2-libutil-linux-2.26.2-2 None\n m2-libxml2 conda-forge/win-64::m2-libxml2-2.9.2-3 None\n m2-mintty conda-forge/win-64::m2-mintty-1!2.2.3-2 None\n m2-mpfr conda-forge/win-64::m2-mpfr-3.1.4-2 None\n m2-msys2-launcher~ conda-forge/win-64::m2-msys2-launcher-git-0.3.28.860c495-2 None\n m2-msys2-runtime conda-forge/win-64::m2-msys2-runtime-2.5.0.17080.65c939c-3 None\n m2-ncurses conda-forge/win-64::m2-ncurses-6.0.20160220-2 None\n m2-sed conda-forge/win-64::m2-sed-4.2.2-3 None\n m2-tftp-hpa conda-forge/win-64::m2-tftp-hpa-5.2-2 None\n m2-time conda-forge/win-64::m2-time-1.7-2 None\n m2-ttyrec conda-forge/win-64::m2-ttyrec-1.0.8-2 None\n m2-tzcode conda-forge/win-64::m2-tzcode-2015.e-2 None\n m2-util-linux conda-forge/win-64::m2-util-linux-2.26.2-2 None\n m2-which conda-forge/win-64::m2-which-2.21-3 None\n m2-zlib conda-forge/win-64::m2-zlib-1.2.8-4 None\n menuinst conda-forge/win-64::menuinst-1.4.19-py311h1ea47a8_1 None\n mock conda-forge/noarch::mock-4.0.3-pyhd8ed1ab_4 None\n msys2-conda-epoch conda-forge/win-64::msys2-conda-epoch-20160418-1 None\n openssl conda-forge/win-64::openssl-3.0.7-hcfcfb64_0 None\n pexpect conda-forge/noarch::pexpect-4.8.0-pyh1a96a4e_2 None\n pluggy conda-forge/noarch::pluggy-1.0.0-pyhd8ed1ab_5 None\n ptyprocess conda-forge/noarch::ptyprocess-0.7.0-pyhd3deb0d_0 None\n pycosat conda-forge/win-64::pycosat-0.6.4-py311ha68e1ae_1 None\n pycparser conda-forge/noarch::pycparser-2.21-pyhd8ed1ab_0 None\n pyopenssl conda-forge/noarch::pyopenssl-22.1.0-pyhd8ed1ab_0 None\n pysocks conda-forge/noarch::pysocks-1.7.1-pyh0701188_6 None\n python conda-forge/win-64::python-3.11.0-hcf16a7b_0_cpython None\n python_abi conda-forge/win-64::python_abi-3.11-3_cp311 None\n requests conda-forge/noarch::requests-2.28.1-pyhd8ed1ab_1 None\n responses conda-forge/noarch::responses-0.21.0-pyhd8ed1ab_0 None\n ruamel.yaml conda-forge/win-64::ruamel.yaml-0.17.21-py311ha68e1ae_2 None\n ruamel.yaml.clib conda-forge/win-64::ruamel.yaml.clib-0.2.7-py311ha68e1ae_0 None\n setuptools conda-forge/noarch::setuptools-65.5.1-pyhd8ed1ab_0 None\n six conda-forge/noarch::six-1.16.0-pyh6c4a22f_0 None\n tk conda-forge/win-64::tk-8.6.12-h8ffe710_0 None\n toolz conda-forge/noarch::toolz-0.12.0-pyhd8ed1ab_0 None\n tqdm conda-forge/noarch::tqdm-4.64.1-pyhd8ed1ab_0 None\n tzdata conda-forge/noarch::tzdata-2022g-h191b570_0 None\n ucrt conda-forge/win-64::ucrt-10.0.22621.0-h57928b3_0 None\n urllib3 conda-forge/noarch::urllib3-1.26.13-pyhd8ed1ab_0 None\n vc conda-forge/win-64::vc-14.3-h3d8a991_9 None\n vs2015_runtime conda-forge/win-64::vs2015_runtime-14.32.31332-h1d6e394_9 None\n win_inet_pton conda-forge/noarch::win_inet_pton-1.1.0-pyhd8ed1ab_6 None\n xz conda-forge/win-64::xz-5.2.6-h8d14728_0 None\n zstandard conda-forge/win-64::zstandard-0.19.0-py311he5d195f_1 None\n zstd conda-forge/win-64::zstd-1.5.2-h7755175_4 None\n\n\n\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# here is an example of how to debug\n\nspecs = [\n \"numpy\",\n \"python=3.11\",\n \"numba=0.70\",\n]\n\nfor i in range(len(specs)):\n _specs = [s for _i, s in enumerate(specs) if i != _i]\n print(\"removed %s and solvable=%s\" % (specs[i], is_solvable(_specs, \"linux-64\")))", | |
"execution_count": 28, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "removed numpy and solvable=False\nremoved python=3.11 and solvable=False\nremoved numba=0.70 and solvable=True\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "conda-root-py", | |
"display_name": "Python [conda env:root] *", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.10.6", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"gist": { | |
"id": "7f64f95343a8300aa2c46706975bd226", | |
"data": { | |
"description": "test conda solver", | |
"public": true | |
} | |
}, | |
"_draft": { | |
"nbviewer_url": "https://gist.github.com/7f64f95343a8300aa2c46706975bd226" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment