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

ambitious-actor-36781

05/09/2021, 11:36 AM
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

happy-kitchen-89482

05/09/2021, 2:39 PM
I think you want
./pants count-loc '**'
'*'
globs over the files in the cwd,
'**'
globs over everything underneath it at any level.
a

ambitious-actor-36781

05/09/2021, 2:45 PM
ah
h

happy-kitchen-89482

05/09/2021, 2:46 PM
Sorry if that wasn't clear in the docs.
a

ambitious-actor-36781

05/09/2021, 3:02 PM
🎉 got something testing, and wheeling something.
h

happy-kitchen-89482

05/09/2021, 4:21 PM
Excellent!
Let us know here if you hit any issues.
b

busy-vase-39202

05/09/2021, 10:29 PM
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

happy-kitchen-89482

05/10/2021, 2:00 AM
I feel like it has to be there somewhere? Weird as hell if not.
b

busy-vase-39202

05/10/2021, 2:27 AM
Could well be. It might just be something that needs to be more findable by search. See what you can turn up.
h

hundreds-father-404

05/10/2021, 5:06 AM
Should be the "Sources" section of Targets page
a

ambitious-actor-36781

05/10/2021, 8:17 AM
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

busy-vase-39202

05/10/2021, 2:37 PM
@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.
5 Views