https://pantsbuild.org/ logo
j

jolly-midnight-72759

05/14/2020, 3:20 AM
While waiting for Benjy's talk, I was playing around with upgrading our 1.18.0 repo to 1.28.0rc1. I am running into a problem following the docs around
--source-source-roots
option. In our old
pants.ini
file the section is defined as a dictionary like so:
Copy code
[source]
source_roots: {
    "3rdparty/go": (u"go_remote",),
    "contrib/go/examples/3rdparty/go": (u"go_remote",),
    "app1": (u"python",),
    "app2": (u"python",),
    }
When I translate this to TOML:
Copy code
[source]
source_roots = """{
    "3rdparty/go": "(u'go_remote',)",
    "contrib/go/examples/3rdparty/go": "(u'go_remote',)",
    "app1": "(u'python',)",
    "app2": "(u'python',)",
    }"""
I get the following error
Copy code
DeprecationWarning: DEPRECATED: option 'source_roots' in scope 'source' will be removed in version 1.30.0.dev0.
  Use --roots instead.
If I change
source_roots
to
roots
I get this error
Invalid option 'roots' under [source] in /Users/raul/dev/cb/chartbeat/pants.toml
. When I go to https://pants.readme.io/docs/source-roots it only talks about
root_patterns
. So I am confused about what to change the
source_roots
to. And I should note, that works because I can see my settings when I run
./pants --no-verify-config help-advanced source
h

hundreds-father-404

05/14/2020, 3:23 AM
Try root_patterns. I think that deprecation message has a stale message. It’s root_patterns, not roots.
Also see https://github.com/pantsbuild/pants/blob/master/pants.toml and search for “[source]” for an example
j

jolly-midnight-72759

05/14/2020, 3:52 AM
That works, but does not produce the same results as v1.18.0:
Copy code
--source-source-roots=<map>
      default: { '3rdparty/go': ('go_remote',), 'contrib/go/examples/3rdparty/go':
        ('go_remote',), 'sharknado3': ('python',), 'sharknado': ('python',),
        'pycb/cb_conf': ('python',), 'pycb/cb_path_class': ('python',),
        'pycb/cb_check_opentsdb': ('python',), 'pycb/cb_mercury': ('python',) }
      A map of source roots for source code to list of languages. Useful when you want
      to enumerate fixed source roots explicitly, instead of relying on patterns.
      DEPRECATED. will be removed in version: 1.30.0.dev0.
      Use --roots instead.
Copy code
--source-source-roots=<map>
      default: { 'src/go/src': ('go',), 'src/main/go/src': ('go',) }
      A map of source roots for source code to list of languages. Useful when you want
      to enumerate fixed source roots explicitly, instead of relying on patterns.
      DEPRECATED. will be removed in version: 1.30.0.dev0.
      Use --roots instead.
h

happy-kitchen-89482

05/14/2020, 4:00 AM
Yeah, that message is broken
it should be
root_patterns
and it should just be a list of source roots without all the language details.
I'll fix that error message to be less confusing
Thanks for the feedback!
j

jolly-midnight-72759

05/14/2020, 4:01 AM
Cool.
I was grepping through the code to find the message, but
source_roots
get's a lot of hits. 🙂
src/python/pants/source/source_root.py
🚀
But only
source_roots
produces the same output as 1.18.0:
Copy code
--source-source-roots=<map>
      default: { '3rdparty/go': (u'go_remote',), 'contrib/go/examples/3rdparty/go': yada yada
When I use
root_patterns
,
./pants --no-verify-config help-advanced source
does not show the right thing.
I'll make an issue, because at the very least it is a CLI UI and documentation issue.
h

hundreds-father-404

05/14/2020, 4:54 AM
Thanks Raúl! Sorry for the confusing error message
j

jolly-midnight-72759

05/14/2020, 4:58 AM
It's
rc0
no apology necessary.
But I think I am at a deadend because when I go to
src/python/pants/source/source_root.py
I see that it too is depreciated.
Copy code
register(
            "--source-root-patterns",
            metavar="<list>",
            type=list,
            fingerprint=True,
            default=cls._DEFAULT_SOURCE_ROOT_PATTERNS,
            advanced=True,
            removal_version="1.30.0.dev0",
            removal_hint="Use --roots instead.",
            help=pattern_help_fmt.format("source"),
        )
I don't know what the desired 1.30.0 UI is so I am not sure what to change it to. 🙂
h

hundreds-father-404

05/14/2020, 5:20 AM
Ah, I think I see now. That’s confusing indeed. So, the preferred option is
root_patterns
in the
source
scope, aka
--source-root-patterns
. It looks like that very similar option is called
--source-source-root-patterns
☝️ 1
h

happy-kitchen-89482

05/14/2020, 5:46 AM
This would be maybe less confusing in the config file, but as a flag it's pretty subtle...
👍 1
5 Views