Skip to content

Commit

Permalink
remove dependency on sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gotmax23 committed Dec 1, 2023
1 parent 853433f commit 5f81353
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
6 changes: 6 additions & 0 deletions changelogs/fragments/119-nosh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
removed_features:
- "Remove dependency on ``sh``
(https://github.com/ansible-community/antsibull-core/pull/119)."
- "``venv`` - remove ``get_command()`` method from ``VenvRunner`` and ``FakeVenvRunner``
(https://github.com/ansible-community/antsibull-core/pull/119)."
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ dependencies = [
"pydantic >= 1.0.0, < 2.0.0",
"PyYAML",
"semantic_version",
# sh v2 has breaking changes.
# https://github.com/ansible-community/antsibull-core/issues/34
"sh >= 1.0.0, < 2.0.0",
# 0.5.0 introduces dict_config
"twiggy >= 0.5.0",
]
Expand Down
33 changes: 1 addition & 32 deletions src/antsibull_core/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from collections.abc import Sequence
from typing import TYPE_CHECKING, NoReturn

import sh # type: ignore[import]

from antsibull_core import subprocess_util

if TYPE_CHECKING:
Expand All @@ -41,10 +39,9 @@ class VenvRunner:
"""
Makes running a command in a venv easy.
Combines venv functionality with sh.
Combines venv functionality with ``antsibull_core.subprocess_util``.
.. seealso::
* `sh <https://amoffat.github.io/sh/>`_
* :python:mod:`venv`
"""

Expand All @@ -71,19 +68,6 @@ def __init__(self, name: str, top_dir: StrPath) -> None:

self.log_run(["pip", "install", "--upgrade", "pip"])

def get_command(self, executable_name) -> sh.Command:
"""
Return an :sh:obj:`sh.Command` for the given program installed within the venv.
:arg executable_name: Program to return a command for.
:returns: An :obj:`sh.Command` that will invoke the program.
.. deprecated:: 2.0.0
This method is deprecated in favor of :method:`asnyc_log_run` and
:method:`log_run`. It will be removed in antsibull_core 3.0.0.
"""
return sh.Command(os.path.join(self.venv_dir, "bin", executable_name))

def install_package(self, package_name: str) -> subprocess.CompletedProcess:
"""
Install a python package into the venv.
Expand Down Expand Up @@ -161,7 +145,6 @@ class FakeVenvRunner:
Simply runs commands.
.. seealso::
* `sh <https://amoffat.github.io/sh/>`_
* :python:mod:`venv`
"""

Expand Down Expand Up @@ -220,20 +203,6 @@ def log_run(
)
)

@staticmethod
def get_command(executable_name) -> sh.Command:
"""
Return an :sh:obj:`sh.Command` for the given program installed within the venv.
:arg executable_name: Program to return a command for.
:returns: An :obj:`sh.Command` that will invoke the program.
.. deprecated:: 2.0.0
This function is deprecated in favor of :method:`asnyc_log_run` and
:method:`log_run`. It will be removed in antsibull_core 3.0.0.
"""
return sh.Command(executable_name)

@staticmethod
def install_package(package_name: str) -> NoReturn:
"""
Expand Down

0 comments on commit 5f81353

Please sign in to comment.