Skip to content

Commit 1cd73da

Browse files
davedittrichpre-commit-ci[bot]ssbarnea
authored
Fix package name in pip upgrade instructions (#2625)
* Fix package name in pip upgrade instructions * chore: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
1 parent 634326b commit 1cd73da

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/ansiblelint/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,27 +192,28 @@ def parse_ansible_version(stdout: str) -> tuple[str, str | None]:
192192

193193
def in_venv() -> bool:
194194
"""Determine whether Python is running from a venv."""
195-
if hasattr(sys, "real_prefix"):
195+
if hasattr(sys, "real_prefix") or os.environ.get("CONDA_EXE", None) is not None:
196196
return True
197+
197198
pfx = getattr(sys, "base_prefix", sys.prefix)
198199
return pfx != sys.prefix
199200

200201

201202
def guess_install_method() -> str:
202203
"""Guess if pip upgrade command should be used."""
204+
package_name = "ansible-lint"
203205
pip = ""
204206
if in_venv():
205207
_logger.debug("Found virtualenv, assuming `pip3 install` will work.")
206-
pip = f"pip install --upgrade {__package__}"
208+
pip = f"pip install --upgrade {package_name}"
207209
elif __file__.startswith(os.path.expanduser("~/.local/lib")):
208210
_logger.debug(
209211
"Found --user installation, assuming `pip3 install --user` will work."
210212
)
211-
pip = f"pip3 install --user --upgrade {__package__}"
213+
pip = f"pip3 install --user --upgrade {package_name}"
212214

213215
# By default we assume pip is not safe to be used
214216
use_pip = False
215-
package_name = "ansible-lint"
216217
try:
217218
# Use pip to detect if is safe to use it to upgrade the package.
218219
# We do imports here to for performance and reasons, and also in order

0 commit comments

Comments
 (0)