While waiting for Benjy's talk, I was playing arou...
# general
j
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
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
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
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
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
Thanks Raúl! Sorry for the confusing error message
j
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
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
This would be maybe less confusing in the config file, but as a flag it's pretty subtle...
👍 1