Single module package?
finnBsch opened this issue · 3 comments
Hi, how would I go about creating a single module package? Say I have one module with a few classes. The automatically generated signatures of the class functions contain then something like
packagename.modulename.classname
However, as this package only contains one module, the packagename and modulename are redundant information. Is there away to create just the module, and not a package? Or to omit these names in the signatures?
Sure you can! I waffled a bit on showing such an example here, but most of the time a realistic package probably grows to have at least a little bit in Python, so that's why the example here is with a module.
You can see at least one example in scikit-build-core's tests, but the idea is simple: install directly to "." rather than a folder name, and don't have a folder with the package name in the repo. Make sure you name the extension nicely, since it's going in site-packages as-is.
You can also have a Python __init__.py
that imports everything from the SO. (well, instead, not also)
Hi Henry,
Thank you for the help. I managed to install my C++ library just as a module. This leads to the function signatures being modulename.classname
, because the module is not part of a package anymore. It makes the documentation more convenient. Now, I am running into a different problem: I want to add external files (images, fonts,..) to be used by the library as described here: https://python-packaging.readthedocs.io/en/latest/non-code-files.html.
For that, it would make sense to install the Python Module into a Folder. This however to my understanding would make it a package, rather than just the module and hence I run into the function signature problem. So, now, what I would like to have:
- Create a Package from my C++ library, so that on installation I get a folder with it
- Omit the Packagename (or the module name) for all signatures in the documentation
Is there a way?
You can also have a Python init.py that imports everything from the SO. (well, instead, not also)
Is this how to achieve that?
And maybe related to that: Why do we use scikit-build-core instead of scikit-build here? I am a bit confused
Sorry, missed this. You want this:
You can also have a Python
__init__.py
that imports everything from the SO. (well, instead, not also)
You'd just have src/packagename/__init__.py
that does from ._core import *
(or, better yet, list things explicitly). Then your module would be packagename._core
.
Scikit-build-core is the modern builder for scikit-build. Eventually, scikit-build will just use scikit-build-core anyway.