Title is kinda confusing, but basically, I followed the Python packaging process to set up my Python package development environment. My project structure is layed out the same, except for a .venv in the root directory (not in src), and additional Python files in the src/package_username directory.
I can build my package fine, but when I go to import it into other projects, I have to import it like import package_username.file or from package_username.file import SomethingInFile. For other python packages, I would only need to do import package or from package import Something.
How can I set up by build process to remove the need for the first portion in my import statements so it matches other packages like termcolor? Is there something I need to add in my __init__.py file?


it’s strange the packaging guide doesn’t mention
__all__. Check this out https://realpython.com/python-all-attribute/#exposing-names-from-modules-and-packages-with-__all__Ignore wildcard (star) imports, it’s a bad practice most of the times. I wish they emphasized that more instead of appearing to promote it from the table of contents…
I looked at the guide you linked. So in my
__init__.pyfile, I should import each public name I want from my files, then add them to the__all__list like this? (I want to make sure I understood the guide correctly)right, those names are also useful when importing your package in tests
you can also create a
__version__string and append it to__all__to have amypackage.__version__to pull version from
pyproject.toml: