https://pantsbuild.org/ logo
#general
Title
# general
c

creamy-truck-92790

09/19/2022, 3:50 PM
Do I have to use
BUILD
files in all subdirectories that I need or can I also just aggregate all files with:
Copy code
python_sources(
   name="lib",
   sources=["folder/**/*.py"],
)
When I do this, I get the error
ImportError: No module named manage
, but I am not sure if this is because this is not allowed or because I am doing something else that is wrong.
1
c

curved-television-6568

09/19/2022, 3:58 PM
You can aggregate like above.
c

creamy-truck-92790

09/19/2022, 3:59 PM
Any idea what this error then means?
Because I have no clue. Manage is the name of my pex_binary, but even if I change the name it still gives the same error.
c

curved-television-6568

09/19/2022, 4:10 PM
Would need a little more context for that, but feels like an import from your code, maybe?
c

creamy-truck-92790

09/19/2022, 4:29 PM
No import that imports something remotely called manage
h

happy-kitchen-89482

09/19/2022, 4:30 PM
I could be wrong but I suspect
folder/**/*.py
requires at least one intermediate directory, so it won’t match
folder/manage.py
?
If that’s the relevant file?
c

creamy-truck-92790

09/19/2022, 4:42 PM
mhh - let me try that (even though the BUILD file is in the same directory as the manage.py file, I just use it to include the entire app / project structure.
@happy-kitchen-89482 Nope same issue if I also include
folder/*.py
Also
folder/***/**.py
doesn't need the intermediary directory.
Copy code
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/__main__.py", line 103, in <module>
    bootstrap_pex(__entry_point__, execute=__execute__, venv_dir=__venv_dir__)
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex_bootstrapper.py", line 601, in bootstrap_pex
    pex.PEX(entry_point).execute()
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 540, in execute
    sys.exit(self._wrap_coverage(self._wrap_profiling, self._execute))
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 447, in _wrap_coverage
    return runner(*args)
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 478, in _wrap_profiling
    return runner(*args)
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 567, in _execute
    return self.execute_entry(
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 751, in execute_entry
    return self.execute_module(entry_point.module)
  File "/home/cwittlinger/.cache/pants/named_caches/pex_root/unzipped_pexes/cc4f62502bf5ab493fd7e2820e5ed844a75404ec/.bootstrap/pex/pex.py", line 759, in execute_module
    runpy.run_module(module_name, run_name="__main__", alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 220, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/usr/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named manage
That is the error if that helps
To me it looks nothing related to my project
...I take everything back...I was really really stupid. Thanks for the help regardless
c

curved-television-6568

09/19/2022, 5:30 PM
Been there. Happy you found something 👍
6 Views