Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace distutils.spawn with shutil.which #1146

Merged
merged 4 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ sphinx-rtd-theme = "^2"
autodocsumm = "^0.2"
docutils = "^0.20"
jinja2 = "<3.2.0"
# setuptools is not needed for building the docs in RTD,
# but it is needed for running the doctests as an
# undeclared dependency of m2r2.
# https://github.com/CrossNox/m2r2/issues/63
setuptools = "^69"


Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/api/auth_methods/test_ldap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import distutils.spawn
import shutil
import logging
from unittest import TestCase, SkipTest

Expand All @@ -17,7 +17,7 @@ class TestLdap(HvacIntegrationTestCase, TestCase):
@classmethod
def setUpClass(cls):
# The mock LDAP server requires Java runtime
if not distutils.spawn.find_executable("java"):
if not shutil.which("java"):
raise SkipTest("The mock LDAP server requires Java runtime")

try:
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/hvac_integration_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from tests.utils import get_config_file_path, create_client, is_enterprise
from tests.utils.server_manager import ServerManager
import distutils.spawn
import shutil
from hvac import Client


Expand All @@ -23,7 +23,7 @@ class HvacIntegrationTestCase:
def setUpClass(cls):
"""Use the ServerManager class to launch a vault server process."""
config_paths = [get_config_file_path("vault-tls.hcl")]
if distutils.spawn.find_executable("consul") is None and cls.enable_vault_ha:
if shutil.which("consul") is None and cls.enable_vault_ha:
logging.warning(
"Unable to run Vault in HA mode, consul binary not found in path."
)
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/server_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import hcl
import typing as t

import distutils.spawn
import shutil
from unittest import SkipTest
from tests.utils import (
get_config_file_path,
Expand Down Expand Up @@ -137,7 +137,7 @@ def start_vault(
self, *, consul_config: dict = None, attempt=1, max_attempts=3, delay_s=1
):
"""Launch the vault server process and wait until its online and ready."""
if distutils.spawn.find_executable("vault") is None:
if shutil.which("vault") is None:
raise SkipTest("Vault executable not found")

with PortGetter() as g:
Expand Down Expand Up @@ -225,7 +225,7 @@ def start_vault(
def start_consul(
self,
) -> str:
if distutils.spawn.find_executable("consul") is None:
if shutil.which("consul") is None:
raise SkipTest("Consul executable not found")

with PortGetter() as g:
Expand Down