Enhance the way for importing python third-party library
Closed this issue · 7 comments
In #364, it created a module called pylibmgr
to manage and import python third-party library from third-party library root thirdparty
.
However, the way for import third-party library is appending to sys.path
, which deteriorate maintainability.
Reference: #364 (comment)
modmesh needs a better way to import third-party library!
Thanks, @j8xixo12 , for creating this issue to track the work to enhance the path finding.
However, the way for import third-party library is appending to
sys.path
, which deteriorate maintainability. Reference: #364 (comment)
Yes, the key is that we should not modify sys.path
(or adding/deleting entries) inside the modmesh
package. It will surprise other packages.
Yes, there is some remaining for this issue.
I found a way in the official Python documentation that allows Python to load a module or package from a source file with a global scope.
https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
I think this is a good way to import third-party library without modified sys.path
!
Yes, there is some remaining for this issue.
I found a way in the official Python documentation that allows Python to load a module or package from a source file with a global scope.
https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
I think this is a good way to import third-party library without modified
sys.path
!
If you are OK with using the Python magic, perhaps meta_path
can be considered: https://yyc.solvcon.net/en/latest/nsd/12advpy/advpy.html#module-magic-with-meta-path . meta_path
gives me an impression that it provides higher modularity for the third-party import.
Both ways are OK to me. What do you think?
Yes, there is some remaining for this issue.
I found a way in the official Python documentation that allows Python to load a module or package from a source file with a global scope.
https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
I think this is a good way to import third-party library without modifiedsys.path
!If you are OK with using the Python magic, perhaps
meta_path
can be considered: https://yyc.solvcon.net/en/latest/nsd/12advpy/advpy.html#module-magic-with-meta-path .meta_path
gives me an impression that it provides higher modularity for the third-party import.Both ways are OK to me. What do you think?
Using meta_path
looks good to me, let me use it to enhance the importing way of third-party library.
No, there is no remaining work, let’s close this issue.