Skip to content

Commit

Permalink
Fix package name in pip upgrade instructions (#2625)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored Oct 27, 2022
1 parent 634326b commit 1cd73da
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,28 @@ def parse_ansible_version(stdout: str) -> tuple[str, str | None]:

def in_venv() -> bool:
"""Determine whether Python is running from a venv."""
if hasattr(sys, "real_prefix"):
if hasattr(sys, "real_prefix") or os.environ.get("CONDA_EXE", None) is not None:
return True

pfx = getattr(sys, "base_prefix", sys.prefix)
return pfx != sys.prefix


def guess_install_method() -> str:
"""Guess if pip upgrade command should be used."""
package_name = "ansible-lint"
pip = ""
if in_venv():
_logger.debug("Found virtualenv, assuming `pip3 install` will work.")
pip = f"pip install --upgrade {__package__}"
pip = f"pip install --upgrade {package_name}"
elif __file__.startswith(os.path.expanduser("~/.local/lib")):
_logger.debug(
"Found --user installation, assuming `pip3 install --user` will work."
)
pip = f"pip3 install --user --upgrade {__package__}"
pip = f"pip3 install --user --upgrade {package_name}"

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

0 comments on commit 1cd73da

Please sign in to comment.