{ "info": { "author": "Matt Shannon", "author_email": "matt.shannon@cantab.net", "bugtrack_url": null, "classifiers": [], "description": "codedep\n=======\n\nThis package provides a simple, semi-automated way to do code-level dependency\ntracking for python projects.\n\nProblem\n-------\n\nThe central idea is to be able to compute, for a given function or class, a\nhash of all the python source code that the function or class depends on.\nA given function or class is considered to depend on its immediate source code\ndefinition, on the source code defining functions or classes referred to in its\nimmediate definition, and so on.\nFor example if a class ``Foo`` uses a function ``bar`` in one of its methods,\nthen the hash value for ``Foo`` is based on the source code defining both\n``Foo`` and ``bar``.\n\nThe ability to compute such a hash value allows automated tracking of when the\nbehaviour of a given function or class changes (or rather, might have changed).\nFor example the author's original use case was for distributing jobs on a\ncompute grid, where it was useful to be able to determine automatically when\na job needed to be re-run because of changes to the source code.\n\nApproach used by codedep\n------------------------\n\nComputing such a hash value is presumably very difficult to do in a fully\nautomated way, partly because of the dynamic nature of python.\nThe approach taken in this package is to require an explicit annotation for\neach function ``fn`` (or class) giving the list of functions or classes that\nare referred to in the definition of ``fn``.\nFor example if a class ``Foo`` uses functions ``bar`` and ``baz`` in its\nmethods, then ``Foo`` could be decorated with ``@codeDeps(bar, baz)``.\nEverything else required to compute the hash value is looked-up automatically\nusing existing tools such as the inspect module.\nTo help with the burden of maintaining the ``@codeDeps`` lists, an automated\ntool is provided which suggests dependencies which may have been forgotten or\nmay have been added unnecessarily.\nThis semi-automated approach has the advantage that it can cope with the common\ncases easily while allowing the user control when they know better than the\ntool.\n\nThere are a few limitations on what the scheme used here can do:\n\n- It only allows dependencies to be specified and hash values to be computed\n for top-level functions and classes, not nested ones.\n- Behind the scenes the decorators add special values to the dictionary of the\n thing being decorated, so the thing being decorated has to have such a\n dictionary.\n This is the case for standard functions and classes.\n- Global (module-level) variables cannot be declared as dependencies since\n it is not possible to find their source code definitions using inspect.\n For safety it is therefore recommended to have no global variables (other\n than function and class definitions) when using this package.\n\nThe scheme used here has the advantage of being relatively simple.\nThe entire code to do the decoration and compute hashes is around 200 lines.\nIt is hoped that this simplicity will allow reasoning about how the scheme will\noperate in any tricky edge cases.\n\nInstallation\n------------\n\nFor most purposes the simplest way to install codedep is to use pip::\n\n sudo pip install codedep\n\nThis installs the latest released version of\n`codedep on PyPI `_.\nAlternatively you can download codedep from PyPI and install it using::\n\n sudo python setup.py install\n\nThe latest development version of codedep is available from a github repository\n(see below).\n\nUsage\n-----\n\nA sample python project is provided in the ``example`` directory.\nThe file ``example/foo.py`` defines some functions and classes.\nThe script ``example/print_hash.py`` prints some of the computed hashes for the\nfunctions and classes, together with some values computed by the functions and\nclasses.\n\nTyping::\n\n python -m example.print_hash\n\nshould give the output::\n\n hash of baz = 1a0ebbff92a8a8691c17a460b8eeb4cb38399c60\n hash of Foo = 96a9e852464e99d68d2769655a8113de33ee0721\n value1 = 6\n value2 = 0\n\nIf you now change the definition of ``qux`` in ``example/foo.py`` to multiply\nby 3 instead of 2, then the above command will output::\n\n hash of baz = 0c955f9963b6acb422501d5ee64e6bdedc5c204b\n hash of Foo = 572f8685fde1670fa720df6ebbf89a6cc8dd1e4c\n value1 = 9\n value2 = 0\n\nSuitable ``@codeDeps`` decorator lines can be suggested using an automated\ntool.\nRunning::\n\n bin/codedep_check example/foo.py\n\nor, if codedep has been installed, running::\n\n codedep_check example/foo.py\n\nshould print ``(no change)`` as one of its lines of output.\nIf you now change the definition of ``baz`` in ``example/foo.py`` to\n``return qux(bar(x) - 2)`` and re-run the automated tool then you should be\ntaken to a vimdiff of the original and suggested files.\nThe tool picks up the fact that ``baz`` now depends on ``bar``.\n\nNote that ``bin/codedep_check`` is a wrapper around\n``codedep/check_deps.py``.\nThe wrapper makes certain assumptions about the structure of the project\n(see ``bin/codedep_check`` for details).\nIn complicated cases it is intended that this wrapper be copied and customized\nto a version suitable for the specific project.\n\nLicense\n-------\n\nPlease see the file ``License`` for details of the license and warranty for\ncodedep.\n\nSource\n------\n\nThe source code is hosted in the\n`codedep github repository `_.\nTo obtain the latest source code using git::\n\n git clone git://github.com/MattShannon/codedep.git\n\nDevelopment is in fact done using `darcs `_, with the darcs\nrepository converted to a git repository using\n`darcs-to-git `_.\n\nBugs\n----\n\nPlease use the\n`issue tracker `_ to submit bug\nreports.\n\nContact\n-------\n\nThe author of codedep is `Matt Shannon `_.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/MattShannon/codedep", "keywords": null, "license": "3-clause BSD (see License file)", "maintainer": null, "maintainer_email": null, "name": "codedep", "package_url": "https://pypi.org/project/codedep/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/codedep/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/MattShannon/codedep" }, "release_url": "https://pypi.org/project/codedep/0.3/", "requires_dist": null, "requires_python": null, "summary": "Semi-automated code-level dependency tracking for python.", "version": "0.3" }, "last_serial": 818621, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "afad6cffc59e2c8913ae8f827f02fba1", "sha256": "54f1b5a602146bd70572444261d98cd93cd9ee1c04bdb6f17ce1afe9f58eba89" }, "downloads": -1, "filename": "codedep-0.2.tar.gz", "has_sig": false, "md5_digest": "afad6cffc59e2c8913ae8f827f02fba1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11351, "upload_time": "2013-07-18T00:46:15", "url": "https://files.pythonhosted.org/packages/b9/59/8c6dfa58e3221599bd310cbb47ff2c9d09c869790f3f30ef22c0ee1ca2cf/codedep-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "46c4b5b5622399ebfcacf2209fc085a7", "sha256": "e3d6b9ad3050c36da32b440a9cbfcb1bb48501ad096d55dff80c73e7c31e6edd" }, "downloads": -1, "filename": "codedep-0.3.tar.gz", "has_sig": false, "md5_digest": "46c4b5b5622399ebfcacf2209fc085a7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11623, "upload_time": "2013-07-18T22:29:02", "url": "https://files.pythonhosted.org/packages/60/0d/987d12e8e6966fd13b419e4b367d92e877dc66611c13400c61b9bdf7ceba/codedep-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "46c4b5b5622399ebfcacf2209fc085a7", "sha256": "e3d6b9ad3050c36da32b440a9cbfcb1bb48501ad096d55dff80c73e7c31e6edd" }, "downloads": -1, "filename": "codedep-0.3.tar.gz", "has_sig": false, "md5_digest": "46c4b5b5622399ebfcacf2209fc085a7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11623, "upload_time": "2013-07-18T22:29:02", "url": "https://files.pythonhosted.org/packages/60/0d/987d12e8e6966fd13b419e4b367d92e877dc66611c13400c61b9bdf7ceba/codedep-0.3.tar.gz" } ] }