From 1f8f2d9336bdc50cf60d709ee5e231194580f85d Mon Sep 17 00:00:00 2001 From: Chip Kent <5250374+chipkent@users.noreply.github.com> Date: Wed, 7 Jan 2026 22:41:15 -0700 Subject: [PATCH 1/4] feat: Add convenience script for quick setup and improve installation process (#137) Add `build_and_run.sh` convenience script for one-command environment setup and server startup, update README with quick start instructions, fix virtual environment path naming to use hyphens instead of equals signs, and reorder package installation to install deephaven-server before ibapi to improve dependency resolution. --- README.md | 10 +++++++++- build_and_run.sh | 39 +++++++++++++++++++++++++++++++++++++++ dhib_env.py | 16 ++++++++-------- 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100755 build_and_run.sh diff --git a/README.md b/README.md index c074683e..7ba72a62 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,14 @@ you can use the `--use_venv false` option to [./dhib_env.py](./dhib_env.py). ``` 4) Build a [deephaven-ib](https://github.com/deephaven-examples/deephaven-ib) virtual environment: + **Quick Start:** For a one-command setup that builds the environment and starts the server, use the convenience script: + ```bash + ./build_and_run.sh + ``` + This script automatically creates the virtual environment, installs the latest release version, and starts the Deephaven server. Press Ctrl-C to stop the server when done. + + **Manual Setup:** For more control over the installation process, follow these steps: + First, create a small, local virtual environment that will be used only to run the `dhib_env.py` script (this avoids installing packages system-wide): ```bash python3 -m venv .venv-installer @@ -201,7 +209,7 @@ you can use the `--use_venv false` option to [./dhib_env.py](./dhib_env.py). Install the dependencies needed to run the script into this installer virtual environment: ```bash - pip --upgrade pip + python -m pip install --upgrade pip pip install -r requirements_dhib_env.txt ``` diff --git a/build_and_run.sh b/build_and_run.sh new file mode 100755 index 00000000..91bfb3d0 --- /dev/null +++ b/build_and_run.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Convenience script to build a release virtual environment and start the Deephaven server. +# This script automates the process of: +# 1. Creating a temporary installer virtual environment +# 2. Building the release virtual environment with deephaven-ib, deephaven-server, and ibapi +# 3. Starting the Deephaven server +# +# Press Ctrl-C to stop the server when done. + +# Display Java home (required for Deephaven) +echo $JAVA_HOME + +# Clean up any existing virtual environments +deactivate 2>/dev/null || true # Deactivate if already in a venv +rm -rf .venv-installer +rm -rf venv-release-dhib* + +# Create temporary installer virtual environment +# This small venv is only used to run the dhib_env.py script +python3.12 -m venv .venv-installer +source .venv-installer/bin/activate + +# Install dependencies needed to run dhib_env.py +python -m pip install --upgrade pip +pip install -r requirements_dhib_env.txt + +# Build the release virtual environment +# This creates venv-release-dhib- with all required packages +python ./dhib_env.py release + +# Clean up temporary installer venv +deactivate +rm -rf .venv-installer + +# Activate the release virtual environment and start Deephaven server +source ./venv-release-dhib*/bin/activate +deephaven server +deactivate \ No newline at end of file diff --git a/dhib_env.py b/dhib_env.py index 44bc8327..6f4461d3 100755 --- a/dhib_env.py +++ b/dhib_env.py @@ -338,9 +338,9 @@ def venv_path(is_release: bool, dh_version: str, dh_ib_version: str) -> Path: The path to the new virtual environment. """ if is_release: - return Path(f"venv-release-dhib={dh_version}").absolute() + return Path(f"venv-release-dhib-{dh_version}").absolute() else: - return Path(f"venv-dev-dhib={dh_ib_version}-dh={dh_version}").absolute() + return Path(f"venv-dev-dhib-{dh_ib_version}-dh-{dh_version}").absolute() ######################################################################################################################## @@ -578,13 +578,13 @@ def dev( logging.warning(f"Using system python: {python}") pyenv = Pyenv(python) + logging.warning(f"Installing deephaven-server: {dh_version}") + pyenv.pip_install("deephaven-server", f"~={dh_version}") + ib_wheel = IbWheel(ib_version) ib_wheel.build(pyenv) ib_wheel.install(pyenv) - logging.warning(f"Installing deephaven-server: {dh_version}") - pyenv.pip_install("deephaven-server", f"~={dh_version}") - if install_dhib: if use_dev: logging.warning(f"Building deephaven-ib from source: {dh_ib_version}") @@ -649,13 +649,13 @@ def release( logging.warning(f"Using system python: {python}") pyenv = Pyenv(python) + logging.warning(f"Installing deephaven-server: {dh_version}") + pyenv.pip_install("deephaven-server", f"~={dh_version}") + ib_wheel = IbWheel(ib_version) ib_wheel.build(pyenv) ib_wheel.install(pyenv) - logging.warning(f"Installing deephaven-server: {dh_version}") - pyenv.pip_install("deephaven-server", f"~={dh_version}") - logging.warning(f"Installing deephaven-ib from PyPI: {dh_ib_version}") pyenv.pip_install("deephaven-ib", f"=={dh_ib_version}") success(pyenv) From c77f3df24723f8c293bc303f07ce750b649bab24 Mon Sep 17 00:00:00 2001 From: Chip Kent <5250374+chipkent@users.noreply.github.com> Date: Wed, 7 Jan 2026 22:48:05 -0700 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build_and_run.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build_and_run.sh b/build_and_run.sh index 91bfb3d0..d6601b38 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -9,7 +9,11 @@ # Press Ctrl-C to stop the server when done. # Display Java home (required for Deephaven) -echo $JAVA_HOME +if [ -z "${JAVA_HOME:-}" ]; then + echo "Error: JAVA_HOME is not set. Deephaven requires Java. Please set JAVA_HOME before running this script." >&2 + exit 1 +fi +echo "JAVA_HOME=${JAVA_HOME}" # Clean up any existing virtual environments deactivate 2>/dev/null || true # Deactivate if already in a venv @@ -35,5 +39,6 @@ rm -rf .venv-installer # Activate the release virtual environment and start Deephaven server source ./venv-release-dhib*/bin/activate -deephaven server -deactivate \ No newline at end of file +# Ensure the release virtual environment is deactivated when the script exits +trap 'deactivate 2>/dev/null || true' EXIT INT TERM +deephaven server \ No newline at end of file From a8d4444addf4361e947ecb7caf41d3e0fb579b7a Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 22:52:54 -0700 Subject: [PATCH 3/4] [WIP] Fix issues from PR #137 on build script (#138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [x] Add `set -e` to the script to exit on any command failure - [x] Add `set -u` to catch undefined variables - [x] Add `set -o pipefail` to catch errors in piped commands - [ ] Run code review - [ ] Reply to the comment with the commit hash --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chipkent <5250374+chipkent@users.noreply.github.com> --- build_and_run.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build_and_run.sh b/build_and_run.sh index d6601b38..d0ad1b6c 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -1,5 +1,10 @@ #!/bin/bash +# Exit on any error, undefined variable, or error in a pipeline +set -e +set -u +set -o pipefail + # Convenience script to build a release virtual environment and start the Deephaven server. # This script automates the process of: # 1. Creating a temporary installer virtual environment From 96013a8c339169b54507fc621a3e21e8d1c422a5 Mon Sep 17 00:00:00 2001 From: Chip Kent <5250374+chipkent@users.noreply.github.com> Date: Wed, 7 Jan 2026 22:57:58 -0700 Subject: [PATCH 4/4] Update build_and_run.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build_and_run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_and_run.sh b/build_and_run.sh index d0ad1b6c..48a5187e 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -36,7 +36,7 @@ pip install -r requirements_dhib_env.txt # Build the release virtual environment # This creates venv-release-dhib- with all required packages -python ./dhib_env.py release +python ./dhib_env.py release # Clean up temporary installer venv deactivate