Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```

Expand Down
49 changes: 49 additions & 0 deletions build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
Comment thread
chipkent marked this conversation as resolved.

# 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
# 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)
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
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

Copilot AI Jan 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script hardcodes python3.12 but doesn't verify that this version is available on the system. Consider adding a check to verify python3.12 exists, or use a more flexible approach like python3 with a version check, consistent with the README documentation which mentions python3.

Copilot uses AI. Check for mistakes.
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-<version> 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

Copilot AI Jan 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a wildcard pattern in the source command could fail if multiple matching directories exist or if no matching directory exists. Consider capturing the venv path from the dhib_env.py output or failing explicitly if the expected venv directory doesn't exist. For example, you could check for the existence of the directory first or use a more robust path resolution.

Suggested change
source ./venv-release-dhib*/bin/activate
venv_activate_candidates=( ./venv-release-dhib*/bin/activate )
# Handle cases where the glob does not match or matches multiple environments
if [ "${#venv_activate_candidates[@]}" -eq 1 ] && [ "${venv_activate_candidates[0]}" = "./venv-release-dhib*/bin/activate" ]; then
echo "Error: No release virtual environment found matching ./venv-release-dhib*/bin/activate" >&2
exit 1
fi
if [ "${#venv_activate_candidates[@]}" -eq 0 ]; then
echo "Error: No release virtual environment found matching ./venv-release-dhib*/bin/activate" >&2
exit 1
elif [ "${#venv_activate_candidates[@]}" -gt 1 ]; then
echo "Error: Multiple release virtual environments found. Please remove duplicates:" >&2
printf ' %s\n' "${venv_activate_candidates[@]}" >&2
exit 1
fi
if [ ! -f "${venv_activate_candidates[0]}" ]; then
echo "Error: Expected activate script not found at ${venv_activate_candidates[0]}" >&2
exit 1
fi
source "${venv_activate_candidates[0]}"

Copilot uses AI. Check for mistakes.
# Ensure the release virtual environment is deactivated when the script exits
trap 'deactivate 2>/dev/null || true' EXIT INT TERM
deephaven server
16 changes: 8 additions & 8 deletions dhib_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


########################################################################################################################
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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)
Expand Down
Loading