Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Keep tagged Python environments unselected in Build Artifacts
Țugui Dragoș929d7a992c1c
diff --git a/AGENTS.md b/AGENTS.mdindex d62eb756..4a2216a0 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -109,8 +109,9 @@ checked by hand. If a change makes one of them fail, the rule is right and the cfinish reading, is shown with its reason and moves only when the user selects it. `peel uninstall`, `peel orphans--remove`, and `peel projects --remove` pass it by, and Select All takes it only once the user has answered thequestion that counts what Peel doesn't recommend (`SelectableRows.notRecommendedAdded`). A repository can still be- selected in two places, since its tool clones it again: inside a folder its tool tags as a cache- (`CACHEDIR.TAG`), such as Swift Package Manager's `.build`, and inside a cache on the Developer page.+ selected in two places, since its tool clones it again: inside Swift Package Manager's `.build`, which it tags as a+ cache (`CACHEDIR.TAG`), and inside a cache on the Developer page; a tag alone never makes a repository selectable+ (`Definition.remakesItsClones`).- **The user's exclusions reach every scanner**, so an excluded item never appears in the first place.- **What a file says about itself is anyone's word.** Any program can write a launch job, an app's Info.plist, or oneof Peel's own records, so a program path that holds a NUL names no program, an app's name goes into a pattern onlydiff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex 21bd0baa..00deb557 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -101,6 +101,9 @@ public enum ProjectArtifacts {/// What the folder holds that only its tool writes, for a kind no project file stands beside.var proof: Proof?var keepsItsSetup = false+ var isFoundOnlyByItsTag = false+ /// The tool clones its dependencies inside and clones them again, so a repository there is not the person's.+ var remakesItsClones = false/// Names ending in `*` are prefixes, and a path such as `tmp/cache` names a folder inside another.func candidates(among names: Set<String>, in folder: URL) -> [String] {@@ -203,7 +206,7 @@ public enum ProjectArtifacts {),Definition(name: ".build", markers: ["Package.swift"], tool: "Swift Package Manager", isGeneric: false,- source: "Xcode 27: swift build --help (--scratch-path, default .build)"+ source: "Xcode 27: swift build --help (--scratch-path, default .build)", remakesItsClones: true),Definition(name: "Pods", markers: ["Podfile"], tool: "CocoaPods", isGeneric: false,@@ -519,6 +522,11 @@ public enum ProjectArtifacts {name: "env", markers: pythonProjectFiles, tool: "Python", isGeneric: true, isEnvironment: true,source: "https://docs.python.org/3/library/venv.html", proof: .holds("pyvenv.cfg")),+ // uv and virtualenv tag every environment they make as a cache, whatever it is called.+ Definition(+ name: "*", markers: [], tool: "Python", isGeneric: false, isEnvironment: true,+ source: "https://peps.python.org/pep-0405/", proof: .holds("pyvenv.cfg"), isFoundOnlyByItsTag: true+ ),Definition(name: "__pycache__", markers: [], tool: "Python", isGeneric: false,source: "https://docs.python.org/3/tutorial/modules.html", proof: .holdsOnlyFilesEnding(".pyc")@@ -1049,8 +1057,7 @@ public enum ProjectArtifacts {lastActivityIsCertain: activity.isCertain,hasGenericName: artifact.found.definition?.isGeneric ?? false,isEnvironment: artifact.found.definition?.isEnvironment ?? false,- // A tool that tags its folder as a cache makes everything in it again, its own clones included.- heldBack: (heldBack == .holdsRepository && artifact.found.isTaggedAsACache ? nil : heldBack)+ heldBack: (heldBack == .holdsRepository && artifact.found.remakesItsClones ? nil : heldBack)?? (artifact.found.definition?.keepsItsSetup == true ? .keepsItsSetup : nil))}@@ -1100,6 +1107,8 @@ public enum ProjectArtifacts {let definition: Definition?let isTaggedAsACache: Boolvar isBesideItsToolsFile = false++ var remakesItsClones: Bool { isTaggedAsACache && definition?.remakesItsClones == true }}/// Lists `folder` and finds the artifacts in it, or nil when it cannot be listed.@@ -1110,7 +1119,7 @@ public enum ProjectArtifacts {let names = Set(entries.map(\.lastPathComponent))var artifactNames: Set<String> = []var found: [Found] = []- for definition in definitions {+ for definition in definitions where !definition.isFoundOnlyByItsTag {let candidates = definition.candidates(among: names, in: folder)guard !candidates.isEmpty, definition.hasMarker(besides: names, in: folder) else { continue }for name in candidates {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 5d52a19e..f686cfdb 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -1024,6 +1024,31 @@ struct ProjectArtifactsTests {#expect(found.filter(\.isRecommended).map(\.project.lastPathComponent) == ["tool"])}+ @Test func aTaggedPythonEnvironmentIsAnEnvironmentWhateverItIsCalledAndKeepsItsClones() async throws {+ let directory = try TemporaryDirectory()+ let tag = Data("Signature: 8a477f597d28d172789f06886806bc55\n# created by virtualenv automatically\n".utf8)+ for (project, file, environment) in [+ ("scripts", "main.py", ".venv"), ("api", "requirements.txt", ".env"), ("app", "pyproject.toml", ".venv"),+ ] {+ try directory.file("Projects/\(project)/\(file)", bytes: 16)+ try directory.file("Projects/\(project)/\(environment)/CACHEDIR.TAG", contents: tag)+ try directory.file("Projects/\(project)/\(environment)/pyvenv.cfg", bytes: 16)+ }+ try directory.file("Projects/app/.venv/src/mylib/.git/HEAD", bytes: 16)+ try age(directory.url, days: 60)++ let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Projects")]).artifacts++ let rows = Dictionary(uniqueKeysWithValues: found.map { ("\($0.project.lastPathComponent)/\($0.name)", $0) })+ for row in ["scripts/.venv", "api/.env"] {+ #expect(rows[row]?.isEnvironment == true, "\(row)")+ #expect(rows[row]?.tool == "Python", "\(row)")+ #expect(rows[row]?.isRecommended == false, "\(row)")+ }+ #expect(rows["app/.venv"]?.heldBack == .holdsRepository)+ #expect(ProjectArtifacts.BackupMarks(found, excluded: [], excludedFromAbove: []).markable.isEmpty)+ }+@Test func aFolderGitTracksIsListedAndNeverSelected() async throws {let directory = try TemporaryDirectory()let git = try await GitFixture(home: directory.url.appending(path: "home"))@@ -1271,6 +1296,11 @@ struct ProjectArtifactsTests {try directory.file("\(artifact)/\(String(repeating: "a", count: characters))/content")case nil: try directory.file("\(artifact)/content")}+ if definition.isFoundOnlyByItsTag {+ try directory.file(+ "\(artifact)/CACHEDIR.TAG", contents: Data("Signature: 8a477f597d28d172789f06886806bc55\n".utf8)+ )+ }expected[artifact] = definition.tool}diff --git a/SAFETY.md b/SAFETY.mdindex 4bbef9a7..c5b3b38a 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -408,13 +408,13 @@ shown with their size as "Unknown", never as zero, in every tool and in Historyread quickly may be exactly the one with work inside, and nothing is selected for you without saying how much it is. Atotal that leaves such a folder out reads "Over" what is known.-A repository can still be selected in two places, since its tool makes everything there again. One is a folder its-tool tags as a cache (`CACHEDIR.TAG`): Swift Package Manager tags `.build`, where it clones a package's-dependencies, and `swift package reset` deletes that folder whole, so Build Artifacts can still select it. The other-is a cache on the Developer page, a folder its tool's documentation or source shows to be a cache, such as the-packages Xcode checks out into DerivedData or the clones Cargo and Swift Package Manager keep, which the tool clones-again when it needs them. Of Carthage's folder in a project, only `Carthage/Build`, which `carthage build` makes, is-offered: its checkouts, which people commit in, carry no such tag and are never listed.+A repository can still be selected in two places, since its tool makes everything there again. One is Swift Package+Manager's `.build`, which it tags as a cache (`CACHEDIR.TAG`) and where it clones a package's dependencies: `swift+package reset` deletes that folder whole, so Build Artifacts can still select it. A tag alone never makes a repository+selectable: anyone can write one. The other is a cache on the Developer page, a folder its tool's documentation or+source shows to be a cache, such as the packages Xcode checks out into DerivedData or the clones Cargo and Swift Package+Manager keep, which the tool clones again when it needs them. Of Carthage's folder in a project, only `Carthage/Build`,+which `carthage build` makes, is offered: its checkouts, which people commit in, carry no such tag and are never listed.Build Artifacts recommends what a build or a package manager makes again from the project's own files, such as`DerivedData`, `.build`, and `.next`, once Peel can tell that nothing in the project has changed for a week. That@@ -423,20 +423,21 @@ includes `node_modules` and `Pods`, which `npm install` and `pod install` put bais part of the project, so it is listed and never selected, and so is one in a repository whose list of tracked filesPeel can't read. Peel reads that list from Git's own index, as Git documents it, and never runs Git in a project.Installed packages are listed and never selected, since packages are often installed into them by hand: a Python-environment (`.venv`, `venv`, `env`, PDM's `__pypackages__`, tox's `.tox`, Nox's `.nox`), Composer's `vendor`, Mix's-`deps`, Shards' `lib`, and Elm's `elm-stuff`. So is Terraform's `.terraform`, which keeps the workspace you chose, and-xwin's `.xwin-cache`, the Windows SDK a Rust project builds against, which only `xwin splat` with your own options puts-back. Pixi's `.pixi/envs` can be suggested: Pixi makes it again from `pixi.lock` and never lets it be edited by hand. A-Meson build folder, whatever its name and wherever Peel finds it, is never selected: it also keeps the options its build-was set up with, which Meson's own `--wipe` carries over and nothing else in the project holds. Neither is Bloop's-`.bloop`, which keeps the workspace settings written there. A folder whose name says nothing on its own, such as-`target` or `build`, is listed and never selected either. Of a Godot project's `.godot`, only the caches Godot makes-again are offered, `imported` and `shader_cache`: the folder also holds the export passwords and keys-(`export_credentials.cfg`), which exist nowhere else. Nx's `.nx` is offered only when it holds nothing but the cache and-the database beside it, which `nx reset` removes together, since a team can keep its release plans there. Build-Artifacts never searches a hidden folder, a Library, or a folder a tool fills, such as `node_modules`: apps and tools-keep there what they install, as an editor keeps each extension's `package.json` beside the `node_modules` it runs with.-A folder chosen to search that is one of those, or sits inside one, is refused with the reason.+environment (`.venv`, `venv`, `env`, PDM's `__pypackages__`, tox's `.tox`, Nox's `.nox`, and any folder tagged as a+cache that holds the `pyvenv.cfg` every environment has), Composer's `vendor`, Mix's `deps`, Shards' `lib`, and Elm's+`elm-stuff`. So is Terraform's `.terraform`, which keeps the workspace you chose, and xwin's `.xwin-cache`, the Windows+SDK a Rust project builds against, which only `xwin splat` with your own options puts back. Pixi's `.pixi/envs` can be+suggested: Pixi makes it again from `pixi.lock` and never lets it be edited by hand. A Meson build folder, whatever its+name and wherever Peel finds it, is never selected: it also keeps the options its build was set up with, which Meson's+own `--wipe` carries over and nothing else in the project holds. Neither is Bloop's `.bloop`, which keeps the workspace+settings written there. A folder whose name says nothing on its own, such as `target` or `build`, is listed and never+selected either. Of a Godot project's `.godot`, only the caches Godot makes again are offered, `imported` and+`shader_cache`: the folder also holds the export passwords and keys (`export_credentials.cfg`), which exist nowhere+else. Nx's `.nx` is offered only when it holds nothing but the cache and the database beside it, which `nx reset`+removes together, since a team can keep its release plans there. Build Artifacts never searches a hidden folder, a+Library, or a folder a tool fills, such as `node_modules`: apps and tools keep there what they install, as an editor+keeps each extension's `package.json` beside the `node_modules` it runs with. A folder chosen to search that is one of+those, or sits inside one, is refused with the reason.Developer, Build Artifacts, Space, and Installers and Backups select nothing for you: opening a page selects nothing,and Select Recommended selects what Peel recommends there.