-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ExternalTool exportable #21258
base: main
Are you sure you want to change the base?
Make ExternalTool exportable #21258
Conversation
36cac8a
to
dfe74bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks for taking it on
Do we like --bin
Fine by me!
Is putting all the bins in the same dir what we want
I wonder if we don't, due to two key downsides of putting them all in the same directory:
- this means that a tool that's more than just a single binary (e.g.
README
s, supporting data files) end up piled into thebin/
directory adjacent to all the other binaries - binaries and/or their supporting files can have names that overlap, e.g. hypothetically someone could be using both a
helm
subsystem and migrating to their own fork of the pluginhelm2
or something, and they both might have ahelm
binary. Or just overlapping on supporting files.
As such, I wonder if we want to stick the Pants option scope in the directory hierarchy as a definitely unique disambiguation, e.g. dist/export/bin/helm/helm
or dist/export/helm/bin/helm
.
async def export_external_tool( | ||
req: _ExportExternalToolForResolveRequest, platform: Platform, union_membership: UnionMembership | ||
) -> MaybeExportResult: | ||
exporatbles = ExportableTool.filter_for_subclasses( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exporatbles = ExportableTool.filter_for_subclasses( | |
exportables = ExportableTool.filter_for_subclasses( |
Both of these are valid. There's also a parameter "generate_exe" which points to the actual executable. We could export everything to separate dirs and then symlink the executable itself into a |
Looks like a very sensible solution to me, and |
651638f
to
b908951
Compare
b908951
to
04cafbd
Compare
do we want to make all |
6b1f68d
to
72636b6
Compare
We've just branched for 2.23, so merging this pull request now will come out in 2.24, please move the release notes updates to |
prevents colissions
274a125
to
b25ad88
Compare
ensures consistency if there are collisions
allows using a name users would expect, even if this is different from the tool's downloaded binary name and the tool's full name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is really nice, thanks for working on it
ln_bin = shutil.which("ln") | ||
if not ln_bin: | ||
# I think ln_bin missing won't happen, but the error message otherwise is "No such file or directory (os error 2)" which isn't helpful | ||
raise RuntimeError( | ||
"Could not locate `ln` bin to link exported binaries to the `bin` dir" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine (i.e. I don't think we need to block merging this, but could instead refactor later), but did you consider the option of creating a digest with symlinks in it and including that in the "main" workspace.write_digest(...)
call? Rather than shell out to symlinking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point. I lifted the idea from the python backend's export
implementation, which uses a PostProcessingCommand to symlink the venv in.
It probably makes more sense to collect all the symlinks and write them out, though. I'll see how hard that is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's a lot simpler, thanks for the suggestion! I've kept it as a separate write_digest
to keep the locality of the processing, there's a lot going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the symlinks are absolute symlinks, relative symlinks complained about the symlink not being in the subtree. Should be fine?
Co-authored-by: Huon Wilson <[email protected]>
This MR wires
ExternalTool
s into the export machinery.It exposes them under a separate cli arg
--bin
. Although it uses some of the same machinery as--resolve
, there are several differences that I think support a separate flag (and some separate internal):ExternalTool
s don't have a resolve. They therefore must not show up for generating lockfiles. We have to implement this separation interally, so we should probably surface that.source dist/export/.../activate
)Closes #21251
Bikeshedding:
--bin
(yes)