Skip to content

Commit 14c7fcc

Browse files
committed
Try to simplify the hunt for brew binary on Linux.
1 parent 70a9d79 commit 14c7fcc

1 file changed

Lines changed: 3 additions & 35 deletions

File tree

meta_package_manager/managers/homebrew.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,12 @@ class Homebrew(PackageManager):
4343
# 2.7.0 is the first release to enforce the use of --cask option.
4444
requirement = "2.7.0"
4545

46+
# Help mpm a little bit in its search for the `brew` binary on Linux.
47+
cli_search_path = ["~/.linuxbrew"]
48+
4649
# Declare this manager as virtual, i.e. not tied to a real CLI.
4750
cli_name = None
4851

49-
@cachedproperty
50-
def cli_path(self):
51-
"""Fully qualified path to the package manager CLI.
52-
53-
Automatically search the location of the CLI in the system. Only checks
54-
if the file exists. Its executability will be assessed later. See the
55-
``self.executable`` method below.
56-
57-
Returns `None` if CLI is not found or is not a file.
58-
59-
..todo:
60-
61-
This is a copy of the parent's ``PackageManager.cli_path()`` method. It was
62-
copy-pasted then slightly tweaked in
63-
https://github.com/kdeldycke/meta-package-manager/pull/188 . Please try to
64-
fix this ugly code duplication.
65-
"""
66-
# Check if the path exist in any of the environment locations.
67-
env_path = ":".join(self.cli_search_path + [os.getenv("PATH")])
68-
cli_path = which(self.cli_name, mode=os.F_OK, path=env_path)
69-
if not cli_path:
70-
logger.debug(f"{self.cli_name} CLI not found.")
71-
return
72-
73-
# Normalize CLI path and check it is a file. Do not follow symlinks.
74-
# Homebrew on linux uses the symlink path to set environment variables.
75-
cli_path = Path.cwd() / Path(cli_path)
76-
logger.debug(f"CLI found at {cli_path}")
77-
78-
if not cli_path.is_file():
79-
logger.warning(f"{cli_path} is not a file.")
80-
return
81-
82-
return cli_path
83-
8452
def get_version(self):
8553
"""Fetch version from ``brew --version`` output.
8654

0 commit comments

Comments
 (0)