fix: parse packages with a brew "version" correctly.#1601
fix: parse packages with a brew "version" correctly.#1601morrison12 wants to merge 1 commit intopyinfra-dev:3.xfrom
Conversation
Fizzadar
left a comment
There was a problem hiding this comment.
I'm not sure this is the right fix since brew uses @ for distinct formula (eg python@3.13, python@3.14). I think we'd be better off fixing this on the operation side though I'm unsure how 🤔
The current change works to add a version of, for example, In terms of changing the operation, removing the /1/ (venv) machine user$ pyinfra @local fact brew.BrewPackages 2>&1 | grep python -A 3
"python": [
"3.12.13",
"3.13.13",
"3.14.4"
(venv) machine user$ pyinfra @local brew.packages python@3.10 present=True
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[@local] Connected
--> Preparing operation func...
[@local] Ready: packages
--> Detected changes:
Operation Change Conditional Change
brew.packages (python@3.10, present=True) 1 (@local) -
Detected changes may not include every change pyinfra will execute.
Hidden side effects of operations may alter behaviour of future operations,
this will be shown in the results. The remote state will always be updated
to reflect the state defined by the input operations.
Detected changes displayed above, skip this step with -y
--> Beginning operation run...
--> Starting operation: brew.packages (python@3.10, present=True)
[@local] Success
--> Results:
Operation Hosts Success Error No Change
brew.packages (python@3.10, present=True) 1 1 - -
Grand total 1 1 - -
--> Disconnecting from hosts...
(venv) machine user$ pyinfra @local fact brew.BrewPackages 2>&1 | grep python -A 4
"python": [
"3.10.20",
"3.12.13",
"3.13.13",
"3.14.4"
/2/
(venv) machine user$ pyinfra @local brew.packages python@3.10.20 present=False
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[@local] Connected
--> Preparing operation func...
[@local] Ready: packages
--> Detected changes:
Operation Change Conditional Change
brew.packages (python@3.10.20, present=False) 1 (@local) -
Detected changes may not include every change pyinfra will execute.
Hidden side effects of operations may alter behaviour of future operations,
this will be shown in the results. The remote state will always be updated
to reflect the state defined by the input operations.
Detected changes displayed above, skip this step with -y
--> Beginning operation run...
--> Starting operation: brew.packages (python@3.10.20, present=False)
[@local] Error: No available formula with the name "python@3.10.20". Did you mean python@3.12, python@3.10, python@3.14, python@3.13 or python@3.11?
[@local] Error: executed 0 commands
--> Disconnecting from hosts...
--> pyinfra error: No hosts remaining!
/3/
(venv) machine user$ pyinfra @local brew.packages python@3.10.20 present=False
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[@local] Connected
--> Preparing operation func...
[@local] Ready: packages
--> Detected changes:
Operation Change Conditional Change
brew.packages (python@3.10.20, present=False) - -
Detected changes may not include every change pyinfra will execute.
Hidden side effects of operations may alter behaviour of future operations,
this will be shown in the results. The remote state will always be updated
to reflect the state defined by the input operations.
Detected changes displayed above, skip this step with -y
--> Beginning operation run...
--> Starting operation: brew.packages (python@3.10.20, present=False)
[@local] No changes
--> Results:
Operation Hosts Success Error No Change
brew.packages (python@3.10.20, present=False) 1 - - 1
Grand total 1 - - 1
--> Disconnecting from hosts...
(venv) machine user$ pyinfra @local fact brew.BrewPackages 2>&1 | grep python -A 4
"python@3.10": [
"3.10.20"
],
"python@3.12": [
"3.12.13"
],
"python@3.13": [
"3.13.13"
],
"python@3.14": [
"3.14.4"
], |
brew.BrewPackages(and thusbrew.BrewCasksby inheritance ignores the '@' separator thatbrewuses even though the separator is used bybrew.packages(see /1/). This causes the "versions" of the formulae or cask to be reported as separate formulae or casks instead of multiple versions of a single formula or cask (see /2/) and extraneous install attempts (see Detected changes part of /2/). With the fix applied, there are multiple versions of a single formula or cask and no install attempt (see /3/).3.xat this time) and started with 3.7 despite the version shown at /3/ !?!scripts/dev-test.sh)scripts/dev-lint.sh)/1/
pyinfra/src/pyinfra/operations/brew.py
Lines 93 to 95 in 812a149
/2/
/3/