{ "info": { "author": "Padraic Shafer", "author_email": "pshafer@lbl.gov", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Build Tools" ], "description": "# pkgscript (version 0.4)\n\nPython module that allows a packaged module to run properly as a script. \n\nIt imports the enclosing package(s) into the script, allowing the script to \nimport other modules from the same package family (using explicit relative or \nabsolute import statements).\n\n**!!! \n`import_parent_packages()` must be called before any package-sibling imports \n!!!**\n\n\n## Examples:\n\n### Milo.mod_script.py\n```python\nimport pkgscript\n# Only call function if module is being run as a script\nif (__name__ == \"__main__\") and (__package__ is None):\n pkgscript.import_parent_packages(\"Milo\", globals())\nfrom Milo.version import __version__\nfrom .version import __version__ # same as previous line\n```\n### top_pkg.sub_pkg.sub_sub_pkg.mod_script.py\n```python\nimport pkgscript\n# Only call function if module is being run as a script\nif (__name__ == \"__main__\") and (__package__ is None):\n pkgscript.import_parent_packages(\n \"top_pkg.sub_pkg.sub_sub_pkg\", globals())\n# Import top_pkg.sub_pkg.other_module\nfrom top_pkg.sub_pkg import other_module\nfrom .. import other_module # same as previous line\nfrom ...sub_pkg import other_module # same as previous line\n```\n\n## Credits\n\nThis software is adapted from helpful code posted by @vaultah \n (https://gist.github.com/vaultah/d63cb4c86be2774377aa674b009f759a) \n in response to a question on Stack Overflow \n (https://stackoverflow.com/a/28154841/9639441)\n\n\n## License\n\nThis software is released under The MIT License (MIT).\n\n_Copyright (c) 2018, Padraic Shafer_\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/padraicshafer/pkgscript", "keywords": "package script import sibling relative absolute", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "PkgScript", "package_url": "https://pypi.org/project/PkgScript/", "platform": "", "project_url": "https://pypi.org/project/PkgScript/", "project_urls": { "Homepage": "https://bitbucket.org/padraicshafer/pkgscript" }, "release_url": "https://pypi.org/project/PkgScript/0.4.3/", "requires_dist": null, "requires_python": "", "summary": "Python module that allows a packaged module to run properly as a script", "version": "0.4.3" }, "last_serial": 3838110, "releases": { "0.2.5": [ { "comment_text": "", "digests": { "md5": "b9c80d4375158c71df2fbebd62f0ca03", "sha256": "152b16c5f0fc1455ee4f0387bed7df67ac3852353d910c9898feacc4e4aac535" }, "downloads": -1, "filename": "PkgScript-0.2.5.tar.gz", "has_sig": false, "md5_digest": "b9c80d4375158c71df2fbebd62f0ca03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21275, "upload_time": "2018-04-14T23:38:29", "url": "https://files.pythonhosted.org/packages/d7/f5/6c905c9359149fac52f88b8bf46ca1118ac6b031f8669f1e88afed06e5ea/PkgScript-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "b4e4cb5d1da69bf66e9b55e658f18edb", "sha256": "cba0b1115c32de3808357eef08cc21768f921ba574058a210746451a315ab322" }, "downloads": -1, "filename": "PkgScript-0.2.6.tar.gz", "has_sig": false, "md5_digest": "b4e4cb5d1da69bf66e9b55e658f18edb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21393, "upload_time": "2018-04-14T23:38:30", "url": "https://files.pythonhosted.org/packages/ab/30/d421a57aa271382599e86b934892ec871e126bc044ec692f9860a5d13a02/PkgScript-0.2.6.tar.gz" } ], "0.2.7": [ { "comment_text": "", "digests": { "md5": "ba3000f229acce34622f7dc8b9c55ca7", "sha256": "cf5f5d34c429fc29806eb178068062c26531dd45f264a70653c2d1224dfa9787" }, "downloads": -1, "filename": "PkgScript-0.2.7.1.tar.gz", "has_sig": false, "md5_digest": "ba3000f229acce34622f7dc8b9c55ca7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21415, "upload_time": "2018-04-15T22:03:09", "url": "https://files.pythonhosted.org/packages/d0/76/282d40094b29d763df78767671d21bea2f927b1f3f0398b287b7f2c74bb4/PkgScript-0.2.7.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "4ca087ccfa07f078f9f1b371d561ae52", "sha256": "edb5c2e7edc490d5014f00c6757435866b6a126f1f31ea4ea510fc2f0680ee8c" }, "downloads": -1, "filename": "PkgScript-0.3.0.tar.gz", "has_sig": false, "md5_digest": "4ca087ccfa07f078f9f1b371d561ae52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21460, "upload_time": "2018-04-21T00:02:37", "url": "https://files.pythonhosted.org/packages/f9/df/acae8126de41a26cc5db0773b998904a4fd9dacb38e161935d915c6d28ee/PkgScript-0.3.0.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "c9d569dcab07b1d174ecf69ff3fddeb0", "sha256": "6643c3d67bb677d16d44652b173d9c976fa5091f39fadf8a1a46fb440b45e5b2" }, "downloads": -1, "filename": "PkgScript-0.4.3.tar.gz", "has_sig": false, "md5_digest": "c9d569dcab07b1d174ecf69ff3fddeb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23511, "upload_time": "2018-05-06T05:22:49", "url": "https://files.pythonhosted.org/packages/5d/e1/3de1b950c53cdb7b5bbd9ce2f0b7a8474920d46671f5607c92680d13f8a2/PkgScript-0.4.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c9d569dcab07b1d174ecf69ff3fddeb0", "sha256": "6643c3d67bb677d16d44652b173d9c976fa5091f39fadf8a1a46fb440b45e5b2" }, "downloads": -1, "filename": "PkgScript-0.4.3.tar.gz", "has_sig": false, "md5_digest": "c9d569dcab07b1d174ecf69ff3fddeb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23511, "upload_time": "2018-05-06T05:22:49", "url": "https://files.pythonhosted.org/packages/5d/e1/3de1b950c53cdb7b5bbd9ce2f0b7a8474920d46671f5607c92680d13f8a2/PkgScript-0.4.3.tar.gz" } ] }