reflex icon indicating copy to clipboard operation
reflex copied to clipboard

[BUILD] `reflex component build` -- module not found error -- reflex 0.7.6

Open TimChild opened this issue 9 months ago β€’ 2 comments

Describe the issue

Running reflex component build I'm getting ModuleNotFoundError: No module named 'clerk_api_demo'.

Only occurs on 0.7.6

Also was occurring because of a "scripts" dir I had with some .py files in.

Expected behavior

What should have happened?

No errors...

Steps to reproduce (if applicable)

  1. Try to build a reflex component that includes a demo (the standard layout) with reflex 0.7.6

Environment

  • Reflex Version: 0.7.6
  • Python Version: 3.13
  • OS: Linux

Thoughts on solution:

Seems to be related to the .pyi stubs generation[^*]. Looks like you're scanning all directories at the root of the project and only skipping them if they have "pycache" in the name (custom_components.py:408). Then deeper in you're trying to import python files (pyi_generator.py:1124).

I think you either want to be more careful about filtering which dirs to scan (do you need to look in more than just "custom_components"?) or add a try catch on the module import (although it's probably best not to try importing files that don't have anything to do with the component, e.g. scripts that have some other purpose, just in case they are somehow in the path, and aren't set up to only run if called directly).

Didn't feel comfortable submitting a PR for this, because I'm not sure what exactly the intentions are of the top level directory walk in the first place.

Also, introducing path.walk in custom_components.py:407 requires python >= 3.12, whereas everything else is python >= 3.10 compatible afaik.

[^*]: is stubs generation for custom components new btw? I've been wondering if it was there but hadn't got around to checking yet...

TimChild avatar Apr 11 '25 00:04 TimChild

Just realized the "build" label probably refers to the build process of reflex run not reflex component build... But I can't change that now, sorry!

TimChild avatar Apr 11 '25 00:04 TimChild