Where does pants look for code? Does it look in th...
# general
a
Where does pants look for code? Does it look in the current git-repository scope? I have a 'master' repository with all the micro-repos checked out into it (controlled by
myrepo
or
mr
). under
/libraries
,
/services
etc. But despite setting
Copy code
[source]
root_patterns = [
    "/scripts",
    "/libraries",
    "/services",
    "/devops",
]
./pants count-loc '*'
doesn't find anything that isn't a file in the root
So even with the following:
Copy code
#pants.toml
[GLOBAL]
pants_version = "2.4.0"
backend_packages = [
    "pants.backend.python"
]

[source]

root_patterns = [
    "src/python",
    "test/python",
]
Copy code
$ git ls-files
.gitignore
pants
pants.toml
src/python/widget/foo.csv
src/python/widget/foo.py
I get the following:
Copy code
$ ./pants count-loc '*'
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
BASH                         1       283       17        18      248          3
TOML                         1        13        3         0       10          0
gitignore                    1         5        0         1        4          0
───────────────────────────────────────────────────────────────────────────────
Total                        3       301       20        19      262          3
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop $6,619
Estimated Schedule Effort 2.279288 months
Estimated People Required 0.344007
───────────────────────────────────────────────────────────────────────────────
pants isn't picking up my
foo.py
and
foo.csv
in
widget
h
I think you want
./pants count-loc '**'
'*'
globs over the files in the cwd,
'**'
globs over everything underneath it at any level.
a
ah
h
Sorry if that wasn't clear in the docs.
a
🎉 got something testing, and wheeling something.
h
Excellent!
Let us know here if you hit any issues.
b
Difficult to track down in the docs, but it's at https://www.pantsbuild.org/docs/rules-api-file-system#pathglobs The docs search feature treats
*
,
"*"
, and
"**"
as a search wildcard rather than a literal. I'm adding mentions of the words "globbing" and "wildcard" there just to add a bit of SEO assist.
I wonder if there's another place in the doc that this info should go. It's currently under The Rules API. But someone doesn't have to be knowingly using the Rules API to need this info. So it'd be helpful to encounter Pants file path globbing operators in a general info section early on.
h
I feel like it has to be there somewhere? Weird as hell if not.
b
Could well be. It might just be something that needs to be more findable by search. See what you can turn up.
h
Should be the "Sources" section of Targets page
a
One thing in the docs I've noticed is it doesn't actually spell it out on how to do things
no single page of going through • installing • configuring • testing • building
it's also seems a bit weird how: • it seems to depend on the location of your
./pants
executable, not the
pants.toml
file •
./pants test
doesn't do anything, and doesn't say why. you need to do
./pants test ::
or
./pants test '**'
to test everything. • When you get an error on dependencies, it doesn't mention who's causing it to error
ResolveError: The file or directory 'src/python/widget' does not exist on disk in the workspace, so the address 'src/python/widget' cannot be resolved.
b
@hundreds-father-404 Docs > Reference > Targets > Files > Sources doesn't mention
**
*or recursive globbing. It's not explicit either about what the role of the `*`* operator is. It's taken for granted that it's globbing. Also, that's a deep path to travel for a newcomer. I think it would make sense for them to encounter it in the Using Pants section or even possibly somewhere in the Introduction section.