Build dedicated Python Package for `try_import()`
See original GitHub issueDear Optuna team,
I very much like your try_import()
utility from here: https://github.com/optuna/optuna/blob/99484054fcec97eb530960a8612c3e6058ee5690/optuna/_imports.py
I would like to use that kind of functionality in other Python Packages that we want to develop. But that package does not have an optuna dependency. That’s why I ask:
Do you plan to release that as an utility package that can be reused by other packages?
If not I would like to inform you that I am creating such a package and open source it under the same MIT License.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Packaging Python Projects
This tutorial walks you through how to package a simple Python project. It will show you how to add the necessary files and...
Read more >How can I import a module dynamically given the full path?
For Python 3.3 and 3.4 use: from importlib.machinery import SourceFileLoader foo = SourceFileLoader("module.name", "/path/to/file.py").load_module() foo.
Read more >Packaging Pitfalls — PyOxidizer 0.4.0 documentation
Many Python packages compile extension modules to native code. (Typically C is used to implement extension modules.) The way this typically works is...
Read more >Publishing your own Python package | by Shay Palachy
In the following post I'll try to walk you through the minimal process I have settled on for packaging Python code, building on...
Read more >Python and TOML: New Best Friends - Real Python
Format and Style TOML Documents; Create TOML From Scratch With tomlkit ... A new module for TOML parsing is being added to Python's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the late reply. Appreciate you checking.
Creating an independent library sounds interesting. I could see it being applicable to other applications as you say. Unfortunately, there’s no plan for the time being in doing so.
try_import
was mostly implemented as a quick internal/private tool to DRY code. There might be room for improving the API, or perhaps even including other related features such as the lazy submodule import helper.Having that said, I don’t see problems in you creating a library deriving it given your description (e.g. the MIT license). If you don’t mind, mentioning Optuna would be very much appreciated, though.
Thanks again. We have published the try_import functionality here: https://github.com/telekom/lazy-imports
Although we took the _LazyModule class from HuggingFace. This implementation somehow worked better for us.