Name | reimport-ng JSON |
Version |
1.5.1
JSON |
| download |
home_page | None |
Summary | Reimport a module in Python3 |
upload_time | 2024-09-01 17:48:01 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | MIT License Copyright (c) 2019 InterSystems Developer Community Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
reimport
module
python3
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Reimport-ng
>Reimport-ng is a fork of the original [reimport](https://bitbucket.org/petershinners/reimport) module by Peter Shinners. The original module was last updated in 2014 and is not compatible with Python 3.8+. This fork aims to update the module to work with Python 3.8+ and to fix any bugs that may have been present in the original module.
This module intends to be a full featured replacement for Python's reload function. It is targeted towards making a reload that works for Python plugins and extensions used by longer running applications.
Reimport currently supports Python 3.8+.
By its very nature, this is not a completely solvable problem. The goal of this module is to make the most common sorts of updates work well. It also allows individual modules and package to assist in the process. A more detailed description of what happens is on the [Wiki](https://bitbucket.org/petershinners/reimport/wiki) page.
## Quick Docs
There are two functions in the API.
def reimport(*modules):
"""Reimport python modules. Multiple modules can be passed either by
name or by reference. Only pure python modules can be reimported."""
return None
def modified(path=None):
"""Find loaded modules that have changed on disk under the given path.
If no path is given then all modules are searched."""
return list_of_strings
## Related
There have been previous attempts at python reimporting. Most are incomplete or frightening, but several of them are worth a closer look.
* [Livecoding](http://code.google.com/p/livecoding) is one of the more complete, it offers a special case directory tree of Python modules that are treated as live files.
* [mod_python](http://www.modpython.org) has implemented a similar reloading mechanism. The module reloading itself may be difficult to use outside mod_python's environment.
* [xreload](http://svn.python.org/projects/sandbox/trunk/xreload) The python source itself comes with a minimal extended reload.
* [globalsub](http://packages.python.org/globalsub) Replace and restore objects with one another globally.
## Overview of the reimport process
The reimport process is handled in several steps.
- A list of modules and packages are given to be reimported.
- For each module, we check all parent packages for a package_reimport value. If the value is True we will reimport the entire package, instead of just the submodule.
- Build a unique set of final modules and packages to reimport. Sort them by package depth order.
- Check each module for SyntaxError and early exception out.
- Move all packages to be reloaded out of sys.modules and hang onto them.
- Reimport modules one at a time. Check to make sure it hasn't already been imported from a parent package being reimported.
- If module added values to all that are missing, AttributeError is raised and reimports are rolled back.
- Find reimported callback and pass the old module reference as an argument
- If callback returns False, do not perform the rejigger for that module
- Exceptions from the callback are redirected to traceback.print_exc
- Find parent packages that haven't been reimported that appear to import * (change for 1.1)
- Push exported symbols from children into these parents (change for 1.1)
- Begin rejigger process for each module imported
- Match old objects to new objects by name
- Transmute classes and functions in the module from old to new
- Switch references from the old object to the new
- For lists, sets, and dictionaries this isn't tricky.
- For tuples it is trickier, but an attempt is made to build a new tuple, and swap references to the tuple itself.
- Classes that derive from the old object have their bases modified.
- Instance have their class swapped
- Remove references to old objects that have no matching named object
- Similar process to the above reference switching
- Note, this doesn't seem to find bound methods to a method that gets dropped
- My first guess is that the gc doesn't track bound methods? (surprising)
## Credits
Reimport was written by Peter Shinners. The original module was last updated in 2014.
Raw data
{
"_id": null,
"home_page": null,
"name": "reimport-ng",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "reimport, module, python3",
"author": null,
"author_email": "grongier <guillaume.rongier@intersystems.com>",
"download_url": "https://files.pythonhosted.org/packages/7f/c2/e1a1437f9e16229d4fa2e637d31b30f0c1aa11d098fefe60e2c90cc81977/reimport_ng-1.5.1.tar.gz",
"platform": null,
"description": "# Reimport-ng\n \n>Reimport-ng is a fork of the original [reimport](https://bitbucket.org/petershinners/reimport) module by Peter Shinners. The original module was last updated in 2014 and is not compatible with Python 3.8+. This fork aims to update the module to work with Python 3.8+ and to fix any bugs that may have been present in the original module.\n\nThis module intends to be a full featured replacement for Python's reload function. It is targeted towards making a reload that works for Python plugins and extensions used by longer running applications. \n\nReimport currently supports Python 3.8+.\n\nBy its very nature, this is not a completely solvable problem. The goal of this module is to make the most common sorts of updates work well. It also allows individual modules and package to assist in the process. A more detailed description of what happens is on the [Wiki](https://bitbucket.org/petershinners/reimport/wiki) page.\n\n## Quick Docs\n\nThere are two functions in the API.\n\n def reimport(*modules):\n \"\"\"Reimport python modules. Multiple modules can be passed either by\n name or by reference. Only pure python modules can be reimported.\"\"\"\n return None\n \n def modified(path=None):\n \"\"\"Find loaded modules that have changed on disk under the given path.\n If no path is given then all modules are searched.\"\"\"\n return list_of_strings \n\n\n## Related\n\nThere have been previous attempts at python reimporting. Most are incomplete or frightening, but several of them are worth a closer look.\n\n * [Livecoding](http://code.google.com/p/livecoding) is one of the more complete, it offers a special case directory tree of Python modules that are treated as live files.\n * [mod_python](http://www.modpython.org) has implemented a similar reloading mechanism. The module reloading itself may be difficult to use outside mod_python's environment.\n * [xreload](http://svn.python.org/projects/sandbox/trunk/xreload) The python source itself comes with a minimal extended reload.\n * [globalsub](http://packages.python.org/globalsub) Replace and restore objects with one another globally.\n\n## Overview of the reimport process\n\nThe reimport process is handled in several steps.\n\n- A list of modules and packages are given to be reimported.\n- For each module, we check all parent packages for a package_reimport value. If the value is True we will reimport the entire package, instead of just the submodule.\n- Build a unique set of final modules and packages to reimport. Sort them by package depth order.\n- Check each module for SyntaxError and early exception out.\n- Move all packages to be reloaded out of sys.modules and hang onto them.\n- Reimport modules one at a time. Check to make sure it hasn't already been imported from a parent package being reimported.\n - If module added values to all that are missing, AttributeError is raised and reimports are rolled back.\n- Find reimported callback and pass the old module reference as an argument\n - If callback returns False, do not perform the rejigger for that module\n - Exceptions from the callback are redirected to traceback.print_exc\n- Find parent packages that haven't been reimported that appear to import * (change for 1.1)\n - Push exported symbols from children into these parents (change for 1.1)\n- Begin rejigger process for each module imported\n - Match old objects to new objects by name\n - Transmute classes and functions in the module from old to new\n - Switch references from the old object to the new\n - For lists, sets, and dictionaries this isn't tricky.\n - For tuples it is trickier, but an attempt is made to build a new tuple, and swap references to the tuple itself.\n - Classes that derive from the old object have their bases modified.\n - Instance have their class swapped\n - Remove references to old objects that have no matching named object\n - Similar process to the above reference switching\n - Note, this doesn't seem to find bound methods to a method that gets dropped\n - My first guess is that the gc doesn't track bound methods? (surprising)\n\n## Credits\n\nReimport was written by Peter Shinners. The original module was last updated in 2014.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2019 InterSystems Developer Community Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Reimport a module in Python3",
"version": "1.5.1",
"project_urls": {
"documentation": "https://github.com/grongierisc/reimport-ng/blob/master/README.md",
"homepage": "https://github.com/grongierisc/reimport-ng",
"issues": "https://github.com/grongierisc/reimport-ng/issues",
"repository": "https://github.com/grongierisc/reimport-ng"
},
"split_keywords": [
"reimport",
" module",
" python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "345e5c06d5929aeafdc6df6034969a75f761d12e31d82819d7b8e408d5d21bf8",
"md5": "a8669b7043fc266d5ff037ccab4f25a4",
"sha256": "e15971fa7d6eec6954929cac0a6fe6a378c5fa41c94e6460beda89c52e2a09c3"
},
"downloads": -1,
"filename": "reimport_ng-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a8669b7043fc266d5ff037ccab4f25a4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11022,
"upload_time": "2024-09-01T17:48:00",
"upload_time_iso_8601": "2024-09-01T17:48:00.552229Z",
"url": "https://files.pythonhosted.org/packages/34/5e/5c06d5929aeafdc6df6034969a75f761d12e31d82819d7b8e408d5d21bf8/reimport_ng-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7fc2e1a1437f9e16229d4fa2e637d31b30f0c1aa11d098fefe60e2c90cc81977",
"md5": "8399079ccc004c476cb225e2364ab52d",
"sha256": "434a661fe4967ae89ce618e70fc80723c26c883f1f78aae40e9c5f7a56bb86b1"
},
"downloads": -1,
"filename": "reimport_ng-1.5.1.tar.gz",
"has_sig": false,
"md5_digest": "8399079ccc004c476cb225e2364ab52d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13628,
"upload_time": "2024-09-01T17:48:01",
"upload_time_iso_8601": "2024-09-01T17:48:01.942018Z",
"url": "https://files.pythonhosted.org/packages/7f/c2/e1a1437f9e16229d4fa2e637d31b30f0c1aa11d098fefe60e2c90cc81977/reimport_ng-1.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-01 17:48:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "grongierisc",
"github_project": "reimport-ng",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "reimport-ng"
}