diff --git a/CHANGELOG.md b/CHANGELOG.md index 473484d..14ae46c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed +- `PocketICServer` now looks for the PocketIC binary in the `POCKET_IC_BIN` environment variable, or in the working directory, or on the PATH, in that order of precedence. + + ## 3.1.0 - 2025-04-28 ### Added diff --git a/pocket_ic/pocket_ic_server.py b/pocket_ic/pocket_ic_server.py index 85b37f9..f3b97eb 100644 --- a/pocket_ic/pocket_ic_server.py +++ b/pocket_ic/pocket_ic_server.py @@ -3,6 +3,7 @@ """ import os +import shutil import time import requests from typing import List, Optional @@ -13,8 +14,8 @@ class PocketICServer: """ An object of this class represents a running PocketIC server. During instantiation, a running server is discovered, or a new one is launched from the PocketIC binary, - which is assumed to be in your working directory or specified via the POCKET_IC_BIN - environment variable. + which is assumed to be specified via the POCKET_IC_BIN environment variable, be on your + PATH, or in your working directory, in that order of precedence. All tests within a testsuite should use the same server, so the service discovery mechanism uses the current process id. This means that only the first @@ -29,6 +30,8 @@ def __init__(self) -> None: pid = os.getpid() if "POCKET_IC_BIN" in os.environ: bin_path = os.environ["POCKET_IC_BIN"] + elif shutil.which("pocket-ic") is not None: + bin_path = "pocket-ic" else: bin_path = "./pocket-ic"