{ "info": { "author": "Laurent Franceschetti", "author_email": "developer@settlenext.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries" ], "description": "Package: Repackage\n==================\n\nLaurent Franceschetti March/June 2013 - 2018 MIT License.\n\n\n\n\n\n- [Purpose](#purpose)\n- [Install](#install)\n- [The problem](#the-problem)\n- [The solution](#the-solution)\n- [Usage](#usage)\n- [Importing a module using the system PATH](#importing-a-module-using-the-system-path)\n- [Limitations](#limitations)\n\n\n\nPurpose\n-------\n\nThis module allows any Python program to call a non-registered package\nin a reliable way. With this module, you may call \"non-official\"\nrepositories, including with relative paths.\n\n> **CAUTION:** *This form is an alternative to system of relative paths\nfor python imports ([PEP\n328]()). It allows additional flexibility, at the cost of breaking some\nassumptions.*\n\nInstall\n-------\n\nIf you are using pip: :\n\n pip install repackage\n\nOtherwise, download the package and type:\n\n```bash\npython setup.py install\n```\n\nThe problem\n-----------\n\nIn Python, registered packages are called by name in import\ninstructions, and lower directories may be treated for all purposes as\npackages.\n\nTwo practical problems arise: a) How to easily call unregistered\npackages which have been dumped in an adjacent directory? b) How to\neasily move python files into a sub-directory without messing up the\nimport statements?\n\nThere are complicated issues with relative imports (see PEP366). The\nbasic idea here is to add the source directory of the package to the lib\npath (thanks to a call to sys.path.append).\n\nBut the probem, is how to programmatically find the source directory,\nfrom a relative path?\n\nTwo often advocated methods to determine the path are: a. from current\ndirectory or b. from \\_\\_FILE\\_\\_ .\n\nBoth those methods have a flaw:\n- The first does not take into account the file where the import is\n made, hence will fail if the project is using more than one\n directory.\n- The second does not allow to delegate those operations to a module\n that would handle those issues (as \\_\\_FILE\\_\\_ is going to point\n now to point to the module and not the caller).\n\nThe solution\n------------\n\nThis package uses a simple strategy that is likely to work in a good\nrange of cases: it inspects the stack to determine which file is the\ncaller and works out the relative path from there. The only delicate\npart consisted in working out how many steps down the stack this is, but\nthe answer should be invariant and can be computed both by reasoning and\nby trial and error (in this case: 3).\n\nUsage\n-----\n\nSituation 1) Moving the files into a lower directory. From the module\nyou want to make the call, just use the following statement before the\nimports: :\n\n import repackage\n repackage.up()\n\nIt should work without changing the imports that were previously\npointing to the upper directory.\n\nIf it's two directories up, write: :\n\n\n repackage.up(2)\n\nSituation 2) Calling a non-registered directory somewhere else (absolute\nor relative path): :\n\n\n repackage.add(\"../../otherdir\")\n\nClearly, repackage.up() would be equivalent to repackage.add(\"..\") . I\nprefer the first because it is more terse and syntactically more robust.\n\nImporting a module using the system PATH\n--------------------------\nIn some cases, it is convenient to install a Python app as a\ncommand in the PATH, usually with a symlink\n(e.g. `foo` => `/my/path/foo.py`).\nThis allows us to execute it, regardless of\nwhere it is installed.\n\nThe idea behind Python packages is more or less the same.\n\n> But what if\nthe module is **not** part of a package? Wouldn't it be intuitive\nto exploit the PATH of the OS to import it?\n\n**This is possible.** Supposing `foo`is in the path, as a symlink to\n`my/path/foo.py`, then you can write:\n\n```Python\nrepackage.add_path(\"foo\")\nimport foo\n```\n\nRepackage will follow the symlinks all the way to the destination\nand add the proper directory to your libpath. Needless to see, it\nwould work also if there is no symlink (note that in this case,\nthe file in your path might be called 'foo.py')\n\nLimitations\n-----------\n\nIf at some points in the execution, you attempt to add several times the\nsame directory to the lib path, this should remain without effect (this\nis a feature of sys.path.append).\n\nThis module has worked reliably for a while, so it is a beta version.\nThe method seems robust so far, but not all ins and outs have been\nexplored. One precaution might be to ensure that the repackaging always\npoints to the same source directory of a package (not to subdirectories\nof the same package), so as to avoid possible ambiguities in the lib\npath. (If this really turned out to be a problem, this could be checked\non the fly and a warning issued?).\n\nIf you find bugs, or even find this approach useless, essentially flawed\nor against the Zen of Python, I will be glad to hear about it.\nSimilarly, if you liked it or have ideas on how to improve it, let me\nknow.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.settlenext.com", "keywords": "package relative path module import library", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "repackage", "package_url": "https://pypi.org/project/repackage/", "platform": "", "project_url": "https://pypi.org/project/repackage/", "project_urls": { "Homepage": "https://www.settlenext.com" }, "release_url": "https://pypi.org/project/repackage/0.7.3/", "requires_dist": null, "requires_python": "", "summary": "Repackaging, call a non-registered package in any directory (with relative call). Used either by modules moved into to a subdirectory or to prepare the import of a non-registered package (in any relative path).", "version": "0.7.3" }, "last_serial": 4155756, "releases": { "0.2": [], "0.2a": [ { "comment_text": "", "digests": { "md5": "8cb06a1d0e2f5c31dfd960616456b9c9", "sha256": "5e385342914842254c66c5f289e989d87262fa3855fa291167d0cac3c917b86f" }, "downloads": -1, "filename": "repackage-0.2a.tar.gz", "has_sig": false, "md5_digest": "8cb06a1d0e2f5c31dfd960616456b9c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3989, "upload_time": "2014-03-04T12:39:16", "url": "https://files.pythonhosted.org/packages/2c/5a/c8cf695185ece674099c9dd278dcb8163f37eb14278886def4cb9a95cb8d/repackage-0.2a.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "20004511717c01190346781333f4601d", "sha256": "8d42106acce51b2928b21cfee1de7bb7bad473520380cba31603a2924c6127d5" }, "downloads": -1, "filename": "repackage-0.3.tar.gz", "has_sig": false, "md5_digest": "20004511717c01190346781333f4601d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3673, "upload_time": "2014-06-10T11:08:56", "url": "https://files.pythonhosted.org/packages/96/29/229677d57150ee05e017f1f6bdf76188e51130a5079bae15f2a6917e3efd/repackage-0.3.tar.gz" } ], "0.3a": [ { "comment_text": "", "digests": { "md5": "f115f974dc30386fc622924800890354", "sha256": "99faf6e834571f58cf0faa9b77cfa9e0fef5117d3082a46f56de4ea8c022e430" }, "downloads": -1, "filename": "repackage-0.3a.tar.gz", "has_sig": false, "md5_digest": "f115f974dc30386fc622924800890354", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3675, "upload_time": "2014-06-10T11:21:02", "url": "https://files.pythonhosted.org/packages/8b/2e/ec54fb184ec2d957b4280f6eccee2612385df7e4175b8f12d91d12ca05e7/repackage-0.3a.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "7944f2a10d7c26328992f970404c726f", "sha256": "22d382905346919abc599aa0a90d46c4bffa76e11791f962216639a1e9260c2d" }, "downloads": -1, "filename": "repackage-0.5.tar.gz", "has_sig": false, "md5_digest": "7944f2a10d7c26328992f970404c726f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3889, "upload_time": "2017-05-03T14:46:14", "url": "https://files.pythonhosted.org/packages/0a/8f/38bf5663a46f9ef16f5c8468cf20f8a198e306677484df7c902f979c6363/repackage-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "ac063be94ce5ab4c092e8a14da19884e", "sha256": "0d03d330c2af370a9bb0ad251c8cf8cff126a244c7f7d3d4b31e1bd46ac79b54" }, "downloads": -1, "filename": "repackage-0.6.tar.gz", "has_sig": false, "md5_digest": "ac063be94ce5ab4c092e8a14da19884e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4003, "upload_time": "2017-12-09T10:46:03", "url": "https://files.pythonhosted.org/packages/53/b7/c147c02155f61cd6d716c962e1bf758d12d12076a9e121c10116063fe29e/repackage-0.6.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "142b7170aa840ffebe843e4848f4204a", "sha256": "f4074428272feda03c0d47ebb612619cc30c742007712528701f332c0a4b4f02" }, "downloads": -1, "filename": "repackage-0.7.1.tar.gz", "has_sig": false, "md5_digest": "142b7170aa840ffebe843e4848f4204a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4839, "upload_time": "2018-07-06T13:52:52", "url": "https://files.pythonhosted.org/packages/7d/2f/6afbc18a9397523c4e2619382b8adc1ef3130b35df07192b92adecb37f9d/repackage-0.7.1.tar.gz" } ], "0.7.2": [ { "comment_text": "", "digests": { "md5": "b4f887a6e34d15deb58934b9a2a60834", "sha256": "089de0dc0d2aacad578c6fbf7dec7ed64295eee7e8db2469c26e7722b5f83d17" }, "downloads": -1, "filename": "repackage-0.7.2.tar.gz", "has_sig": false, "md5_digest": "b4f887a6e34d15deb58934b9a2a60834", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4862, "upload_time": "2018-07-06T13:54:59", "url": "https://files.pythonhosted.org/packages/ea/16/ee0f6f36c3f56cba4bbd1e6d7746300b2922ba3f005e9fee9b31a8c9d6b9/repackage-0.7.2.tar.gz" } ], "0.7.3": [ { "comment_text": "", "digests": { "md5": "25f6966bc57f665453174a9b3773fbed", "sha256": "350fdbb4a297866e9161e80757dd4582a336b0b7259e58926d96b0644c47d204" }, "downloads": -1, "filename": "repackage-0.7.3.tar.gz", "has_sig": false, "md5_digest": "25f6966bc57f665453174a9b3773fbed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4956, "upload_time": "2018-08-10T08:12:36", "url": "https://files.pythonhosted.org/packages/ce/19/5122e8279b7dfdbacbab648116ac84751b7c603ff3569c5e32ccb75bf0e4/repackage-0.7.3.tar.gz" } ], "0.7b": [ { "comment_text": "", "digests": { "md5": "a1205f0fcc5986aad34003940b195732", "sha256": "daae26712f1738befb551eb2c35e5047e83668d3aa3588375ef989aa4f3f125d" }, "downloads": -1, "filename": "repackage-0.7b.tar.gz", "has_sig": false, "md5_digest": "a1205f0fcc5986aad34003940b195732", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4804, "upload_time": "2018-07-06T13:47:07", "url": "https://files.pythonhosted.org/packages/92/25/4b16e574f2578d82a8cfee03c0543c8968f90f6c7725f3fb167ba39ef818/repackage-0.7b.tar.gz" } ], "0.7c": [ { "comment_text": "", "digests": { "md5": "9c17eae8dedf4e321d23f71c91183c92", "sha256": "68fc10e3902ccd0a2cb5b12f10e6ba5ac56d90b4c4ba2c270f2925ce699424a3" }, "downloads": -1, "filename": "repackage-0.7c.tar.gz", "has_sig": false, "md5_digest": "9c17eae8dedf4e321d23f71c91183c92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4836, "upload_time": "2018-07-06T13:49:13", "url": "https://files.pythonhosted.org/packages/4c/a5/44da0de2e2c32559faedae2831f05691807bea03fa5e5089b6e43617c0be/repackage-0.7c.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "25f6966bc57f665453174a9b3773fbed", "sha256": "350fdbb4a297866e9161e80757dd4582a336b0b7259e58926d96b0644c47d204" }, "downloads": -1, "filename": "repackage-0.7.3.tar.gz", "has_sig": false, "md5_digest": "25f6966bc57f665453174a9b3773fbed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4956, "upload_time": "2018-08-10T08:12:36", "url": "https://files.pythonhosted.org/packages/ce/19/5122e8279b7dfdbacbab648116ac84751b7c603ff3569c5e32ccb75bf0e4/repackage-0.7.3.tar.gz" } ] }