wide-midnight-7859803/18/2022, 1:30 AM
? I think
both set the source root, via different mechanisms, and then
is what Pants looks for to identify something pants-able. However, I just did a re-factor, and I'm not sure why I lost access to one of my libraries. /core/BUILD.pants
python_sources( name="libcore", sources=["**/*.py"], )
This above, works, however, nested everything under
python_sources( name="libhelloworld", sources=["**/*.py"], dependencies=[ "core:libcore", ], )
(without adding new BUILD files) and it falls over. My
is as follows:
After re-reading https://www.pantsbuild.org/docs/existing-repositories#migrating-from-other-build-tools-set-custom-build-file-names - I think I can drop the
[GLOBAL] pants_version = "2.11.0.dev2" build_patterns = ["BUILD.pants", "BUILD"] [source] marker_filenames = ["BUILD.pants"] root_patterns = [ "examples/python", "pants-plugins", ] ...
entirely, and while I can add another top-level BUILD to the
directory, I'm not sure why it worked top level but then fails nested... Note: My
had "/" as a root_pattern, when everything was top-level
- but I thought one of the
would have solved that problem
strong-toothbrush-3775903/18/2022, 8:57 AM
./pants list ::
helped me a lot to understand what happens when I change my settings.
wide-midnight-7859803/18/2022, 3:39 PM
./pants list ::
(but I honestly forget what those API calls are EVERY TIME I'm debugging something. It's the strangest thing. Anyways, it's not an error problem, as much, as a qualitative API "surprise"? That's not even the correct word, but I can fully qualify everything, and it works correctly - but it definitely looks ugly in the build files.
witty-crayon-2278603/18/2022, 7:15 PM
subsystem): source roots are how filenames get trimmed at import time: see https://www.pantsbuild.org/docs/source-roots for more info.
to create BUILD files rather than creating them manually. see https://www.pantsbuild.org/v2.10/docs/create-initial-build-files for more info.
wide-midnight-7859803/19/2022, 4:41 AM
strong-toothbrush-3775903/19/2022, 9:19 AM
it should generally be possible since Pants should infer the dependency. But again as @witty-crayon-22786 mentioned, you should probably use
from libcore import something
to create your BUILD files rather than trying to manually create them yourself.
witty-crayon-2278603/21/2022, 7:27 PM
Note: I know that I can fully qualify those core libs tono: neither of these allow for shorthand when you explicitly reference those libraries in a- but I thought one of the
build_patternswould have solved that problem
list. but as @strong-toothbrush-37759 said: needing to explicitly add
lists should be rare due to dependency inference. if you are needing to add a dep manually, it might be because your source roots aren’t set up properly.
to determine that the module name is
and (and so should be imported as
) : and that means that you need
from core import something
to report a source root at
wide-midnight-7859803/22/2022, 12:05 AM
witty-crayon-2278603/22/2022, 12:07 AM