Skip to content

Ensure packaged artefacts are fully replaced in dist/#18930

Merged
huonw merged 3 commits intopantsbuild:mainfrom
huonw:bugfix/18849-17758-package-overwrite
May 8, 2023
Merged

Ensure packaged artefacts are fully replaced in dist/#18930
huonw merged 3 commits intopantsbuild:mainfrom
huonw:bugfix/18849-17758-package-overwrite

Conversation

@huonw
Copy link
Copy Markdown
Contributor

@huonw huonw commented May 7, 2023

This patch has the package goal clear out the artefact(s) it is about to write to dist/, if they already exists.

For instance, if running pants package path/to:target on a pex_binary (outputting path.to/target.pex), pants will now first remove anything that's already at dist/path.to/target.pex before writing the new output.

This resolves two problems:

  • if there's existing contents of a different kind (e.g. a directory in dist/ and writing a file), the package call would explode. For instance, switching a target like pex_binary(..., format="zipapp") (file) to pex_binary(..., format="packed") (directory).
  • if the package output is directory, stale files already in that location in dist/ would remain. For instance, a pex_binary(..., format="packed") where a file was removed.

This fixes #17758 and fixes #18849, respectively.

This only fixes package, not any other goals that also write to fixed paths (like export and export-codegen). In #18871, I start on export-codegen, but it's a bit fiddlier (requires propagating "this is the artefact" paths around) and it's best to land the infrastructure in this PR first. I'll file follow-up issues covering them specifically.

Commits are individually reviewable.

@huonw huonw added the category:bugfix Bug fixes for released features label May 7, 2023
@huonw huonw force-pushed the bugfix/18849-17758-package-overwrite branch from 43558d2 to 1eb18a2 Compare May 7, 2023 22:54
Copy link
Copy Markdown
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@huonw huonw merged commit a24a59e into pantsbuild:main May 8, 2023
@huonw huonw deleted the bugfix/18849-17758-package-overwrite branch May 8, 2023 21:48
@huonw
Copy link
Copy Markdown
Contributor Author

huonw commented May 8, 2023

I'll file follow-up issues covering them specifically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:bugfix Bug fixes for released features

Projects

None yet

4 participants