Skip to content

Commit 3e3404e

Browse files
committed
Fix package and LD_LIBRARY_PATH issues for readthedocs
Signed-off-by: Gigon Bae <gbae@nvidia.com>
1 parent 1f7c050 commit 3e3404e

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

docs/source/conf.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919
f"{READTHEDOCS_PROJECT}/envs/{READTHEDOCS_VERSION}/bin/activate; ../../run setup read_the_docs'",
2020
shell=True,
2121
)
22-
# Update LD_LIBRARY_PATH for CUDA runtime
23-
old_ld_library_path = os.environ.get("LD_LIBRARY_PATH", "")
24-
# Note that 'python3.8' is hard-coded here, it should be updated if the Python version changes by
25-
# .readthedocs.yml or other configurations.
26-
os.environ["LD_LIBRARY_PATH"] = (
27-
f"{READTHEDOCS_PROJECT}/envs/{READTHEDOCS_VERSION}/lib/python3.8/site-packages/nvidia/cuda_runtime/lib:{old_ld_library_path}"
28-
)
22+
# Print LD_LIBRARY_PATH for verification
23+
ld_library_path = os.environ.get("LD_LIBRARY_PATH", "")
24+
print(f"LD_LIBRARY_PATH: {ld_library_path}")
2925
subprocess.call(
3026
"/bin/bash -c 'source /home/docs/checkouts/readthedocs.org/user_builds/"
3127
f"{READTHEDOCS_PROJECT}/envs/{READTHEDOCS_VERSION}/bin/activate; ../../run setup_gen_docs'",

run

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,11 @@ get_package_info() {
302302

303303
install_python_dev_deps() {
304304
local config="${1:-dev}"
305+
local is_read_the_docs="false"
305306
if [ -n "${VIRTUAL_ENV}" ] || [ -n "${CONDA_PREFIX}" ]; then
306307
# Read the Docs site is using specific setuptools version so should not upgrade it.
307308
if [ "$config" = "read_the_docs" ]; then
308-
run_command ${MONAI_PY_EXE} -m pip install -q -U pip wheel build
309-
# Install cuda runtime dependency
310-
run_command ${MONAI_PY_EXE} -m pip install -q nvidia-cuda-runtime-cu12
309+
is_read_the_docs="true"
311310
else
312311
run_command ${MONAI_PY_EXE} -m pip install -q -U setuptools pip wheel build
313312
fi
@@ -331,6 +330,26 @@ install_python_dev_deps() {
331330
# fix_holoscan_import
332331

333332
install_edit_mode
333+
334+
# Install packages overridden by Holoscan package if readthedocs is enabled
335+
if [ ${is_read_the_docs} = "true" ]; then
336+
# Upgrade pip overridden by Holoscan
337+
run_command ${MONAI_PY_EXE} -m pip install -q -U pip wheel build
338+
# Upgrade PyYAML to avoid the issue with the version installed by Holoscan
339+
run_command ${MONAI_PY_EXE} -m pip install -U PyYAML
340+
341+
# Install cuda runtime dependency
342+
run_command ${MONAI_PY_EXE} -m pip install nvidia-cuda-runtime-cu12
343+
344+
# Copy the cuda runtime library to the fixed location (workaround for readthedocs) so that
345+
# we can leverage the existing LD_LIBRARY_PATH (configured by the readthedocs UI) to locate the cuda runtime library.
346+
# (LD_LIBRARY_PATH is set to /home/docs/ for that purpose)
347+
# Note that 'python3.8' is hard-coded here, it should be updated if the Python version changes by
348+
# .readthedocs.yml or other configurations.
349+
run_command ls -al /home/docs/checkouts/readthedocs.org/user_builds/${READTHEDOCS_PROJECT}/envs/${READTHEDOCS_VERSION}/lib/python3.8/site-packages/nvidia/cuda_runtime/lib/
350+
run_command cp /home/docs/checkouts/readthedocs.org/user_builds/${READTHEDOCS_PROJECT}/envs/${READTHEDOCS_VERSION}/lib/python3.8/site-packages/nvidia/cuda_runtime/lib/*.so* /home/docs/
351+
run_command ls -al /home/docs/
352+
fi
334353
}
335354

336355
fix_holoscan_import() {

0 commit comments

Comments
 (0)