{ "info": { "author": "Felix Berkenkamp", "author_email": "fberkenkamp@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "autoexec\n========\n\nAutomatically turn python functions into executable scripts\n\nWhenever you have written some code and want to run it on a cluster, the first step is to turn it into an executable. This typically leads to a quick stop over at the docs for `argparse`, together with a lot of duplicated effort in reproducing the function signature. This can be error-prone and annoying, especially if one edits the function.\n\nThis script automates this process, using information about types provided either through function annotation, default values in keyword arguments, or type information in `numpydoc`-style docstrings. Like any shell script, this limits the functions to arguments that can be passed in the terminal, (str, int, float,...).\n\nExample\n-------\n\nLet's say you've written the following function in ``example.py``, which provides all kinds of different type information\n\n.. code:: python\n\n def add(a: int, b, c=5, d=7., e=None):\n \"\"\"Some cool addition.\n\n It's super complicated.\n You know, adding and stuff.\n\n Parameters\n ----------\n b : int\n This is the second complicated parameter\n super complicated\n e : int, optional\n \"\"\"\n if e is None:\n e = 0\n return a + b + c + d + e\n\nNow all you have to do to turn this into an executable is add the following code at the bottom\n\n.. code:: python\n\n if __name__ == '__main__':\n import autoexec\n res = autoexec.execute_function(add)\n print(res)\n\nand run ``chmod +x example.py``. Now if you run ``./example.py --help`` you get the following output\n\n.. code::\n\n \u276f\u276f\u276f ./example.py --help\n usage: example.py [-h] --a A --b B [--c C] [--d D] [--e E]\n\n Some cool addition.\n\n It's super complicated.\n You know, adding and stuff.\n\n optional arguments:\n -h, --help show this help message and exit\n --a A int\n --b B This is the second complicated parameter\n super complicated\n --c C int, default: 5\n --d D float, default: 7.0\n --e E int, default: None\n\nAnd you're ready to call the script from the command line\n\n.. code::\n\n \u276f\u276f\u276f ./example.py --a 1 --b 2 --c 3\n 13.0\n\nThere is type-checking by argparse\n\n.. code::\n\n \u276f\u276f\u276f ./example.py --a 1 --b stringy\n usage: example.py [-h] --a A --b B [--c C] [--d D] [--e E]\n example.py: error: argument --b: invalid int value: 'stringy'\n\nand it complains about missing arguments\n\n.. code::\n\n \u276f\u276f\u276f ./example.py --a 1\n usage: example.py [-h] --a A --b B [--c C] [--d D] [--e E]\n example.py: error: the following arguments are required: --b\n\nThere is also support for multiple functions via ``autoexec.execute_functions``.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/befelix/autoexec", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "autoexec", "package_url": "https://pypi.org/project/autoexec/", "platform": "", "project_url": "https://pypi.org/project/autoexec/", "project_urls": { "Homepage": "https://github.com/befelix/autoexec" }, "release_url": "https://pypi.org/project/autoexec/0.1.1/", "requires_dist": [ "numpydoc" ], "requires_python": "", "summary": "Automatically turn functions into executables.", "version": "0.1.1" }, "last_serial": 3797771, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "5883798455ba4bf029e96b0dbf0e5827", "sha256": "b927a073bd639a38caf7c128a7a6c08675eb10c94a099c9fa131d74f5db4a45a" }, "downloads": -1, "filename": "autoexec-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5883798455ba4bf029e96b0dbf0e5827", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6531, "upload_time": "2018-04-23T09:36:00", "url": "https://files.pythonhosted.org/packages/d6/54/5cb39e0f6a96c43ef1497e7d3f80e4ee3e800b5986472b3e6d9024bea08a/autoexec-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eeaffa4630628ce204bdad9775fbb283", "sha256": "3dee1722d8fafad4e8adbe3290316aff9848e9838c91c73e30040e06cb9fe75a" }, "downloads": -1, "filename": "autoexec-0.1.1.tar.gz", "has_sig": false, "md5_digest": "eeaffa4630628ce204bdad9775fbb283", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4457, "upload_time": "2018-04-23T09:36:01", "url": "https://files.pythonhosted.org/packages/2c/0c/4d0113bc56f7c887ae6a7ab174228f876782b63cb513c5491927eadc8429/autoexec-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5883798455ba4bf029e96b0dbf0e5827", "sha256": "b927a073bd639a38caf7c128a7a6c08675eb10c94a099c9fa131d74f5db4a45a" }, "downloads": -1, "filename": "autoexec-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5883798455ba4bf029e96b0dbf0e5827", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6531, "upload_time": "2018-04-23T09:36:00", "url": "https://files.pythonhosted.org/packages/d6/54/5cb39e0f6a96c43ef1497e7d3f80e4ee3e800b5986472b3e6d9024bea08a/autoexec-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eeaffa4630628ce204bdad9775fbb283", "sha256": "3dee1722d8fafad4e8adbe3290316aff9848e9838c91c73e30040e06cb9fe75a" }, "downloads": -1, "filename": "autoexec-0.1.1.tar.gz", "has_sig": false, "md5_digest": "eeaffa4630628ce204bdad9775fbb283", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4457, "upload_time": "2018-04-23T09:36:01", "url": "https://files.pythonhosted.org/packages/2c/0c/4d0113bc56f7c887ae6a7ab174228f876782b63cb513c5491927eadc8429/autoexec-0.1.1.tar.gz" } ] }