Custom Component is having trouble loading

Hi,

I’m testing out a custom authentication component for my Streamlit app. However, when using the component in production, it fails to render for some reason.

image

I’ve managed to get i to work in dev mode by forking the code and adding it to my Streamlit project - but I still can’t make it run in production.

Upon digging a bit, it seems to me that the declaration of the component fails since the build path for some reason doens’t work. It looks like the assertion fails since the module is none as per the following traceback

venv\lib\site-packages\streamlit\components\v1\components.py:284, in declare_component(name, path, url)
    281 # Get the caller's module name. `__name__` gives us the module's
    282 # fully-qualified name, which includes its package.
    283 module = inspect.getmodule(caller_frame)
--> 284 assert module is not None
...
    288 # user executed `python my_component.py`), then this name will be
    289 # "__main__" instead of the actual package name. In this case, we use
    290 # the main module's filename, sans `.py` extension, as the component name.

AssertionError: 

To obtain the build_path I use the following:


root_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(root_dir, "frontend\\dist")

This returns:

'c:\\Users\\initials\\xxx\\Desktop\\Absence importer\\absense_importer\\frontend\\dist'

I’ve also tried to wrap everything inside a Linux Docker container, but to no avail, unfortunately. Can anyone spot my error?

I’m on Python 3.10.7 and using Streamlit 1.18.1.