{ "info": { "author": "cgat-developers", "author_email": "sebastian.luna.valero@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Purpose\n\nThe goal of `conda_deps` is to generate a [conda environment file](https://bit.ly/2THhLnA) as a result of\nthe dependencies found in a repository. At the moment, it only translates Python and R dependencies\nbut it would be great to have it working for other programming languages as well.\n\n`conda_deps` translates import statements in Python source code like:\n\n import numpy\n import scipy\n\ninto an environment file:\n\n name: testenv\n \n channels:\n - conda-forge\n - bioconda\n - defaults\n\n dependencies:\n - python\n - numpy\n - scipy\n\nFor R it translates library imports like:\n\n library(reshape2)\n library(ggplot2)\n\ninto:\n\n name: testenv\n \n channels:\n - conda-forge\n - bioconda\n - defaults\n\n dependencies:\n - r-base\n - r-reshape2 \n - r-ggplot2\n\n## Warning\n\nPlease note that `conda_deps` does not check dependencies in a clever way. For example, if your code imports `scipy` and `numpy`, the script will generate an environment with both listed even though `numpy` **is** a dependency of `scipy` and only the latter would be required. So the expected output of `conda_deps` is a direct translation of the dependencies found in your code.\n\n# Installation\n\n`conda_deps` only works in **Python 3** and will only scan properly **Python 3** source code.\nThere should be no restriction in the case of R.\n\n`conda_deps` has been uploaded to `conda-forge` so you can install it with:\n\n # if you don't have conda available:\n curl -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh\n bash Miniconda3-latest-Linux-x86_64.sh -b -p conda-install\n source conda-install/etc/profile.d/conda.sh \n conda update --all --yes\n \n # once conda is available:\n conda create --name conda_deps --channel conda-forge conda_deps\n conda activate conda_deps\n conda_deps --help\n\n# Usage\n\nThis is how you scan a single Python or R file:\n\n conda_deps \n \nThe script can also scan folders:\n\n conda_deps \n \nIn case you want to exclude one or more subfolders, use the `--exclude-folder` option one or more times:\n\n conda_deps --exclude-folder \n\nYou may also want to scan additonal files of folders:\n\n conda_deps --include-files my-script.py --include-files \n \n# How it works\n\n## Python source code\n \nThe script uses [Python's Abstract Syntax Trees](https://docs.python.org/3/library/ast.html#module-ast)\nto parse files ending in `.py`. It looks for `import ` statements, and discards the modules belonging to the\nPython Standard Library (e.g. `import os`). It assumes that `` has a corresponding conda package\nwith the same name (e.g. `import numpy` corresponds to `conda install numpy`). However, that is not\nalways the case and you can provide a proper translation between the module name and its corresponding\nconda package (e.g. `import yaml` will require `conda install pyyaml`) via the \n[python_deps.json](https://github.com/cgat-developers/conda-deps/blob/master/conda_deps/python_deps.json) file, which\nwill be loaded into a dictionary at the beginning of the script. It looks like this:\n\n {\n \"Bio\":\"biopython\",\n \"Cython\":\"cython\",\n \"bs4\":\"beautifulsoup4\",\n \"bx\":\"bx-python\",\n \"lzo\":\"python-lzo\",\n \"pyBigWig\":\"pybigwig\",\n \"sklearn\":\"scikit-learn\",\n \"web\":\"web.py\",\n \"weblogolib\":\"python-weblogo\",\n \"yaml\":\"pyyaml\"\n } \n\nThe dictionary key is the name in `import ` and the value is the name of the conda package. \n\nThe **python_deps.json** file is meant to be useful for generic use. However, it is possible to include\nadditional json files specific to your project:\n\n conda_deps --include-py-json my_project.json \n\nThe translations in **my_project.json** will take priority over those in **python_deps.json**.\n\nIf you find that there are missing translations in the general purpose **python_deps.json** file, please\nfeel free to open a pull request to add more.\n\n## R source code\n\nIn the case of R files, it uses `grep` to look for `library(name)` regular expressions in files ending in `.R`.\nThe same way we use a `json` file to detail translations for Python, \nwe use the [r_deps.json](https://github.com/cgat-developers/conda-deps/blob/master/conda_deps/r_deps.json)\nfile which will be loaded into a dictionary at the beginning of the script. Here is how it looks like:\n\n {\n \"dplyr\":\"r-dplyr\",\n \"edgeR\":\"bioconductor-edger\",\n \"flashClust\":\"r-flashclust\",\n \"gcrma\":\"bioconductor-gcrma\",\n \"ggplot2\":\"r-ggplot2\",\n \"gplots\":\"r-gplots\",\n \"gridExtra\":\"r-gridextra\",\n \"grid\":\"r-gridbase\",\n \"gtools\":\"r-gtools\",\n \"hpar\":\"bioconductor-hpar\",\n \"knitr\":\"r-knitr\",\n \"limma\":\"bioconductor-limma\",\n \"maSigPro\":\"bioconductor-masigpro\",\n }\n\nIn this case the dictionary key is the name in `library(name)` and the value is the name of the conda package.\n\nIf you are missing a translation in **r_deps.json** you can either open a pull request to add it or include it\nin your own json file:\n\n conda_deps --include-r-json my_project.json \n \nPlease note that the translations in **my_project.json** will take priority over those in **r_deps.json**.\n\n## Warning\n\nAn important point to bear in mind is that the translations for both Python and R are not comprehensive and are mainly based in the dependencies used in the past. It will be a matter of time to keep adding new dependencies to the json files in charge of the translation. This implies that the environment file produced as output may not be valid straight away and conda will complain about that when creating the environment (i.e. error message: **PackagesNotFoundError**).\n\n# Related tools\n\n* [snakefood](http://furius.ca/snakefood/): a more comprehensive tool but it works only with Python 2.\n* [pipreqs](https://github.com/bndr/pipreqs): does a similar job but for **requirements.txt** files and pip.\n\n# References\n\n* https://docs.python.org/3/library/ast.html#module-ast\n* http://bit.ly/2rDf5xu\n* http://bit.ly/2r0Uv9t\n* https://github.com/titusjan/astviewer\n\n# Changelog\n\n* v0.0.9:\n - Scan **.Rmd** and **.ipynb** files as well, therefore the script now depends on **nbconvert**\n - Able to scan Python imports with multiple modules (e.g. `import numpy, matplotlib`)\n - Add new R dependencies to the json dictionary\n - Scan `rmagic` and `cythonmagic` in **.ipynb** files ([#1](https://github.com/cgat-developers/conda-deps/issues/1))\n* v0.0.8:\n - [Add new R dependencies](https://github.com/cgat-developers/conda-deps/pull/6)\n* v0.0.7:\n - Improve the test to check whether a module belongs to the Python Standard Library\n - Add new R dependencies to the json dictionary\n* v0.0.6:\n - Add sanity check for dependency translation\n - [Improve regex to translate Bioconductor dependencies](https://github.com/cgat-developers/conda-deps/pull/3)\n* v0.0.5:\n - Add **r_deps.json** to manifest file\n - Rename option **--include-py-files** to **--include-files**\n* v0.0.4: \n - Add translation of R dependencies\n - Not uploaded to conda-forge due to missing **r_deps.json** in the manifest file\n* v0.0.3: minor bugfixes.\n* v0.0.2: first working version uploaded to conda-forge.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cgat-developers/conda-deps", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "conda-deps", "package_url": "https://pypi.org/project/conda-deps/", "platform": "", "project_url": "https://pypi.org/project/conda-deps/", "project_urls": { "Homepage": "https://github.com/cgat-developers/conda-deps" }, "release_url": "https://pypi.org/project/conda-deps/0.0.9/", "requires_dist": null, "requires_python": "", "summary": "Generate conda environment files from Python source code", "version": "0.0.9" }, "last_serial": 5519403, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "865d78192f6c1537e5416438baa3d3e0", "sha256": "370bd2cfd40b14957cbdab52658329b8e5658cca150b713954087376b7dec689" }, "downloads": -1, "filename": "conda_deps-0.0.1-py3.7.egg", "has_sig": false, "md5_digest": "865d78192f6c1537e5416438baa3d3e0", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 11054, "upload_time": "2019-03-19T17:41:12", "url": "https://files.pythonhosted.org/packages/0f/48/bceaf9de0cd2ffb87ce8f66907e014305014d8b0c2a79e0f88c71241f7b7/conda_deps-0.0.1-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "7bde90c9436a5825c8aa7b849290f1c8", "sha256": "94d73b5a0cc5e30f60f4d8447bc53a557b91beda2f362479856d955893258e92" }, "downloads": -1, "filename": "conda_deps-0.0.1.tar.gz", "has_sig": false, "md5_digest": "7bde90c9436a5825c8aa7b849290f1c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6730, "upload_time": "2019-03-19T17:41:14", "url": "https://files.pythonhosted.org/packages/54/36/33d9e8de51fb096518c196f343e97a6525f8fa3170efe5f1822994b2dfdb/conda_deps-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "c56f2b5bf424b8ca9fda3ef442978640", "sha256": "4ee16fd4a54a6508265fcbc9e3048c0154319efdd2293f6fa7710cb7ee4a4035" }, "downloads": -1, "filename": "conda_deps-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c56f2b5bf424b8ca9fda3ef442978640", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6769, "upload_time": "2019-03-19T17:49:18", "url": "https://files.pythonhosted.org/packages/95/45/12243d14dbd0232ef8d158b8ae5c919be460c5d8d9caf66ef319b7c21a87/conda_deps-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "014dcbf29932da54d2b75896930341e4", "sha256": "761d4b0f0aa18e3d3edf634c0d4026784f49445a14f7bcc1bb02d1fbbd755f17" }, "downloads": -1, "filename": "conda_deps-0.0.3.tar.gz", "has_sig": false, "md5_digest": "014dcbf29932da54d2b75896930341e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6875, "upload_time": "2019-04-01T16:09:43", "url": "https://files.pythonhosted.org/packages/31/92/dcef2bf29de388aef5c1ef98cb24ae9afd9b903280526a6e7ffc7d82d997/conda_deps-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "54658d0ee4abfed33e101d1fd2455c38", "sha256": "4bd9a31750620d8507d6602d9240ba65180c76baae7920269b3c493974654ef4" }, "downloads": -1, "filename": "conda_deps-0.0.4.tar.gz", "has_sig": false, "md5_digest": "54658d0ee4abfed33e101d1fd2455c38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7832, "upload_time": "2019-04-16T17:52:09", "url": "https://files.pythonhosted.org/packages/df/16/21284673cc8f85902fab9640ae92894687b856c2e14bcaa1d254adbf7170/conda_deps-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "cc7230de2a60faf910e35253c93cbb2a", "sha256": "b33406a63c505238bc693c804bdf4de463570171edc1c3a4eeff80736af726cc" }, "downloads": -1, "filename": "conda_deps-0.0.5.tar.gz", "has_sig": false, "md5_digest": "cc7230de2a60faf910e35253c93cbb2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9154, "upload_time": "2019-04-17T17:09:33", "url": "https://files.pythonhosted.org/packages/cb/ec/82c6e1f0a634eec863b566efacc0ea976255bc55edae3794063606e49076/conda_deps-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "072d450c41caf49174916a0b8bd404d7", "sha256": "d68bd50a918bc94707340ebfc18e97d801052e56481ae370eb1206817347ecb7" }, "downloads": -1, "filename": "conda_deps-0.0.6.tar.gz", "has_sig": false, "md5_digest": "072d450c41caf49174916a0b8bd404d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9612, "upload_time": "2019-04-24T18:36:01", "url": "https://files.pythonhosted.org/packages/5c/07/c7141a5bb6b4ef240be3a72d99470e8ebd545052602388f1735522b756ea/conda_deps-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "3349907dd7fd4c3ffc7f3b565c0c4d1c", "sha256": "0c6031790a7ec7f59b48ba51d05b1cd046194193699627e8e5dfc5cdc7e9b30e" }, "downloads": -1, "filename": "conda_deps-0.0.7.tar.gz", "has_sig": false, "md5_digest": "3349907dd7fd4c3ffc7f3b565c0c4d1c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9738, "upload_time": "2019-04-30T18:09:24", "url": "https://files.pythonhosted.org/packages/09/c9/555af70172f91e3bca7abc2cdaa43d2a941498e6ccc8a6bb4451fc1f82ca/conda_deps-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "6df00e7fa210a4f5b91b4f95536d190a", "sha256": "577e733342ea518218fa2e77ba21d2d8ca1f599ab88eae1abe6f79b92d700773" }, "downloads": -1, "filename": "conda_deps-0.0.8.tar.gz", "has_sig": false, "md5_digest": "6df00e7fa210a4f5b91b4f95536d190a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9862, "upload_time": "2019-05-16T18:13:45", "url": "https://files.pythonhosted.org/packages/7f/c3/a9f662d4fb6f06629f8c2251706b4f93ea457b16e788ca192e49c179d2e8/conda_deps-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "31a4926c9bd62cbcb3b305dc97875a9f", "sha256": "d12567fe9719befaa571c6167fff043338552399c5076910e5022e12bfd02c53" }, "downloads": -1, "filename": "conda_deps-0.0.9.tar.gz", "has_sig": false, "md5_digest": "31a4926c9bd62cbcb3b305dc97875a9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12608, "upload_time": "2019-07-11T18:06:40", "url": "https://files.pythonhosted.org/packages/21/65/9f474da081023749a4d906000069cb280ced32dec8d6d43791818d06b7cb/conda_deps-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "31a4926c9bd62cbcb3b305dc97875a9f", "sha256": "d12567fe9719befaa571c6167fff043338552399c5076910e5022e12bfd02c53" }, "downloads": -1, "filename": "conda_deps-0.0.9.tar.gz", "has_sig": false, "md5_digest": "31a4926c9bd62cbcb3b305dc97875a9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12608, "upload_time": "2019-07-11T18:06:40", "url": "https://files.pythonhosted.org/packages/21/65/9f474da081023749a4d906000069cb280ced32dec8d6d43791818d06b7cb/conda_deps-0.0.9.tar.gz" } ] }