Skip to content

Commit

Permalink
Assert that the python version meets the required minimum.
Browse files Browse the repository at this point in the history
Update the default deephaven version to 0.36.1
  • Loading branch information
chipkent committed Aug 28, 2024
1 parent d113e0e commit d338575
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion dhib_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import requests

IB_VERSION_DEFAULT="10.19.04"
DH_VERSION_DEFAULT="0.34.1"
DH_VERSION_DEFAULT="0.36.1"
MIN_PY_VERSION="3.10.0"

########################################################################################################################
# Version Numbers
Expand Down Expand Up @@ -197,6 +198,36 @@ def pkg_dependencies(path_or_module: Union[str, Path, ModuleType]) -> Dict[str,
########################################################################################################################


def python_version(python: str) -> tuple[int, ...]:
"""Get the version of Python.
Args:
python: The path to the Python executable.
Returns:
A tuple of integers representing the version of Python.
"""
cmd = f"{python} --version"
logging.warning(f"Getting Python version: {cmd}")
version = os.popen(cmd).read().strip().split(" ")[1]
return version_tuple(version)

def assert_python_version(python: str) -> None:
"""Assert that the version of Python is at least the minimum required version.
Args:
python: The path to the Python executable.
Raises:
ValueError: If the version of Python is less than the minimum required version.
"""
version = python_version(python)
min_version = version_tuple(MIN_PY_VERSION)

if version < min_version:
raise ValueError(f"Python version {version_str(version, True)} is less than the minimum required version {version_str(min_version, True)}.")


class Pyenv:
"""A python environment."""

Expand Down Expand Up @@ -431,6 +462,8 @@ def ib_wheel(

python = Path(python).absolute() if python.startswith("./") else python
logging.warning(f"Using system python: {python}")
assert_python_version(python)

pyenv = Pyenv(python)

ib_wheel = IbWheel(ib_version)
Expand Down Expand Up @@ -463,6 +496,8 @@ def dhib_wheel(

python = Path(python).absolute() if python.startswith("./") else python
logging.warning(f"Using system python: {python}")
assert_python_version(python)

pyenv = Pyenv(python)

logging.warning(f"Building deephaven-ib from source: {dh_ib_version}")
Expand Down Expand Up @@ -500,6 +535,7 @@ def dev(
logging.warning(f"Creating development environment: python={python} dh_version={dh_version}, dh_version_exact={dh_version_exact}, ib_version={ib_version}, dh_ib_version={dh_ib_version}, delete_vm_if_exists={delete_venv}")

python = Path(python).absolute() if python.startswith("./") else python
assert_python_version(python)

if dh_version_exact:
if dh_version != DH_VERSION_DEFAULT:
Expand Down Expand Up @@ -572,6 +608,7 @@ def release(
logging.warning(f"Creating release environment: python={python} dh_ib_version={dh_ib_version}")

python = Path(python).absolute() if python.startswith("./") else python
assert_python_version(python)

wheel = download_wheel(python, "deephaven_ib", dh_ib_version)
deps = pkg_dependencies(wheel)
Expand Down

0 comments on commit d338575

Please sign in to comment.