cool-easter-32542
04/27/2023, 10:49 PMpex_binary(..., layout="packed") (or layout="loose"). If someone has run pants package :: once to output this target, makes a change that removes files, and then reruns pants package ::, the removed files are left there.
In theory, writing to dist/ should exactly synchronise the contents of a target-that-outputs-directory (removing stale contents). This will need to be done at an appropriate level, e.g. for a packed pex pants package path/to:target, it'll output dist/path.to/target.pex/..., but it should only synchronise dist/path.to/target.pex/, not removing anything from dist/ or dist/path.to/.
This likely applies to other methods of writing to dist/, like export-codegen.
Reproducer:
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.15.0"
backend_packages = ["pants.backend.python"]
[anonymous-telemetry]
enabled = false
EOF
cat > BUILD <<EOF
python_sources(name="sources")
pex_binary(name="pex", layout="packed", dependencies=[":sources"])
EOF
touch a.py b.py
# initial export:
pants package :pex
tree dist
rm b.py
pants package :pex
# BUG: b.py is still in dist/pex.pex/
tree dist
# clear out and start again to validate the expected contents (no b.py)
rm -rf dist
pants package :pex
tree dist
Output:
1. initial export
08:43:37.96 [INFO] Wrote dist/pex.pex
dist
└── pex.pex
├── PEX-INFO
├── __main__.py
├── __pex__
│ └── __init__.py
├── a.py
└── b.py
2 directories, 5 files
2. BUG: b.py is still in dist/pex.pex/
08:43:38.33 [WARN] Unmatched glob from //b.py:sources's `source` field: "b.py"
Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.15/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
08:43:38.33 [INFO] Wrote dist/pex.pex
dist
└── pex.pex
├── PEX-INFO
├── __main__.py
├── __pex__
│ └── __init__.py
├── a.py
└── b.py
2 directories, 5 files
3. clear out and start again ...
08:43:38.74 [INFO] Wrote dist/pex.pex
dist
└── pex.pex
├── PEX-INFO
├── __main__.py
├── __pex__
│ └── __init__.py
└── a.py
2 directories, 4 files
Pants version
2.15.0
OS
macOS
Additional info
Potentially vaguely related: #17758, #18809.
pantsbuild/pantscool-easter-32542
05/08/2023, 9:48 PMcool-easter-32542
05/08/2023, 9:48 PM