Was it a purposeful change in 2.10 to no longer al...
# general
e
Was it a purposeful change in 2.10 to no longer allow targets to be defined with sources outside of where the target is defined?
Previously our
3rdparty/BUILD.pants
contained the following and worked great:
Copy code
python_requirements(
    source="../path/to/legacy/external-requirements.txt",
)
This made it easy to partially migrate our repo to pants without breaking anything legacy.
In 2.10 I am unable to: • Use a relative path to the parent dir (
../
) • Use an absolute path (
/path
or
//path
) • Use a symlink to the legacy path as a source (not recognized as file)
h
fwiw, that's been a thing in 2.9 as well
e
In 2.9 we were able to use
Copy code
python_requirements(
    source="../path/to/legacy/external-requirements.txt",
)
h
huh. I wasn't able to do that with things like
python_sources
.
What's the rationale for putting the requirements not collocated with the requirements file (or above it)?
h
Huh didn't realize the old "context aware object factories" allowed you to do that. That was not intentional The reason this is no longer possible is when you change to the new "target generator" mechanism, that the same bans on
../
now get applied
e
While slightly annoying in my current very specific use case, not allowing
../
seems reasonable. Not allowing
/absolute/paths
seems a bit restrictive, but sure. Why not recognize symlinks though?
h
re absolute path, a BUILD file can only define targets in your current repository. You can't define a target for
/HOME/some_other_project
I'm not certain re symlinks, I think Stu or John might have more context on that
e
re: rationale So in this case we were able to work around it by moving the actual
requirements.txt
file into
3rdparty
, and symlinking to it from the legacy location. Pip has no problem following symlinks. If we were starting from scratch we would not need the requirements file in 2 locations, but we only still only partially on pants and too much brittle tooling references the legacy structure. It's a lot nicer for our 3rdpary deps for pants to be
3rdparty:pandas
@hundreds-father-404 to clarify I mean an absolute path under the repo, not the filesystem.
👍 1
h
ah yeah, targets can only own files in the BUILD file's dir or below it. That is key for how things like
--changed-since
works, so we know which targets to consider and which we can ignore