diff --git a/python/docker/test_wheels/scripts/README.md b/python/docker/test_wheels/scripts/README.md index fec55bf9e7..b67ab80888 100644 --- a/python/docker/test_wheels/scripts/README.md +++ b/python/docker/test_wheels/scripts/README.md @@ -2,15 +2,29 @@ ## Installation -For regular use: -``` +**Important:** This package requires access to the `python_versions.json` configuration file in the opm-simulators repository. Choose one of these installation methods: + +### Option 1: Install within repository (Recommended) +```bash +# Create venv inside the opm-simulators repository +$ cd /path/to/opm-simulators/python/docker/test_wheels/scripts $ python -m venv .venv $ source .venv/bin/activate $ pip install . # Installs package and dependencies ``` -For development (editable install with locked dependency versions): +### Option 2: Global installation with environment variable +```bash +# Install anywhere, but set environment variable +$ python -m venv .venv +$ source .venv/bin/activate +$ pip install . +$ export OPM_SIMULATORS_ROOT=/path/to/opm-simulators ``` + +### For development (editable install with locked dependency versions): +```bash +$ cd /path/to/opm-simulators/python/docker/test_wheels/scripts $ uv venv $ uv sync # Installs package in editable mode with exact versions from uv.lock $ source .venv/bin/activate @@ -100,3 +114,34 @@ $ opm-wheels show-wheel-files \ opm_simulators-2025.10-cp312-cp312-manylinux_2_27_x86_64.whl ``` +## Troubleshooting + +### FileNotFoundError: Could not locate python_versions.json + +This error occurs when the CLI cannot find the configuration file. Solutions: + +1. **Run from within the repository:** + ```bash + cd /path/to/opm-simulators + cd python/docker/test_wheels/scripts + source .venv/bin/activate + opm-wheels run-docker-image --help + ``` + +2. **Set environment variable for global installations:** + ```bash + export OPM_SIMULATORS_ROOT=/path/to/opm-simulators + opm-wheels run-docker-image --help + ``` + +3. **Verify the configuration file exists:** + ```bash + ls /path/to/opm-simulators/python/docker/python_versions.json + ``` + +### RuntimeError: Not a valid Git repository + +This error means you're not inside a Git repository. Either: +- Navigate to the opm-simulators repository directory, or +- Use the `OPM_SIMULATORS_ROOT` environment variable method + diff --git a/python/docker/test_wheels/scripts/src/opm_wheels/config_reader.py b/python/docker/test_wheels/scripts/src/opm_wheels/config_reader.py index aafa555f6c..afcb1aabb7 100644 --- a/python/docker/test_wheels/scripts/src/opm_wheels/config_reader.py +++ b/python/docker/test_wheels/scripts/src/opm_wheels/config_reader.py @@ -4,14 +4,28 @@ from pathlib import Path from typing import Dict, List from opm_wheels.constants import PythonVersion +from opm_wheels.helpers import get_git_root def get_config_path() -> Path: """Get the path to the python_versions.json config file.""" - # Go up from docker/test_wheels/scripts/src/opm_wheels to docker root - current_dir = Path(__file__).parent - config_path = current_dir / ".." / ".." / ".." / ".." / "python_versions.json" - return config_path.resolve() + try: + # Try to find git root (works when inside repo) + repo_root = get_git_root() + return repo_root / "python/docker/python_versions.json" + except RuntimeError: + # Fallback to environment variable for global installations + env_root = os.environ.get('OPM_SIMULATORS_ROOT') + if env_root: + repo_root = Path(env_root) + config_path = repo_root / "python/docker/python_versions.json" + if config_path.exists(): + return config_path + + raise FileNotFoundError( + "Could not locate python_versions.json. Either run from within " + "opm-simulators repository or set OPM_SIMULATORS_ROOT environment variable." + ) def load_python_config() -> Dict: