Sorry about this I've another Pants issue I could ...
# general
Sorry about this I've another Pants issue I could use some support on. I've got this structure that I'm trying to build a pex_binary target for (and eventually a docker target, but I'm not there yet): bar • bar ◦ ◦ ◦ ◦ • test ◦ ◦ <test_files> • BUILD • README • Dockerfile And this is my BUILD file
Copy code
    name = "bar",
    sources = ["bar/*.py"],
    sources = ["test/test_*.py"],
Here is the error:
Copy code
$ ./pants run bar:run 
Traceback (most recent call last):
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 483, in execute
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 401, in _wrap_coverage
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 432, in _wrap_profiling
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 539, in _execute
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 655, in execute_entry
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/", line 686, in execute_pkg_resources
  File "/home/james/Documents/monorepo/.pants.d/tmpfiz317ey/run.pex/.bootstrap/pex/vendor/_vendored/setuptools/pkg_resources/", line 2481, in resolve
ModuleNotFoundError: No module named 'server'
And checking my
is see: bar bar/bar bar/test Also the tests run fine when I do
./pants test bar:test
Given my past problems I'm assuming it's a roots issue, but my other targets (2 packages, 2 tests) and the tests here all work. It's just the
in this web service that seems to not be working now.
Just guessing here.. but it could be the
root that causing issues.. did you see it required for something else to work?
Aside, you shouldn’t have to add the dependency in the pex target.. as it will be inferred from the entry point.
Yeah this was the solution to my problem the other day with my directory structure where I had core/core/ requiring to be referenced as: core.core.something. There's 3 subfolders in this repo currently with the same structure and path entries and they all package and test fine,
tests fine but fails to run
I would have expected a source root of just
to allow other parts to reference your modules as
But I’m no expert, so will defer for a few hours until the experts wake up.. 🙂
Yeah you're right I'd just written an overly permissive glob in the roots config. But restricting it back down doesn't change anything
Ok this was the issue. I think the problems where: 1) My thinking about roots (I'd assumed it wouldn't hurt to have move files in there than the actual root) 2) The root_pattern glob was always drilling down too far as my folders are
so a pattern of
always yields
The Fix:
Copy code
marker_filenames = ["BUILD"]
As I only put
in my roots. Thanks again
👍 1
Thanks for the feedback.
Glad that worked out! Sorry for the trouble. Source roots can be a gotcha, if you have any suggestions on how to improve the documentation on them, that would be really appreciated!
💯 1
I had in the past done a little work on autodetecting them in
, but it's trickier than you might think
Thanks, will do. I'll get my Proof of Concept project working then I'll reflect on the pain points and see how I can contribute back 🙂
❤️ 2