{ "info": { "author": "Niklas Rosenstein", "author_email": "rosensteinniklas@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Other Environment", "Environment :: Plugins", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: Jython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "localimport allows you to import Python modules in an isolated\nenvironment, preserving the global importer state.\n\n\nFeatures\n========\n\n- Emulates an isolated environment for Python module imports\n- Evaluates ``*.pth`` files\n- Compatible with ``pkg_resources`` namespaces\n- Mocks ``pkgutil.extend_path()`` to support zipped Python eggs\n\nExample\n=======\n\nGiven your Python script, application or plugin comes with a directory\nthat contains modules for import, you can use localimport to keep the\nglobal importer state clean.\n\n::\n\n app.py\n res/modules/\n some_package/\n __init__.py\n\n.. code:: python\n\n # app.py\n with localimport('res/modules') as _importer:\n import some_package\n assert 'some_package' not in sys.modules\n\n **Important**: You must keep the reference to the ``localimport``\n object alive, especially if you use ``from xx import yy`` imports.\n\nUsage\n=====\n\n| In most cases it would not make sense to use ``localimport`` as a\n Python module when you actually want to import Python modules since\n the import of the ``localimport`` module itself would not be isolated.\n| The solution is to use the ``localimport`` source code directly in\n your application code. Usually you will use a minified version.\n\nPre-minified versions of ``localimport`` can be found in this\n`Gist `__. Of course you can minify\nthe code by yourself, for example using the\n`nr `__ command-line tools.\n\n::\n\n nr py.blob localimport.py -cme localimport > localimport-gzb64-w80.py\n\nDepending on your application, you may want to use a bootstrapper entry\npoint.\n\n.. code:: python\n\n # @@@ minified localimport here @@@\n\n with localimport('.') as _importer:\n from my_application_package.__main__ import main\n main()\n\nAPI\n===\n\n``localimport(path, parent_dir=None, do_eggs=True, do_pth=True, do_autodisable=True)``\n--------------------------------------------------------------------------------------\n\n A context manager that creates an isolated environment for importing\n Python modules. Once the context manager exits, the previous global\n state is restored.\n\n Note that the context can be entered multiple times, but it is not\n recommended generally as the only case where you would want to do\n that is inside a piece of code that gets executed delayed (eg. a\n function) which imports a module, and building the isolated\n environment and restoring to the previous state has some performance\n impacts.\n\n Also note that the context will only remove packages on exit that\n have actually been imported from the list of paths specified in the\n *path* argument, but not modules from the standard library, for\n example.\n\n **Parameters**\n\n - *path* \u2013 A list of paths that are added to ``sys.path`` inside\n the context manager. Can also be a single string. If one or more\n relative paths are passed, they are treated relative to the\n *parent\\_dir* argument.\n - *parent\\_dir* \u2013 A path that is concatenated with relative paths\n passed to the *path* argument. If this argument is omitted or\n ``None``, it will default to the parent directory of the file\n that called the ``localimport()`` constructor (using\n ``sys._getframe(1).f_globals['__file__']``).\n - *do\\_eggs* \u2013 A boolean that indicates whether ``.egg`` files or\n directories found in the additional paths are added to\n ``sys.path``.\n - *do\\_pth* \u2013 A boolean that indicates whether ``.pth`` files found\n in the additional paths will be evaluated.\n - *do\\_autodisable* \u2013 A boolean that indicates that\n ``localimport.autodisable()`` should be called automatically be\n the context manager.\n\n *Changed in 1.7* Added ``do_autodisable`` parameter.\n\n``localimport.autodisable()``\n-----------------------------\n\n Uses ``localimport.discover()`` to automatically detect modules that\n could be imported from the paths in the importer context and calls\n #disable on all of them.\n\n *New in 1.7*\n\n``localimport.disable(modules)``\n--------------------------------\n\n Disable one or more modules by moving them from the global module\n cache (``sys.modules``) to a dictionary of temporary hidden modules\n in the isolated environment. Once the ``localimport()`` context\n manager exits, these modules will be restored. Does nothing when a\n module does not exist.\n\n **Parameters**\n\n - *modules* \u2013 A list of module names or a single module name\n string.\n\n``localimport.discover()``\n--------------------------\n\n A shorthand for ``pkgutil.walk_packages(importer.path)``.\n\n *New in 1.7*\n\n--------------\n\n\nCopyright \u00a9 2018 Niklas Rosenstein", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/NiklasRosenstein/localimport", "keywords": "import,embedded,modules,packages", "license": "", "maintainer": "", "maintainer_email": "", "name": "localimport", "package_url": "https://pypi.org/project/localimport/", "platform": "", "project_url": "https://pypi.org/project/localimport/", "project_urls": { "Homepage": "https://github.com/NiklasRosenstein/localimport" }, "release_url": "https://pypi.org/project/localimport/1.7.3/", "requires_dist": null, "requires_python": "", "summary": "Isolated import of Python Modules", "version": "1.7.3" }, "last_serial": 3605442, "releases": { "1.4.16": [ { "comment_text": "", "digests": { "md5": "c5358ba971c82cf3d605786cfd6547e7", "sha256": "420cc4e163caadc9606bed74bdb19b3f99ecf4770adc36384ade0f02be819fc1" }, "downloads": -1, "filename": "localimport-1.4.16.tar.gz", "has_sig": false, "md5_digest": "c5358ba971c82cf3d605786cfd6547e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3788, "upload_time": "2016-08-09T00:38:47", "url": "https://files.pythonhosted.org/packages/06/9d/16e591cc4b56b25e08b2ac4b6410647675d189914fa50b71bea4397ef2da/localimport-1.4.16.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "c8413336de5e9c824d1b61603a20e4da", "sha256": "ae137b40e4cddd57184995c66afb830deddb0f804cd09bb6cb41d90dce023dd8" }, "downloads": -1, "filename": "localimport-1.5.tar.gz", "has_sig": false, "md5_digest": "c8413336de5e9c824d1b61603a20e4da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8883, "upload_time": "2016-08-09T01:00:11", "url": "https://files.pythonhosted.org/packages/36/e8/2419ac4c5a729fc1010822d405c68bec837dce0ba50ecf3c2ec4392bf4a4/localimport-1.5.tar.gz" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "b3e8478991491d75ea0c38d1dc441535", "sha256": "08f7c3eb6161f5dfbb7db1b7d0ff9d72dd09e8612e42638384740710ec8e8ed0" }, "downloads": -1, "filename": "localimport-1.5.1.zip", "has_sig": false, "md5_digest": "b3e8478991491d75ea0c38d1dc441535", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14425, "upload_time": "2017-02-20T16:25:15", "url": "https://files.pythonhosted.org/packages/59/6f/49f1d83ac9e01adf247dc9f7ad4cf978a2a4f95573d4611a981e48e9660b/localimport-1.5.1.zip" } ], "1.5.2": [ { "comment_text": "", "digests": { "md5": "794a8e57a69f7b5876666c491b6bbe2a", "sha256": "412c6371a19c79ec096697b856f02e81dc05a911b977e43cbbb120e4a6c1dde4" }, "downloads": -1, "filename": "localimport-1.5.2.tar.gz", "has_sig": false, "md5_digest": "794a8e57a69f7b5876666c491b6bbe2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8148, "upload_time": "2017-05-24T12:05:13", "url": "https://files.pythonhosted.org/packages/cf/21/a34a0fe3767cc16e239c49db4e16540982d77b2c2c900ec6b525f5bea566/localimport-1.5.2.tar.gz" } ], "1.6.0": [ { "comment_text": "", "digests": { "md5": "afed9d270da629743cc2e8ee4589a92d", "sha256": "cfbac2670cc8b2a79a5687c1557e8da993536356818517380c8396421d24bb7f" }, "downloads": -1, "filename": "localimport-1.6.0.tar.gz", "has_sig": false, "md5_digest": "afed9d270da629743cc2e8ee4589a92d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7034, "upload_time": "2018-02-17T19:45:45", "url": "https://files.pythonhosted.org/packages/77/ee/d1c368d768f89d8bfc4517b8254db8f6e88eeac55918752b6c61dbefdc79/localimport-1.6.0.tar.gz" } ], "1.6.1": [ { "comment_text": "", "digests": { "md5": "5ec6e58ca3611ba9376945218cea2dca", "sha256": "e27bcb19dba3b114bb4cf784eb9af6bc5a87f169a3d31a2064ab251841e948f6" }, "downloads": -1, "filename": "localimport-1.6.1.tar.gz", "has_sig": false, "md5_digest": "5ec6e58ca3611ba9376945218cea2dca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7140, "upload_time": "2018-02-18T08:56:35", "url": "https://files.pythonhosted.org/packages/7a/60/3bda78acdcf76d843805015d605dd51441cd5989a5d079fdeeea29062391/localimport-1.6.1.tar.gz" } ], "1.6.1a0": [ { "comment_text": "", "digests": { "md5": "574660038b17633cdbcd46f606cb2834", "sha256": "9001d6d23d9f394f21546e704152b679851c2892e405f64e339943cd64afa268" }, "downloads": -1, "filename": "localimport-1.6.1a0.tar.gz", "has_sig": false, "md5_digest": "574660038b17633cdbcd46f606cb2834", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7130, "upload_time": "2018-02-18T09:48:46", "url": "https://files.pythonhosted.org/packages/a6/d7/4957c5e98f15b5b9600a961dac408bc6bfcc170fe843cbff21ec529861ea/localimport-1.6.1a0.tar.gz" } ], "1.6.1a2": [ { "comment_text": "", "digests": { "md5": "dc651c6f80856186b636b3712b993471", "sha256": "0c728ce2bb94a091bdf9921f8beb057e88de5885efd1401391b97b4df11391ec" }, "downloads": -1, "filename": "localimport-1.6.1a2.tar.gz", "has_sig": false, "md5_digest": "dc651c6f80856186b636b3712b993471", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7127, "upload_time": "2018-02-18T10:00:44", "url": "https://files.pythonhosted.org/packages/4d/1c/e105f671ece62fdb6f0dc6762bce8921c96558763a9ddf19af770aeec224/localimport-1.6.1a2.tar.gz" } ], "1.7.0": [ { "comment_text": "", "digests": { "md5": "b3d6630836daeff912c4b402c270e6e6", "sha256": "d7aba90a6e6abc8355e325f6065ec59821eb55afa2ae1847ef8a967a6f3ab310" }, "downloads": -1, "filename": "localimport-1.7.0.tar.gz", "has_sig": false, "md5_digest": "b3d6630836daeff912c4b402c270e6e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7577, "upload_time": "2018-02-18T13:09:22", "url": "https://files.pythonhosted.org/packages/33/36/101bbe18102148b04a8080a64e8591f59e99f88e695d1f0966b2bc1067b0/localimport-1.7.0.tar.gz" } ], "1.7.1": [ { "comment_text": "", "digests": { "md5": "b8c16473a800c3321c2949c69edab75b", "sha256": "2f7cbd2fab7fe35f6d82ffc2d9ec174c5e3c33b8507d619a12c52f9767754578" }, "downloads": -1, "filename": "localimport-1.7.1.tar.gz", "has_sig": false, "md5_digest": "b8c16473a800c3321c2949c69edab75b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7562, "upload_time": "2018-02-18T13:14:44", "url": "https://files.pythonhosted.org/packages/98/fe/a93e8957404b86f03219e7e94d4b0c7e9494cab7a8c5a323b6b94d4713b9/localimport-1.7.1.tar.gz" } ], "1.7.2": [ { "comment_text": "", "digests": { "md5": "52376ea5e0affd5359ddb938f66cb28b", "sha256": "005e03531f81b2855daa809cd85419a7559210244d2681f165fb92f2290712af" }, "downloads": -1, "filename": "localimport-1.7.2.tar.gz", "has_sig": false, "md5_digest": "52376ea5e0affd5359ddb938f66cb28b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7572, "upload_time": "2018-02-22T13:32:51", "url": "https://files.pythonhosted.org/packages/6a/02/345a3c0cbbabb753746caba73df92fc0a77bb912d1debb4cba6356594ff1/localimport-1.7.2.tar.gz" } ], "1.7.3": [ { "comment_text": "", "digests": { "md5": "4c78b76b7821666a332f4e74c7fcfcda", "sha256": "a7b0023b3251c07f6120231cc6d56dfebfadc04a05b03c4f286b9aac59c521ba" }, "downloads": -1, "filename": "localimport-1.7.3.tar.gz", "has_sig": false, "md5_digest": "4c78b76b7821666a332f4e74c7fcfcda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7818, "upload_time": "2018-02-22T13:54:48", "url": "https://files.pythonhosted.org/packages/24/a5/5ee98dc4c8eee5b1efe8209d9582b67ba592fcf9dbbe1570701414c79c21/localimport-1.7.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c78b76b7821666a332f4e74c7fcfcda", "sha256": "a7b0023b3251c07f6120231cc6d56dfebfadc04a05b03c4f286b9aac59c521ba" }, "downloads": -1, "filename": "localimport-1.7.3.tar.gz", "has_sig": false, "md5_digest": "4c78b76b7821666a332f4e74c7fcfcda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7818, "upload_time": "2018-02-22T13:54:48", "url": "https://files.pythonhosted.org/packages/24/a5/5ee98dc4c8eee5b1efe8209d9582b67ba592fcf9dbbe1570701414c79c21/localimport-1.7.3.tar.gz" } ] }