I have some questions about configuring pants tail...
# general
d
I have some questions about configuring pants tailor. First: We're running an ancient version of pants V1 and I need to keep those build files intact for now. How do I set up tailor to read from/write to a filename other than BUILD? Second: We have a directory full of scripts that are not managed by pants. Tailor is currently failing because some of those scripts behave badly. I have the following in my pants.toml but it doesn't appear to be helping. What am I missing?
Copy code
[tailor]
ignore_paths = ["/scripts"]
ignore_adding_targets = ["/scripts/**"]
h
Hello! You can use these options: ā€¢ https://www.pantsbuild.org/docs/reference-tailor#section-build-file-name ā€¢ https://www.pantsbuild.org/docs/reference-global#section-build-patterns Re ignores, it should be something like this:
Copy code
[tailor]
ignore_paths = ["scripts/**"]`
ignore_adding_targets
does not work with globs
d
Thanks Eric!
ā¤ļø 1
Still failing šŸ˜ž
Copy code
./v2pants tailor --check                                                                     āœ˜ 130 PantsPrototype āœ­ āœš āœ±
12:52:04.52 [ERROR] 1 Exception encountered:

  Exception: While expanding link "scripts/python/query/synonyms/csv_unicode.py": Globs may not traverse outside of the buildroot: "scripts/python/query/synonyms/../../../../../scripts/search/csv_unicode.py"
That is with
Copy code
[GLOBAL]
pants_version = "2.9.0rc2"

build_patterns = [
  "BUILD.V2",
]

build_ignore = [
    "scripts/**",
]

backend_packages = [
  "pants.backend.python"
]

[source]
root_patterns = [
  '/src/python',
  '/test/python',
]

[tailor]
ignore_paths = ["scripts"]
build_file_name = ["BUILD.V2"]
h
BTW I wouldn't call it
BUILD.V2
because v1 (IIRC) reads BUILD.* by default. So I would go with
BUILD2
or something
šŸ‘ 2
d
Oh! I think I fixed it:
Copy code
pants_ignore = [
    "scripts/**",
]
šŸ‘ 1
Good tip!
h
Oh cool! Yeah, I guess you want Pants itself to ignore that misbehaving dir, not just tailor
symlinks are... trouble
d
Copy code
./v2pants tailor --check                                                                       āœ˜ 1 PantsPrototype āœ­ āœš āœ±
12:58:46.47 [ERROR] 1 Exception encountered:

  ValueError: The option `[tailor].build_file_name` is set to `["BUILD2"]`, which is not compatible with `[GLOBAL].build_patterns`: ['BUILD2']. This means that generated BUILD files would be ignored.

To fix, please update the options so that they are compatible.
New error
Symlinks can be hell šŸ™‚
Those two names do match. I copied and pasted to make sure.
If I run with the --tailor-build-file-name flag it seems to work.
Copy code
./v2pants tailor --tailor-build-file-name="BUILD2" --check                                     āœ˜ 1 PantsPrototype āœ­ āœš āœ±
13:09:27.51 [ERROR] 1 Exception encountered:

  NoSourceRootError: No source root found for `build-support/docker/docker_service_entrypoint.py`. See <https://www.pantsbuild.org/v2.9/docs/source-roots> for how to define source roots.
I have succesfully run tailor (using the build-file-name flag) but am now seeing these errors:
Copy code
MappingError: Failed to parse ./3rdparty/python/BUILD2:
__call__() got an unexpected keyword argument 'name'
The build file contents are:
Copy code
python_requirements(
    name="requirements.txt",
)
which look normal to me?
h
Ah that is a bug. What Pants version are you using? We fixed it recently. Workaround is to delete the
name=
part
d
šŸ‘
I'm on 2.9.0rc2
h
2.9.0 was released recently with some bug fixes like this
d
The speed difference is already hugely noticeable over V1. tailor created all those build files in seconds, vs running buildgen and having the build graph take 10-15 minutes to get warmed up.
šŸ™Œ 1
h
I think the error above is because you set
[tailor].build_file_name
to a list and not a string?
šŸ‘ 1
d
ooo
Yep! That fixed it!
Is there a way to set a default 3rdparty requirements? We have several and it would be nice not to have to set it in every build file.
eg:
Copy code
The target src/python/fsluigi/task/visitdata/third_party/matched_visits.py imports `<http://dateutil.tz|dateutil.tz>`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['3rdparty/python:python-dateutil', 'build-support/foursquare/lambda/aws-merge-pipeline:python-dateutil', 'src/python/fsluigi/task/normalization_eval:python-dateutil'].
h
There will be, in the works! Here's how it will work https://github.com/pantsbuild/pants/issues/13621#issuecomment-992978245
šŸ‘ 1