Closed pawamoy closed 1 year ago
This is my first time looking at the __module__
attribute, so I don't have any good ideas off the top of my head. It looks like the pure C implementation has the same property, though, so maybe this is just a native module thing in general? You can test it like this:
$ python3 -m venv /tmp/tempenv
$ source /tmp/tempenv/bin/activate
(tempenv) $ cd blake3-py/c_impl
(tempenv) $ pip install .
...
(tempenv) $ python3
Python 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from blake3 import blake3
>>> blake3.__module__
'builtins'
What are some other pure-C or pure-Rust modules we could look at for comparison?
Another project using maturin gives the same result: https://github.com/samuelcolvin/watchfiles.
$ python -m venv .venv
$ . .venv/bin/activate
$ pip install watchfiles
$ python -c 'from watchfiles.main import RustNotify; print(RustNotify.__module__)'
builtins
what about Pydantic core?
$ python -c 'from pydantic_core import SchemaValidator; print(SchemaValidator.__module__)'
pydantic_core._pydantic_core
We could ask @samuelcolvin 👋
You just need to set module
on the pyclass
, see here.
Thanks @samuelcolvin!
No problem 👍.
Released as version 0.3.2. (After quite a bit of wrangling with an unreleated CI break...)
Wow, this was fast!! I'm gonna update and test mkdocstrings. Thanks a lot everyone!
Yup, thanks for the quick release!!
I guess it comes from your build system (maturin IIUC?), but
blake3.blake3.blake3
(or the shorterblake3.blake3
) says its parent module isbuiltins
:It's problematic because there's no
blake3
object importable frombuiltins
. It makes it impossible to inspect the object without special-casing it. For reference: https://github.com/mkdocstrings/mkdocstrings/issues/451#issuecomment-1353709610Do you know if there's a way to compile the project so that its objects correctly report their parent modules, for example
blake3.blake3
(and notbuiltins
)?