@@ -318,7 +318,7 @@ def __init__(self, *args: t.Any, tmux_bin: str | None = None) -> None:
318318 )
319319
320320
321- def get_version () -> LooseVersion :
321+ def get_version (tmux_bin : str | None = None ) -> LooseVersion :
322322 """Return tmux version.
323323
324324 If tmux is built from git master, the version returned will be the latest
@@ -327,12 +327,19 @@ def get_version() -> LooseVersion:
327327 If using OpenBSD's base system tmux, the version will have ``-openbsd``
328328 appended to the latest version, e.g. ``2.4-openbsd``.
329329
330+ Parameters
331+ ----------
332+ tmux_bin : str, optional
333+ Path to tmux binary. If *None*, uses the system tmux from
334+ :func:`shutil.which`.
335+
330336 Returns
331337 -------
332338 :class:`distutils.version.LooseVersion`
333- tmux version according to :func:`shtuil.which`'s tmux
339+ tmux version according to *tmux_bin* if provided, otherwise the
340+ system tmux from :func:`shutil.which`
334341 """
335- proc = tmux_cmd ("-V" )
342+ proc = tmux_cmd ("-V" , tmux_bin = tmux_bin )
336343 if proc .stderr :
337344 if proc .stderr [0 ] == "tmux: unknown option -- V" :
338345 if sys .platform .startswith ("openbsd" ): # openbsd has no tmux -V
@@ -357,93 +364,105 @@ def get_version() -> LooseVersion:
357364 return LooseVersion (version )
358365
359366
360- def has_version (version : str ) -> bool :
367+ def has_version (version : str , tmux_bin : str | None = None ) -> bool :
361368 """Return True if tmux version installed.
362369
363370 Parameters
364371 ----------
365372 version : str
366373 version number, e.g. '3.2a'
374+ tmux_bin : str, optional
375+ Path to tmux binary. If *None*, uses the system tmux.
367376
368377 Returns
369378 -------
370379 bool
371380 True if version matches
372381 """
373- return get_version () == LooseVersion (version )
382+ return get_version (tmux_bin = tmux_bin ) == LooseVersion (version )
374383
375384
376- def has_gt_version (min_version : str ) -> bool :
385+ def has_gt_version (min_version : str , tmux_bin : str | None = None ) -> bool :
377386 """Return True if tmux version greater than minimum.
378387
379388 Parameters
380389 ----------
381390 min_version : str
382391 tmux version, e.g. '3.2a'
392+ tmux_bin : str, optional
393+ Path to tmux binary. If *None*, uses the system tmux.
383394
384395 Returns
385396 -------
386397 bool
387398 True if version above min_version
388399 """
389- return get_version () > LooseVersion (min_version )
400+ return get_version (tmux_bin = tmux_bin ) > LooseVersion (min_version )
390401
391402
392- def has_gte_version (min_version : str ) -> bool :
403+ def has_gte_version (min_version : str , tmux_bin : str | None = None ) -> bool :
393404 """Return True if tmux version greater or equal to minimum.
394405
395406 Parameters
396407 ----------
397408 min_version : str
398409 tmux version, e.g. '3.2a'
410+ tmux_bin : str, optional
411+ Path to tmux binary. If *None*, uses the system tmux.
399412
400413 Returns
401414 -------
402415 bool
403416 True if version above or equal to min_version
404417 """
405- return get_version () >= LooseVersion (min_version )
418+ return get_version (tmux_bin = tmux_bin ) >= LooseVersion (min_version )
406419
407420
408- def has_lte_version (max_version : str ) -> bool :
421+ def has_lte_version (max_version : str , tmux_bin : str | None = None ) -> bool :
409422 """Return True if tmux version less or equal to minimum.
410423
411424 Parameters
412425 ----------
413426 max_version : str
414427 tmux version, e.g. '3.2a'
428+ tmux_bin : str, optional
429+ Path to tmux binary. If *None*, uses the system tmux.
415430
416431 Returns
417432 -------
418433 bool
419434 True if version below or equal to max_version
420435 """
421- return get_version () <= LooseVersion (max_version )
436+ return get_version (tmux_bin = tmux_bin ) <= LooseVersion (max_version )
422437
423438
424- def has_lt_version (max_version : str ) -> bool :
439+ def has_lt_version (max_version : str , tmux_bin : str | None = None ) -> bool :
425440 """Return True if tmux version less than minimum.
426441
427442 Parameters
428443 ----------
429444 max_version : str
430445 tmux version, e.g. '3.2a'
446+ tmux_bin : str, optional
447+ Path to tmux binary. If *None*, uses the system tmux.
431448
432449 Returns
433450 -------
434451 bool
435452 True if version below max_version
436453 """
437- return get_version () < LooseVersion (max_version )
454+ return get_version (tmux_bin = tmux_bin ) < LooseVersion (max_version )
438455
439456
440- def has_minimum_version (raises : bool = True ) -> bool :
457+ def has_minimum_version (raises : bool = True , tmux_bin : str | None = None ) -> bool :
441458 """Return True if tmux meets version requirement. Version >= 3.2a.
442459
443460 Parameters
444461 ----------
445462 raises : bool
446463 raise exception if below minimum version requirement
464+ tmux_bin : str, optional
465+ Path to tmux binary. If *None*, uses the system tmux.
447466
448467 Returns
449468 -------
@@ -467,12 +486,12 @@ def has_minimum_version(raises: bool = True) -> bool:
467486 Versions will now remove trailing letters per
468487 `Issue 55 <https://github.com/tmux-python/tmuxp/issues/55>`_.
469488 """
470- if get_version () < LooseVersion (TMUX_MIN_VERSION ):
489+ if get_version (tmux_bin = tmux_bin ) < LooseVersion (TMUX_MIN_VERSION ):
471490 if raises :
472491 msg = (
473492 f"libtmux only supports tmux { TMUX_MIN_VERSION } and greater. This "
474- f"system has { get_version ()} installed. Upgrade your tmux to use "
475- "libtmux, or use libtmux v0.48.x for older tmux versions."
493+ f"system has { get_version (tmux_bin = tmux_bin )} installed. Upgrade your "
494+ "tmux to use libtmux, or use libtmux v0.48.x for older tmux versions."
476495 )
477496 raise exc .VersionTooLow (msg )
478497 return False
0 commit comments