Skip to content

Commit

Permalink
improve 'which' check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Mar 5, 2024
1 parent 8b42cb4 commit 1001e40
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions airbyte/_factories/connector_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ def get_source(
# Assume this is a path
local_executable = Path(local_executable).absolute()
else:
if sys.platform == "win32":
which_executable: str | None = None
which_executable = shutil.which(local_executable)
if not which_executable and sys.platform == "win32":
# Try with the .exe extension
local_executable = f"{local_executable}.exe"
which_executable = shutil.which(local_executable)

which_executable = shutil.which(local_executable)
if which_executable is None:
raise exc.AirbyteConnectorExecutableNotFoundError(
connector_name=name,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_duckdb_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def duckdb_cache() -> Generator[DuckDBCache, None, None]:

def test_which_source_faker() -> None:
"""Test that source-faker is available on PATH."""
assert shutil.which("source-faker") is not None, \
assert shutil.which("source-faker") or shutil.which("source-faker.exe"), \
f"Can't find source-faker on PATH: {os.environ['PATH']}"


Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_source_faker_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def all_cache_types(

def test_which_source_faker() -> None:
"""Test that source-faker is available on PATH."""
assert shutil.which("source-faker") is not None, \
assert shutil.which("source-faker") or shutil.which("source-faker.exe"), \
f"Can't find source-faker on PATH: {os.environ['PATH']}"


Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_source_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def test_install_uninstall():
assert not os.path.exists(install_root / ".venv-source-test")

# use which to check if the executable is available
assert shutil.which("source-test") is None
assert not shutil.which("source-test") and not shutil.which("source-test.exe")

# assert that the connector is not available
with pytest.raises(Exception):
Expand Down

0 comments on commit 1001e40

Please sign in to comment.