Conversation
d0b1815 to
b98047d
Compare
|
Pushes fix linter errors. |
|
For my comprehension: Does removing the filesystem imports completely removes the use of the deprecated |
b98047d to
b8164c7
Compare
sbrodehl
left a comment
There was a problem hiding this comment.
Let's implement "inclusive" traversal using sys.path and pkgutil.
|
Hey there, I have a slightly new take on this based on our discussion. However, as it still feels to be hacky due to the requirement of getting the absolute identifier of the callees package, I have pushed this to a seperate branch, https://github.com/da-h/miniflask/tree/remove_filesystem_imports_new . Removing the hacky part i.e. removing the relative import capability of modules is also possible, though it induces problems in all test scenarios. Feel free to play around here. :) |
… by python anyway)
…basedir,selectivebasedir}
b8164c7 to
843ba7c
Compare
|
Rebased onto |
sbrodehl
left a comment
There was a problem hiding this comment.
Please address the linter issues.
843ba7c to
09ea11a
Compare
3452bcf to
6cfeac4
Compare
6cfeac4 to
0ae1033
Compare
Remove Filesystem Imports
Attention: This is a breaking change! (Search below for the term API-CHange).
This MR changes the way
miniflaskimports modules.Previously,
miniflaskwould overwrite the python import-routine to allow module repositories in the whole filesystem.This however, leads to a variety of problems, for instance harder to track errors in testing environments, instantiations of objects for relative imports compared to instantiations given through
miniflask-routines, etc.The solution to all this is to let
miniflaskdetermine the import paths that python would use for all module imports and use those for importing.With this in place, renaming module-base directories internally, or, allowing filesystem-wide imports is not possible anymore.
Nevertheless I strongly believe that making
miniflaskmimic python's behavior for module naming is more natural and surely more future-proof with regards to understanding the internal behavior as a user and also for debugging for later developments.*Note: Merging this PR closes #115 and closes #97.
Example
Consider the following directory-structure:
usingminiflask.pysits itself in a python package namedsubpackage. This is the actual file that callsmf.initin a way.usingminiflask.py, the accessible modules are calledmodules.module1andmodules.otherdir.module2.modules.module1andmodules.otherdir.module2.myproject.subpackage.modules.module1andmyproject.subpackage.modules.otherdir.module2, asmyproject.subpackageis the actual python-prefix for all modules.myproject.subpackage) should be also added to the miniflask-ids, however, the current design decision is not to do that. In theory, such a change should be doable without breaking to much, however I am not yet sure to be honest. In theory some users might be depending on absolute paths to work. If for instance those do not rely onstate.all, everything should be fine, though.Things done in this MR
The core commit for this MR is probably 83f69641, where the true python import name of each module specification is determined and used to import a module.
There are other things that needed to be done to make this a complete function. Here in more detail:
mf.inita dict for initialization... This is not possible anymore due to the requirement of being also python-import-compatible.module_spec["importname"]to be exactly the same as python's import-name for the respective modules, also forminiflask's pre-shipped modules...I used the opportunity to normalize the folder-structure a bit.
Check all before creating this PR: