Comment by zbentley
3 days ago
...crash?
Seriously: crash if your dependencies aren't available. There are better ways to do optional dependencies. ImportError ain't it.
3 days ago
...crash?
Seriously: crash if your dependencies aren't available. There are better ways to do optional dependencies. ImportError ain't it.
What is the right way to handle an optional dependency?
https://packaging.python.org/en/latest/guides/writing-pyproj...
I don't understand, sorry. How does declaring an optional dependency in a toml file solve the problem of accessing the symbol in your code?
Also, you need something that works for simple one-file scripts, not just a whole package or project.
I think this import flow tends to be the canonical one.
I might recommend doing something like importing from something like `numpy.version` (or some other "random" very small utils package) so that the work done on file load is still fairly small.
Common? Yes. Canonical/ideal? No. Optional dependency specifiers in your package metadata is a much better way to go. You can use those even if you don't publish your package as an artifact; `pip install -e .[optional-thing]` should work, or can be made to, easily.
1 reply →
It's not clear such a thing even exists in general though. It's certainly not guaranteed by packages.
What would that be for numba?
1 reply →