From 86732ecadb58865aa8d2b2efcd00924b2616fc6b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 12:41:31 +0300 Subject: [PATCH 01/75] initial try --- platforms/cuda/sharedTarget/CMakeLists.txt | 1 + .../prepare_build_environment_linux_cpu.sh | 38 ++++++ .../prepare_build_environment_linux_cu118.sh | 124 ++++++++++++++++++ .../prepare_build_environment_linux_cu124.sh | 31 +++++ .../prepare_build_environment_osx.sh | 0 .../prepare_build_environment_windows_cpu.sh | 8 ++ ...prepare_build_environment_windows_cu118.sh | 19 +++ ...prepare_build_environment_windows_cu124.sh | 19 +++ wrappers/python/pyproject.toml | 47 +++++++ wrappers/python/setup.py | 31 +---- 10 files changed, 291 insertions(+), 27 deletions(-) create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh create mode 100644 wrappers/python/pyproject.toml diff --git a/platforms/cuda/sharedTarget/CMakeLists.txt b/platforms/cuda/sharedTarget/CMakeLists.txt index cdc0336ae8..8248a532de 100644 --- a/platforms/cuda/sharedTarget/CMakeLists.txt +++ b/platforms/cuda/sharedTarget/CMakeLists.txt @@ -22,4 +22,5 @@ ELSE (APPLE) SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}") ENDIF (APPLE) +SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN/..;$ORIGIN/../../../nvidia/cufft/lib;$ORIGIN/../../../nvidia/cuda_nvrtc/lib;") INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_TARGET}) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh new file mode 100755 index 0000000000..70b8f95d13 --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh @@ -0,0 +1,38 @@ +#! /bin/bash + +set -e +set -x + +# Install dependencies with yum +dnf install -y doxygen zip opencl-headers ocl-icd tree + +# # Install CUDA (nothing) + +# # Install HIP +# export HIP_VERSION=6 +# yum install -y epel-release +# yum install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm +# yum install -y rocm-device-libs hip-devel hip-runtime-amd hipcc + +# Configure build with Cmake +mkdir -p build +cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX=${HOME}/openmm-install \ + -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' \ + -DOPENMM_BUILD_OPENCL_LIB=ON \ + -DOPENCL_INCLUDE_DIR=/usr/include/CL \ + -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1 + +tree . + +# Build OpenMM +make -j4 install +make -j4 PythonInstall + +# Build wheel +export LD_LIBRARY_PATH=${HOME}/openmm-install/lib +export OPENMM_INCLUDE_PATH=../openmmapi/include +tree ./python + +ls -l ../openmmapi/ \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh new file mode 100755 index 0000000000..ac32543d6d --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh @@ -0,0 +1,124 @@ +#! /bin/bash + +set -e +set -x + +dnf install -y doxygen + + +if [ "$CIBW_ARCHS" != "aarch64" ]; then + + # Install CUDA 11.8: + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-nvcc-11-8-11.8.89-1 \ + cuda-cudart-devel-11-8-11.8.89-1 \ + libcurand-devel-11-8-10.3.0.86-1 \ + libcudnn9-devel-cuda-11-9.8.0.87-1 \ + libcublas-devel-11-8-11.11.3.6-1 \ + libnccl-devel-2.15.5-1+cuda11.8 \ + libcusparse-devel-11-8-11.7.5.86-1 \ + libcusolver-devel-11-8-11.4.1.48-1 \ + gcc-toolset-11 + + ln -s cuda-11.8 /usr/local/cuda + ln -s /opt/rh/gcc-toolset-11/root/usr/bin/gcc /usr/local/cuda/bin/gcc + ln -s /opt/rh/gcc-toolset-11/root/usr/bin/g++ /usr/local/cuda/bin/g++ + + export CUDA_HOME="/usr/local/cuda" + export WITH_CUDA=1 + + + # Configure pip to use PyTorch extra-index-url for CUDA 11.8 + mkdir -p $HOME/.config/pip + echo "[global] +extra-index-url = https://download.pytorch.org/whl/cu118" > $HOME/.config/pip/pip.conf + +fi + + +# OpenMM Compilation starting here + +CMAKE_FLAGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release" +if [[ "$with_test_suite" == "true" ]]; then + CMAKE_FLAGS+=" -DBUILD_TESTING=ON -DOPENMM_BUILD_OPENCL_TESTS=ON" +else + CMAKE_FLAGS+=" -DBUILD_TESTING=OFF" +fi + + +if [[ "$target_platform" == linux* ]]; then + SHLIB_EXT=".so" + # CFLAGS + # JRG: Had to add -ldl to prevent linking errors (dlopen, etc) + MINIMAL_CFLAGS+=" -O3 -ldl" + CFLAGS+=" $MINIMAL_CFLAGS" + CXXFLAGS+=" $MINIMAL_CFLAGS" + + # CUDA is enabled in these platforms + if [[ "$target_platform" == linux-64 || "$target_platform" == linux-ppc64le ]]; then + # # CUDA_HOME is defined by nvcc metapackage + CMAKE_FLAGS+=" -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME}" + # CUDA tests won't build, disable for now + # See https://github.com/openmm/openmm/issues/2258#issuecomment-462223634 + CMAKE_FLAGS+=" -DOPENMM_BUILD_CUDA_TESTS=OFF" + # shadow some CMAKE_ARGS bits that interfere with CUDA detection + CMAKE_FLAGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH" + fi + + # OpenCL ICD + CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" + CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" + +elif [[ "$target_platform" == osx* ]]; then + SHLIB_EXT=".dylib" + if [[ "$opencl_impl" == khronos ]]; then + CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" + CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" + fi + # When using opencl_impl == apple, CMake will auto-locate it, so no need to provide the flags + # On Conda Forge, this will result in: + # /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/... + # ...SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenCL.framework + # On local builds, it might be: + # /System/Library/Frameworks/OpenCL.framework/OpenCL +fi + +# Set location for FFTW3 on both linux and mac +CMAKE_FLAGS+=" -DFFTW_INCLUDES=${PREFIX}/include/" +CMAKE_FLAGS+=" -DFFTW_LIBRARY=${PREFIX}/lib/libfftw3f${SHLIB_EXT}" +CMAKE_FLAGS+=" -DFFTW_THREADS_LIBRARY=${PREFIX}/lib/libfftw3f_threads${SHLIB_EXT}" +# Disambiguate swig location +CMAKE_FLAGS+=" -DSWIG_EXECUTABLE=$(which swig)" + +# Build in subdirectory and install. +mkdir -p build +cd build +cmake ${CMAKE_FLAGS} .. +make -j$CPU_COUNT +make -j$CPU_COUNT install PythonInstall + +# Put examples into an appropriate subdirectory. +mkdir -p ${PREFIX}/share/openmm/ +mv ${PREFIX}/examples ${PREFIX}/share/openmm/ + +# Fix some overlinking warnings/errors +for lib in ${PREFIX}/lib/plugins/*${SHLIB_EXT}; do + ln -s $lib ${PREFIX}/lib/$(basename $lib) || true +done + +if [[ "$with_test_suite" == "true" ]]; then + mkdir -p ${PREFIX}/share/openmm/tests/ + # BSD find vs GNU find: -executable is only available in GNU find + # +0111 is somehow equivalent in BSD, but that's not compatible in GNU + # so we use different commands for each... + if [[ "$target_platform" == osx* ]]; then + find . -name "Test*" -perm +0111 -type f \ + -exec python $RECIPE_DIR/patch_osx_tests.py "{}" \; \ + -exec cp "{}" $PREFIX/share/openmm/tests/ \; + else + find . -name "Test*" -executable -type f -exec cp "{}" $PREFIX/share/openmm/tests/ \; + fi + cp -r python/tests $PREFIX/share/openmm/tests/python +fi diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh new file mode 100755 index 0000000000..cc9e212c5a --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh @@ -0,0 +1,31 @@ +#! /bin/bash + +set -e +set -x + + +if [ "$CIBW_ARCHS" != "aarch64" ]; then + + # Install CUDA 12.4: + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-nvcc-12-4-12.4.131-1 \ + cuda-cudart-devel-12-4-12.4.127-1 \ + libcurand-devel-12-4-10.3.5.147-1 \ + libcudnn9-devel-cuda-12-9.1.0.70-1 \ + libcublas-devel-12-4-12.4.5.8-1 \ + libnccl-devel-2.21.5-1+cuda12.4 \ + libcusparse-devel-12-4-12.3.1.170-1 \ + libcusolver-devel-12-4-11.6.1.9-1 \ + gcc-toolset-13 + + ln -s cuda-12.4 /usr/local/cuda + ln -s /opt/rh/gcc-toolset-13/root/usr/bin/gcc /usr/local/cuda/bin/gcc + ln -s /opt/rh/gcc-toolset-13/root/usr/bin/g++ /usr/local/cuda/bin/g++ + + export CUDA_HOME="/usr/local/cuda" + export WITH_CUDA=1 + +fi + diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh new file mode 100755 index 0000000000..e69de29bb2 diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh new file mode 100755 index 0000000000..1785227133 --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Create pip directory if it doesn't exist +mkdir -p "C:\ProgramData\pip" + +# Create pip.ini file with PyTorch CPU index +echo "[global] +extra-index-url = https://download.pytorch.org/whl/cpu" > "C:\ProgramData\pip\pip.ini" diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh new file mode 100755 index 0000000000..3bf768f08d --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +set -e +set -x + +CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" +curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe +./cuda.exe -s nvcc_11.8 cudart_11.8 cublas_dev_11.8 curand_dev_11.8 cusparse_dev_11.8 cusolver_dev_11.8 thrust_11.8 +rm cuda.exe + +export WITH_CUDA=1 +export CUDA_HOME="$CUDA_ROOT" + +# Create pip directory if it doesn't exist +mkdir -p "C:\ProgramData\pip" + +# Create pip.ini file with PyTorch CUDA 11.8 index +echo "[global] +extra-index-url = https://download.pytorch.org/whl/cu118" > "C:\ProgramData\pip\pip.ini" \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh new file mode 100755 index 0000000000..7b441f93e0 --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +set -e +set -x + +CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" +curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe +./cuda.exe -s nvcc_12.4 cudart_12.4 cublas_dev_12.4 curand_dev_12.4 cusparse_dev_12.4 cusolver_dev_12.4 +rm cuda.exe + +export WITH_CUDA=1 +export CUDA_HOME="$CUDA_ROOT" + +# Create pip directory if it doesn't exist +mkdir -p "C:\ProgramData\pip" + +# Create pip.ini file with PyTorch CUDA 12.4 index +echo "[global] +extra-index-url = https://download.pytorch.org/whl/cu124" > "C:\ProgramData\pip\pip.ini" \ No newline at end of file diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml new file mode 100644 index 0000000000..6a3b8b33b0 --- /dev/null +++ b/wrappers/python/pyproject.toml @@ -0,0 +1,47 @@ +[project] +name = "OpenMM" +description = "Python wrapper for OpenMM (a C++ MD package)" +authors = [{ name = "Peter Eastman", email = "peastman@stanford.edu" }] +readme = "README.md" +license = "PSF-2.0" +requires-python = ">=3.8" +dynamic = ["version"] +classifiers = [ + "Programming Language :: Python :: 3", +] +dependencies = [ + "numpy" +] + +[project.urls] +"Homepage" = "https://openmm.org" +"Bug Tracker" = "https://github.com/openmm/openmm/issues" +"Download URL" = "https://openmm.org" + +[tool.setuptools_scm] + +[tool.setuptools.packages.find] +include = ["openmm*"] + + +[tool.setuptools.exclude-package-data] +"*" = ["*.c", "*.cpp", "*.h", "*.cuh", "*.cu", ".gitignore"] + +[build-system] +requires = ["setuptools>=64", "setuptools-scm>=8", "numpy", "cython"] +build-backend = "setuptools.build_meta" + + +[tool.cibuildwheel] +skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] +test-requires = ["pytest"] +test-command = "pytest {project}/tests" +manylinux-x86_64-image = "manylinux_2_28" +manylinux-aarch64-image = "manylinux_2_28" +environment-pass = ["CIBW_ARCHS"] +# container-engine = "docker; create_args: --gpus all" + +# [tool.cibuildwheel.macos] +# repair-wheel-command = [ +# "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}", +# ] \ No newline at end of file diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 05c958e0ad..9453641d11 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -84,13 +84,14 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION """ cnt = """ +import os # THIS FILE IS GENERATED FROM OPENMM SETUP.PY short_version = '%(version)s' version = '%(version)s' full_version = '%(full_version)s' git_revision = '%(git_revision)s' release = %(isrelease)s -openmm_library_path = r'%(path)s' +openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "OpenMM.libs", "lib")) if not release: version = full_version @@ -127,16 +128,6 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, build_info=BUILD_INFO): from setuptools import Extension setupKeywords = {} - setupKeywords["name"] = "OpenMM" - setupKeywords["version"] = "%s.%s.%s%s" % (major_version_num, - minor_version_num, - build_info, - os.getenv('VERSION_SUFFIX', '')) - setupKeywords["author"] = "Peter Eastman" - setupKeywords["license"] = \ - "Python Software Foundation License (BSD-like)" - setupKeywords["url"] = "https://openmm.org" - setupKeywords["download_url"] = "https://openmm.org" setupKeywords["packages"] = [ "simtk", "simtk.unit", @@ -151,21 +142,6 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, "openmm.app.internal.pdbx", "openmm.app.internal.pdbx.reader", "openmm.app.internal.pdbx.writer"] - setupKeywords["data_files"] = [] - setupKeywords["package_data"] = {"openmm" : [], - "openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/charmm36/*.xml', 'data/implicit/*.xml'], - "openmm.app.internal" : []} - setupKeywords["install_requires"] = ["numpy"] - setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"] - setupKeywords["description"] = \ - "Python wrapper for OpenMM (a C++ MD package)" - setupKeywords["long_description"] = \ - """OpenMM is a toolkit for molecular simulation. It can be used either as a - stand-alone application for running simulations, or as a library you call - from your own code. It provides a combination of extreme flexibility - (through custom forces and integrators), openness, and high performance - (especially on recent GPUs) that make it truly unique among simulation codes. - """ define_macros = [('MAJOR_VERSION', major_version_num), ('MINOR_VERSION', minor_version_num)] @@ -191,7 +167,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, if not openmm_lib_path: reportError("Set OPENMM_LIB_PATH to point to the lib directory for OpenMM") - extra_compile_args=['-std=c++11'] + extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'] extra_link_args=[] if platform.system() == "Windows": define_macros.append( ('WIN32', None) ) @@ -199,6 +175,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, define_macros.append( (' _MSC_VER', None) ) extra_compile_args.append('/EHsc') else: + extra_link_args += ['-Wl,-rpath,$ORIGIN/../OpenMM.libs/lib'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', openmm_lib_path] From 7fce7cf3a180e1f30f310678112fa53c365c1b50 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 15:15:01 +0300 Subject: [PATCH 02/75] cpu build working --- wrappers/python/MANIFEST.in | 3 ++- .../prepare_build_environment_linux_cpu.sh | 19 +++++++++++-------- wrappers/python/pyproject.toml | 16 +++++++++++----- wrappers/python/setup.py | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/wrappers/python/MANIFEST.in b/wrappers/python/MANIFEST.in index c9af15ab45..df2d446845 100644 --- a/wrappers/python/MANIFEST.in +++ b/wrappers/python/MANIFEST.in @@ -8,4 +8,5 @@ recursive-include src *.txt *.py *.i *.c *.cxx *.h *.sh Doxyfile prune src/swig_doxygen/doxygen/html prune src/swig_doxygen/doxygen/xml global-exclude CMakeLists.txt - +graft openmm/include +graft openmm/lib \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh index 70b8f95d13..55c64f0472 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh @@ -4,7 +4,7 @@ set -e set -x # Install dependencies with yum -dnf install -y doxygen zip opencl-headers ocl-icd tree +dnf install -y doxygen zip opencl-headers ocl-icd # # Install CUDA (nothing) @@ -16,23 +16,26 @@ dnf install -y doxygen zip opencl-headers ocl-icd tree # Configure build with Cmake mkdir -p build +mkdir -p openmm-install cd build cmake .. \ - -DCMAKE_INSTALL_PREFIX=${HOME}/openmm-install \ + -DCMAKE_INSTALL_PREFIX=openmm-install \ -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' \ -DOPENMM_BUILD_OPENCL_LIB=ON \ -DOPENCL_INCLUDE_DIR=/usr/include/CL \ -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1 -tree . - # Build OpenMM make -j4 install make -j4 PythonInstall +cd .. + # Build wheel -export LD_LIBRARY_PATH=${HOME}/openmm-install/lib -export OPENMM_INCLUDE_PATH=../openmmapi/include -tree ./python +export LD_LIBRARY_PATH=openmm-install/lib + +cp -r build/python/* wrappers/python/ +cp -r build/openmm-install/include wrappers/python/openmm/ +cp -r build/openmm-install/lib wrappers/python/openmm/ + -ls -l ../openmmapi/ \ No newline at end of file diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 6a3b8b33b0..07ecb8b641 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -19,28 +19,34 @@ dependencies = [ "Download URL" = "https://openmm.org" [tool.setuptools_scm] +root = "../.." [tool.setuptools.packages.find] include = ["openmm*"] -[tool.setuptools.exclude-package-data] -"*" = ["*.c", "*.cpp", "*.h", "*.cuh", "*.cu", ".gitignore"] +# [tool.setuptools.exclude-package-data] +# "*" = ["*.c", "*.cpp", "*.h", "*.cuh", "*.cu", ".gitignore"] [build-system] -requires = ["setuptools>=64", "setuptools-scm>=8", "numpy", "cython"] +requires = ["setuptools>=78", "setuptools-scm>=8", "numpy", "cython"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] -test-command = "pytest {project}/tests" +test-command = "cd {project}/wrappers/python/tests; pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -environment-pass = ["CIBW_ARCHS"] +environment-pass = ["CIBW_ARCHS", "OPENMM_INCLUDE_PATH", "OPENMM_LIB_PATH", "LD_LIBRARY_PATH"] # container-engine = "docker; create_args: --gpus all" +[tool.cibuildwheel.linux] +repair-wheel-command = [ + "auditwheel repair --exclude libOpenMM.so --exclude libOpenMMCUDA.so --exclude libOpenMMHIP.so --exclude libOpenMMOpenCL.so --exclude libOpenMMDrude.so --exclude libOpenMMAmoeba.so --exclude libOpenMMRPMD.so --exclude libOpenCL.so.1 --exclude libcuda.so.1 --exclude libcufft.so.11 --exclude libcufft.so.10 --exclude libnvrtc.so.11.2 --exclude libnvrtc.so.12 --exclude libhiprtc.so.6 --exclude libamdhip64.so.6 -w {dest_dir} {wheel}", +] + # [tool.cibuildwheel.macos] # repair-wheel-command = [ # "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}", diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 9453641d11..e6b072a0d1 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -91,7 +91,7 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION full_version = '%(full_version)s' git_revision = '%(git_revision)s' release = %(isrelease)s -openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "OpenMM.libs", "lib")) +openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "lib")) if not release: version = full_version @@ -175,7 +175,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, define_macros.append( (' _MSC_VER', None) ) extra_compile_args.append('/EHsc') else: - extra_link_args += ['-Wl,-rpath,$ORIGIN/../OpenMM.libs/lib'] + extra_link_args += ['-Wl,-rpath,$ORIGIN/lib'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', openmm_lib_path] From db005cd2c0067a3de1e1e0deeae1958a1d97e588 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 15:33:57 +0300 Subject: [PATCH 03/75] cleanup the installation --- wrappers/python/MANIFEST.in | 4 ++-- .../prepare_build_environment_linux_cpu.sh | 2 +- wrappers/python/openmm/__init__.py | 11 ++++++----- wrappers/python/pyproject.toml | 2 +- wrappers/python/setup.py | 8 ++------ 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/wrappers/python/MANIFEST.in b/wrappers/python/MANIFEST.in index df2d446845..a97adf6cbc 100644 --- a/wrappers/python/MANIFEST.in +++ b/wrappers/python/MANIFEST.in @@ -8,5 +8,5 @@ recursive-include src *.txt *.py *.i *.c *.cxx *.h *.sh Doxyfile prune src/swig_doxygen/doxygen/html prune src/swig_doxygen/doxygen/xml global-exclude CMakeLists.txt -graft openmm/include -graft openmm/lib \ No newline at end of file +graft openmm/lib +prune include \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh index 55c64f0472..fa154ed944 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh @@ -35,7 +35,7 @@ cd .. export LD_LIBRARY_PATH=openmm-install/lib cp -r build/python/* wrappers/python/ -cp -r build/openmm-install/include wrappers/python/openmm/ +cp -r build/openmm-install/include wrappers/python/ cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 26a1a2aeaf..3141065085 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -9,14 +9,15 @@ import os, os.path import sys -from . import version + +openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')) if sys.platform == 'win32': _path = os.environ['PATH'] os.environ['PATH'] = r'%(lib)s;%(lib)s\plugins;%(path)s' % { - 'lib': version.openmm_library_path, 'path': _path} + 'lib': openmm_library_path, 'path': _path} try: - with os.add_dll_directory(version.openmm_library_path): + with os.add_dll_directory(openmm_library_path): from . import _openmm except: pass @@ -26,8 +27,8 @@ from openmm.mtsintegrator import MTSIntegrator, MTSLangevinIntegrator from openmm.amd import AMDIntegrator, AMDForceGroupIntegrator, DualAMDIntegrator -if os.getenv('OPENMM_PLUGIN_DIR') is None and os.path.isdir(version.openmm_library_path): - pluginLoadedLibNames = Platform.loadPluginsFromDirectory(os.path.join(version.openmm_library_path, 'plugins')) +if os.getenv('OPENMM_PLUGIN_DIR') is None and os.path.isdir(openmm_library_path): + pluginLoadedLibNames = Platform.loadPluginsFromDirectory(os.path.join(openmm_library_path, 'plugins')) else: pluginLoadedLibNames = Platform.loadPluginsFromDirectory(Platform.getDefaultPluginsDirectory()) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 07ecb8b641..80b40ac56e 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -39,7 +39,7 @@ test-requires = ["pytest"] test-command = "cd {project}/wrappers/python/tests; pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -environment-pass = ["CIBW_ARCHS", "OPENMM_INCLUDE_PATH", "OPENMM_LIB_PATH", "LD_LIBRARY_PATH"] +environment-pass = ["CIBW_ARCHS"] # container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.linux] diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index e6b072a0d1..f1409d5471 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -160,12 +160,8 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, libraries[ii]="%s_d" % libraries[ii] sys.stdout.write("%s\n" % libraries[ii]) - openmm_include_path = os.getenv('OPENMM_INCLUDE_PATH') - if not openmm_include_path: - reportError("Set OPENMM_INCLUDE_PATH to point to the include directory for OpenMM") - openmm_lib_path = os.getenv('OPENMM_LIB_PATH') - if not openmm_lib_path: - reportError("Set OPENMM_LIB_PATH to point to the lib directory for OpenMM") + openmm_include_path = 'include' + openmm_lib_path = 'openmm/lib' extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'] extra_link_args=[] From d8bace0f078fa8e033d44af6a8b4bb63936e585c Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:26:56 +0300 Subject: [PATCH 04/75] time to test it on all OSs --- .github/workflows/publish.yml | 81 ++++++++++++ .../prepare_build_environment_linux.sh | 62 +++++++++ .../prepare_build_environment_linux_cpu.sh | 41 ------ .../prepare_build_environment_linux_cu118.sh | 124 ------------------ .../prepare_build_environment_linux_cu124.sh | 31 ----- .../prepare_build_environment_osx.sh | 13 ++ .../prepare_build_environment_windows.sh | 49 +++++++ .../prepare_build_environment_windows_cpu.sh | 8 -- ...prepare_build_environment_windows_cu118.sh | 19 --- ...prepare_build_environment_windows_cu124.sh | 19 --- wrappers/python/pyproject.toml | 4 +- 11 files changed, 207 insertions(+), 244 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh create mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh delete mode 100755 wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..4a81d3f51c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,81 @@ +name: Build wheels and publish + +on: + workflow_dispatch: + workflow_call: + push: + +jobs: + build: + name: Build wheels on ${{ matrix.os }}-${{ matrix.cuda }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] + accelerator: [cpu, cu118, cu124, hip] + exclude: + - os: ubuntu-24.04-arm + accelerator: cu118 + - os: ubuntu-24.04-arm + accelerator: cu124 + - os: macos-latest + accelerator: cu118 + - os: macos-latest + accelerator: cu124 + + steps: + - name: Free space of Github Runner (otherwise it will fail by running out of disk) + if: matrix.os == 'ubuntu-latest' + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "/usr/local/.ghcup" + sudo rm -rf "/usr/local/julia1.9.2" + sudo rm -rf "/usr/local/lib/android" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.23.0 + + - name: Activate MSVC + uses: ilammy/msvc-dev-cmd@v1 + if: matrix.os == 'windows-2019' + + - name: Build wheels + if: matrix.os != 'windows-2019' + shell: bash -l {0} + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + export CIBW_ARCHS="${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'auto64' }}" + fi + python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" + CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" + CUDA_VERSION: ${{ matrix.accelerator }} + ACCELERATOR: ${{ matrix.accelerator }} + CIBW_BUILD: "cp310-*" + + - name: Build wheels + if: matrix.os == 'windows-2019' + shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" + DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building + CUDA_VERSION: ${{ matrix.accelerator }} + ACCELERATOR: ${{ matrix.accelerator }} + CIBW_BUILD: "cp310-*" + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.accelerator }}-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh new file mode 100755 index 0000000000..c7ba69faf3 --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -0,0 +1,62 @@ +#! /bin/bash + +set -e +set -x + +# Install dependencies with yum +dnf install -y doxygen zip opencl-headers ocl-icd + +if [ "$ACCELERATOR" == "cu118" ]; then + # Install CUDA 11.8 + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-compiler-11-8-11.8.0-1 \ + cuda-libraries-11-8-11.8.0-1 \ + cuda-libraries-devel-11-8-11.8.0-1 + + ln -s cuda-11.8 /usr/local/cuda + + export CUDA_HOME="/usr/local/cuda" +fi + +if [ "$ACCELERATOR" == "cu124" ]; then + # Install CUDA 12.4 + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-compiler-12-4-12.4.1-1 \ + cuda-libraries-12-4-12.4.1-1 \ + cuda-libraries-devel-12-4-12.4.1-1 + + ln -s cuda-12.4 /usr/local/cuda + + export CUDA_HOME="/usr/local/cuda" +fi + +if [ "$ACCELERATOR" == "hip" ]; then + # Install HIP 6.2 + dnf install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm + dnf install -y rocm-device-libs hip-devel hip-runtime-amd hipcc +fi + +# Configure build with Cmake +mkdir -p build +mkdir -p openmm-install +cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX=openmm-install \ + -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' \ + -DOPENMM_BUILD_OPENCL_LIB=ON \ + -DOPENCL_INCLUDE_DIR=/usr/include/CL \ + -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1 + +# Build OpenMM +make -j4 install +make -j4 PythonInstall + +cd .. + +cp -r build/python/* wrappers/python/ +cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh deleted file mode 100755 index fa154ed944..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cpu.sh +++ /dev/null @@ -1,41 +0,0 @@ -#! /bin/bash - -set -e -set -x - -# Install dependencies with yum -dnf install -y doxygen zip opencl-headers ocl-icd - -# # Install CUDA (nothing) - -# # Install HIP -# export HIP_VERSION=6 -# yum install -y epel-release -# yum install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm -# yum install -y rocm-device-libs hip-devel hip-runtime-amd hipcc - -# Configure build with Cmake -mkdir -p build -mkdir -p openmm-install -cd build -cmake .. \ - -DCMAKE_INSTALL_PREFIX=openmm-install \ - -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' \ - -DOPENMM_BUILD_OPENCL_LIB=ON \ - -DOPENCL_INCLUDE_DIR=/usr/include/CL \ - -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1 - -# Build OpenMM -make -j4 install -make -j4 PythonInstall - -cd .. - -# Build wheel -export LD_LIBRARY_PATH=openmm-install/lib - -cp -r build/python/* wrappers/python/ -cp -r build/openmm-install/include wrappers/python/ -cp -r build/openmm-install/lib wrappers/python/openmm/ - - diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh deleted file mode 100755 index ac32543d6d..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu118.sh +++ /dev/null @@ -1,124 +0,0 @@ -#! /bin/bash - -set -e -set -x - -dnf install -y doxygen - - -if [ "$CIBW_ARCHS" != "aarch64" ]; then - - # Install CUDA 11.8: - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo - - dnf install --setopt=obsoletes=0 -y \ - cuda-nvcc-11-8-11.8.89-1 \ - cuda-cudart-devel-11-8-11.8.89-1 \ - libcurand-devel-11-8-10.3.0.86-1 \ - libcudnn9-devel-cuda-11-9.8.0.87-1 \ - libcublas-devel-11-8-11.11.3.6-1 \ - libnccl-devel-2.15.5-1+cuda11.8 \ - libcusparse-devel-11-8-11.7.5.86-1 \ - libcusolver-devel-11-8-11.4.1.48-1 \ - gcc-toolset-11 - - ln -s cuda-11.8 /usr/local/cuda - ln -s /opt/rh/gcc-toolset-11/root/usr/bin/gcc /usr/local/cuda/bin/gcc - ln -s /opt/rh/gcc-toolset-11/root/usr/bin/g++ /usr/local/cuda/bin/g++ - - export CUDA_HOME="/usr/local/cuda" - export WITH_CUDA=1 - - - # Configure pip to use PyTorch extra-index-url for CUDA 11.8 - mkdir -p $HOME/.config/pip - echo "[global] -extra-index-url = https://download.pytorch.org/whl/cu118" > $HOME/.config/pip/pip.conf - -fi - - -# OpenMM Compilation starting here - -CMAKE_FLAGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release" -if [[ "$with_test_suite" == "true" ]]; then - CMAKE_FLAGS+=" -DBUILD_TESTING=ON -DOPENMM_BUILD_OPENCL_TESTS=ON" -else - CMAKE_FLAGS+=" -DBUILD_TESTING=OFF" -fi - - -if [[ "$target_platform" == linux* ]]; then - SHLIB_EXT=".so" - # CFLAGS - # JRG: Had to add -ldl to prevent linking errors (dlopen, etc) - MINIMAL_CFLAGS+=" -O3 -ldl" - CFLAGS+=" $MINIMAL_CFLAGS" - CXXFLAGS+=" $MINIMAL_CFLAGS" - - # CUDA is enabled in these platforms - if [[ "$target_platform" == linux-64 || "$target_platform" == linux-ppc64le ]]; then - # # CUDA_HOME is defined by nvcc metapackage - CMAKE_FLAGS+=" -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME}" - # CUDA tests won't build, disable for now - # See https://github.com/openmm/openmm/issues/2258#issuecomment-462223634 - CMAKE_FLAGS+=" -DOPENMM_BUILD_CUDA_TESTS=OFF" - # shadow some CMAKE_ARGS bits that interfere with CUDA detection - CMAKE_FLAGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH" - fi - - # OpenCL ICD - CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" - CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" - -elif [[ "$target_platform" == osx* ]]; then - SHLIB_EXT=".dylib" - if [[ "$opencl_impl" == khronos ]]; then - CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" - CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" - fi - # When using opencl_impl == apple, CMake will auto-locate it, so no need to provide the flags - # On Conda Forge, this will result in: - # /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/... - # ...SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenCL.framework - # On local builds, it might be: - # /System/Library/Frameworks/OpenCL.framework/OpenCL -fi - -# Set location for FFTW3 on both linux and mac -CMAKE_FLAGS+=" -DFFTW_INCLUDES=${PREFIX}/include/" -CMAKE_FLAGS+=" -DFFTW_LIBRARY=${PREFIX}/lib/libfftw3f${SHLIB_EXT}" -CMAKE_FLAGS+=" -DFFTW_THREADS_LIBRARY=${PREFIX}/lib/libfftw3f_threads${SHLIB_EXT}" -# Disambiguate swig location -CMAKE_FLAGS+=" -DSWIG_EXECUTABLE=$(which swig)" - -# Build in subdirectory and install. -mkdir -p build -cd build -cmake ${CMAKE_FLAGS} .. -make -j$CPU_COUNT -make -j$CPU_COUNT install PythonInstall - -# Put examples into an appropriate subdirectory. -mkdir -p ${PREFIX}/share/openmm/ -mv ${PREFIX}/examples ${PREFIX}/share/openmm/ - -# Fix some overlinking warnings/errors -for lib in ${PREFIX}/lib/plugins/*${SHLIB_EXT}; do - ln -s $lib ${PREFIX}/lib/$(basename $lib) || true -done - -if [[ "$with_test_suite" == "true" ]]; then - mkdir -p ${PREFIX}/share/openmm/tests/ - # BSD find vs GNU find: -executable is only available in GNU find - # +0111 is somehow equivalent in BSD, but that's not compatible in GNU - # so we use different commands for each... - if [[ "$target_platform" == osx* ]]; then - find . -name "Test*" -perm +0111 -type f \ - -exec python $RECIPE_DIR/patch_osx_tests.py "{}" \; \ - -exec cp "{}" $PREFIX/share/openmm/tests/ \; - else - find . -name "Test*" -executable -type f -exec cp "{}" $PREFIX/share/openmm/tests/ \; - fi - cp -r python/tests $PREFIX/share/openmm/tests/python -fi diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh deleted file mode 100755 index cc9e212c5a..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux_cu124.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/bash - -set -e -set -x - - -if [ "$CIBW_ARCHS" != "aarch64" ]; then - - # Install CUDA 12.4: - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo - - dnf install --setopt=obsoletes=0 -y \ - cuda-nvcc-12-4-12.4.131-1 \ - cuda-cudart-devel-12-4-12.4.127-1 \ - libcurand-devel-12-4-10.3.5.147-1 \ - libcudnn9-devel-cuda-12-9.1.0.70-1 \ - libcublas-devel-12-4-12.4.5.8-1 \ - libnccl-devel-2.21.5-1+cuda12.4 \ - libcusparse-devel-12-4-12.3.1.170-1 \ - libcusolver-devel-12-4-11.6.1.9-1 \ - gcc-toolset-13 - - ln -s cuda-12.4 /usr/local/cuda - ln -s /opt/rh/gcc-toolset-13/root/usr/bin/gcc /usr/local/cuda/bin/gcc - ln -s /opt/rh/gcc-toolset-13/root/usr/bin/g++ /usr/local/cuda/bin/g++ - - export CUDA_HOME="/usr/local/cuda" - export WITH_CUDA=1 - -fi - diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh index e69de29bb2..bc417b6056 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh @@ -0,0 +1,13 @@ +brew install doxygen + +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=openmm-install +make -j4 install +make -j4 PythonInstall + +cd .. + +cp -r build/python/* wrappers/python/ +cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh new file mode 100755 index 0000000000..8d1ef94ec9 --- /dev/null +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -0,0 +1,49 @@ +#! /bin/bash + +set -e +set -x + +if [ "$ACCELERATOR" == "cu118" ]; then + CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe + ./cuda.exe -s nvcc_11.8 nvrtc_11.8 nvrtc_dev_11.8 cudart_11.8 cufft_11.8 cufft_dev_11.8 opencl_11.8 cuda_profiler_api_11.8 + rm cuda.exe +fi + +if [ "$ACCELERATOR" == "cu124" ]; then + CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe + ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 opencl_12.4 cuda_profiler_api_12.4 + rm cuda.exe +fi + +if [ "$ACCELERATOR" == "hip" ]; then + curl.exe --output HIP.exe --url https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe + ./HIP.exe -install + rm HIP.exe +fi + +# Configure build with Cmake +mkdir -p build +mkdir -p openmm-install +cd build +cmake -G "NMake Makefiles JOM" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=openmm-install \ + -DCMAKE_PREFIX_PATH="openmm-install;C:\Program Files\AMD\ROCm\6.1" \ + -DCMAKE_CXX_COMPILER=cl.exe \ + -DCMAKE_C_COMPILER=cl.exe \ + -DOPENCL_INCLUDE_DIR="${CUDA_ROOT}/include" \ + -DOPENCL_LIBRARY="${CUDA_ROOT}/lib/x64/OpenCL.lib" \ + -DHIP_PLATFORM=amd \ + .. + +# Build OpenMM +make -j4 install +make -j4 PythonInstall + +cd .. + +cp -r build/python/* wrappers/python/ +cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh deleted file mode 100755 index 1785227133..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cpu.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Create pip directory if it doesn't exist -mkdir -p "C:\ProgramData\pip" - -# Create pip.ini file with PyTorch CPU index -echo "[global] -extra-index-url = https://download.pytorch.org/whl/cpu" > "C:\ProgramData\pip\pip.ini" diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh deleted file mode 100755 index 3bf768f08d..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu118.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash - -set -e -set -x - -CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe -./cuda.exe -s nvcc_11.8 cudart_11.8 cublas_dev_11.8 curand_dev_11.8 cusparse_dev_11.8 cusolver_dev_11.8 thrust_11.8 -rm cuda.exe - -export WITH_CUDA=1 -export CUDA_HOME="$CUDA_ROOT" - -# Create pip directory if it doesn't exist -mkdir -p "C:\ProgramData\pip" - -# Create pip.ini file with PyTorch CUDA 11.8 index -echo "[global] -extra-index-url = https://download.pytorch.org/whl/cu118" > "C:\ProgramData\pip\pip.ini" \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh deleted file mode 100755 index 7b441f93e0..0000000000 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows_cu124.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash - -set -e -set -x - -CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" -curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe -./cuda.exe -s nvcc_12.4 cudart_12.4 cublas_dev_12.4 curand_dev_12.4 cusparse_dev_12.4 cusolver_dev_12.4 -rm cuda.exe - -export WITH_CUDA=1 -export CUDA_HOME="$CUDA_ROOT" - -# Create pip directory if it doesn't exist -mkdir -p "C:\ProgramData\pip" - -# Create pip.ini file with PyTorch CUDA 12.4 index -echo "[global] -extra-index-url = https://download.pytorch.org/whl/cu124" > "C:\ProgramData\pip\pip.ini" \ No newline at end of file diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 80b40ac56e..fe667e338a 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -39,8 +39,8 @@ test-requires = ["pytest"] test-command = "cd {project}/wrappers/python/tests; pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -environment-pass = ["CIBW_ARCHS"] -# container-engine = "docker; create_args: --gpus all" +environment-pass = ["ACCELERATOR"] +container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.linux] repair-wheel-command = [ From f097d519065b3beb526b7c35c1d4efc7c30de7ec Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:29:36 +0300 Subject: [PATCH 05/75] wront path --- .github/workflows/publish.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4a81d3f51c..021bc4a371 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,10 +19,14 @@ jobs: accelerator: cu118 - os: ubuntu-24.04-arm accelerator: cu124 + - os: ubuntu-24.04-arm + accelerator: hip - os: macos-latest accelerator: cu118 - os: macos-latest accelerator: cu124 + - os: macos-latest + accelerator: hip steps: - name: Free space of Github Runner (otherwise it will fail by running out of disk) @@ -52,11 +56,7 @@ jobs: - name: Build wheels if: matrix.os != 'windows-2019' shell: bash -l {0} - run: | - if [[ "${{ runner.os }}" == "Linux" ]]; then - export CIBW_ARCHS="${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'auto64' }}" - fi - python -m cibuildwheel --output-dir wheelhouse + run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" @@ -67,7 +67,7 @@ jobs: - name: Build wheels if: matrix.os == 'windows-2019' shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables - run: python -m cibuildwheel --output-dir wheelhouse + run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building From e76d87be990484510dd58993ea041149d64e73f3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:46:00 +0300 Subject: [PATCH 06/75] fixes --- .github/workflows/publish.yml | 10 +++++++++- .../prepare_build_environment_osx.sh | 2 +- .../prepare_build_environment_windows.sh | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 021bc4a371..51d5731fbd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ on: jobs: build: - name: Build wheels on ${{ matrix.os }}-${{ matrix.cuda }} + name: Build wheels on ${{ matrix.os }}-${{ matrix.accelerator }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -53,6 +53,14 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 if: matrix.os == 'windows-2019' + - name: "Install OpenCL" + uses: Jimver/cuda-toolkit@v0.2.16 + if: matrix.os == 'windows-2019' + id: cuda-toolkit + with: + method: "network" + sub-packages: '["opencl"]' + - name: Build wheels if: matrix.os != 'windows-2019' shell: bash -l {0} diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh index bc417b6056..6053766898 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh @@ -1,4 +1,4 @@ -brew install doxygen +brew install doxygen swig mkdir build cd build diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 8d1ef94ec9..50822cc02d 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -6,14 +6,14 @@ set -x if [ "$ACCELERATOR" == "cu118" ]; then CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe - ./cuda.exe -s nvcc_11.8 nvrtc_11.8 nvrtc_dev_11.8 cudart_11.8 cufft_11.8 cufft_dev_11.8 opencl_11.8 cuda_profiler_api_11.8 + ./cuda.exe -s nvcc_11.8 nvrtc_11.8 nvrtc_dev_11.8 cudart_11.8 cufft_11.8 cufft_dev_11.8 cuda_profiler_api_11.8 rm cuda.exe fi if [ "$ACCELERATOR" == "cu124" ]; then CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe - ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 opencl_12.4 cuda_profiler_api_12.4 + ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 cuda_profiler_api_12.4 rm cuda.exe fi From a886cabae8da35d7a20ae66706d88c7e38157b68 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:51:13 +0300 Subject: [PATCH 07/75] ignore missing deps on OSX --- wrappers/python/pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index fe667e338a..75d4cfa245 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -47,7 +47,7 @@ repair-wheel-command = [ "auditwheel repair --exclude libOpenMM.so --exclude libOpenMMCUDA.so --exclude libOpenMMHIP.so --exclude libOpenMMOpenCL.so --exclude libOpenMMDrude.so --exclude libOpenMMAmoeba.so --exclude libOpenMMRPMD.so --exclude libOpenCL.so.1 --exclude libcuda.so.1 --exclude libcufft.so.11 --exclude libcufft.so.10 --exclude libnvrtc.so.11.2 --exclude libnvrtc.so.12 --exclude libhiprtc.so.6 --exclude libamdhip64.so.6 -w {dest_dir} {wheel}", ] -# [tool.cibuildwheel.macos] -# repair-wheel-command = [ -# "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}", -# ] \ No newline at end of file +[tool.cibuildwheel.macos] +repair-wheel-command = [ + "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}", +] \ No newline at end of file From 28f6353483fabf475477c87d896f4e08d9c0ebba Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:55:03 +0300 Subject: [PATCH 08/75] jom for Windows --- .github/workflows/publish.yml | 6 ++++++ .../prepare_build_environment_windows.sh | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 51d5731fbd..7e25897c26 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -61,6 +61,12 @@ jobs: method: "network" sub-packages: '["opencl"]' + - name: "Install dependencies with choco" + uses: crazy-max/ghaction-chocolatey@v3 + if: matrix.os == 'windows-2019' + with: + args: install doxygen.install jom + - name: Build wheels if: matrix.os != 'windows-2019' shell: bash -l {0} diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 50822cc02d..53b244e2c6 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -39,8 +39,8 @@ cmake -G "NMake Makefiles JOM" \ .. # Build OpenMM -make -j4 install -make -j4 PythonInstall +jom -j 4 install +jom -j 4 PythonInstall cd .. From cde2efa474236c67dff5fffb08b2178e92c7a2c6 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 16:58:44 +0300 Subject: [PATCH 09/75] no gpus on CI --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 75d4cfa245..44b00b537c 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -40,7 +40,7 @@ test-command = "cd {project}/wrappers/python/tests; pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" environment-pass = ["ACCELERATOR"] -container-engine = "docker; create_args: --gpus all" +# container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.linux] repair-wheel-command = [ From 2918023b5b464f9fc0ceb918708d7fc29243a481 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:14:52 +0300 Subject: [PATCH 10/75] include the includes. continue on error for OSX --- wrappers/python/MANIFEST.in | 2 +- .../prepare_build_environment_linux.sh | 2 +- .../cibuildwheel_support/prepare_build_environment_osx.sh | 7 ++++++- .../prepare_build_environment_windows.sh | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wrappers/python/MANIFEST.in b/wrappers/python/MANIFEST.in index a97adf6cbc..12cc448ab9 100644 --- a/wrappers/python/MANIFEST.in +++ b/wrappers/python/MANIFEST.in @@ -9,4 +9,4 @@ prune src/swig_doxygen/doxygen/html prune src/swig_doxygen/doxygen/xml global-exclude CMakeLists.txt graft openmm/lib -prune include \ No newline at end of file +graft openmm/include \ No newline at end of file diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index c7ba69faf3..260044592f 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -58,5 +58,5 @@ make -j4 PythonInstall cd .. cp -r build/python/* wrappers/python/ -cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh index 6053766898..f527c3dc24 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh @@ -1,3 +1,8 @@ +#! /bin/bash + +set -e +set -x + brew install doxygen swig mkdir build @@ -9,5 +14,5 @@ make -j4 PythonInstall cd .. cp -r build/python/* wrappers/python/ -cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 53b244e2c6..864e35ac9b 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -45,5 +45,5 @@ jom -j 4 PythonInstall cd .. cp -r build/python/* wrappers/python/ -cp -r build/openmm-install/include wrappers/python/ +cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ From 88f6ea516cf248d841e28c49532b30545a79cfee Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:17:50 +0300 Subject: [PATCH 11/75] fix windows opencl path --- .github/workflows/publish.yml | 1 + .../cibuildwheel_support/prepare_build_environment_windows.sh | 4 ++-- wrappers/python/pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7e25897c26..264170d772 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -88,6 +88,7 @@ jobs: CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} CIBW_BUILD: "cp310-*" + OPENCL_PATH: "${{steps.cuda-toolkit.outputs.CUDA_PATH}}" - uses: actions/upload-artifact@v4 with: diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 864e35ac9b..714ec53cff 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -33,8 +33,8 @@ cmake -G "NMake Makefiles JOM" \ -DCMAKE_PREFIX_PATH="openmm-install;C:\Program Files\AMD\ROCm\6.1" \ -DCMAKE_CXX_COMPILER=cl.exe \ -DCMAKE_C_COMPILER=cl.exe \ - -DOPENCL_INCLUDE_DIR="${CUDA_ROOT}/include" \ - -DOPENCL_LIBRARY="${CUDA_ROOT}/lib/x64/OpenCL.lib" \ + -DOPENCL_INCLUDE_DIR="${OPENCL_PATH}/include" \ + -DOPENCL_LIBRARY="${OPENCL_PATH}/lib/x64/OpenCL.lib" \ -DHIP_PLATFORM=amd \ .. diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 44b00b537c..8312e5b2b8 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -39,7 +39,7 @@ test-requires = ["pytest"] test-command = "cd {project}/wrappers/python/tests; pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -environment-pass = ["ACCELERATOR"] +environment-pass = ["ACCELERATOR", "OPENCL_PATH"] # container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.linux] From 00ef6e1c2c1c98243cd0a7ff506c174412c392c3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:26:19 +0300 Subject: [PATCH 12/75] forgot one path --- wrappers/python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index f1409d5471..8b0de0e3bd 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -160,7 +160,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, libraries[ii]="%s_d" % libraries[ii] sys.stdout.write("%s\n" % libraries[ii]) - openmm_include_path = 'include' + openmm_include_path = 'openmm/include' openmm_lib_path = 'openmm/lib' extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'] From 11a5de8648dfc06f5a704982a5193a904bc47b4b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:35:20 +0300 Subject: [PATCH 13/75] fix OSX rpath --- wrappers/python/setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 8b0de0e3bd..e28494cfa6 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -91,7 +91,6 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION full_version = '%(full_version)s' git_revision = '%(git_revision)s' release = %(isrelease)s -openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "lib")) if not release: version = full_version @@ -119,8 +118,7 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION a.write(cnt % {'version': version, 'full_version' : full_version, 'git_revision' : git_revision, - 'isrelease': str(IS_RELEASED), - 'path': os.getenv('OPENMM_LIB_PATH')}) + 'isrelease': str(IS_RELEASED)}) def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, @@ -174,7 +172,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, extra_link_args += ['-Wl,-rpath,$ORIGIN/lib'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] - extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', openmm_lib_path] + extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', f'@loader_path/{openmm_lib_path}'] if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ and platform.processor() != 'arm': extra_compile_args += ['-mmacosx-version-min=10.7'] extra_link_args += ['-mmacosx-version-min=10.7'] From ec96e89d59061731ad4ee77aaf286e89a1054f35 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:49:52 +0300 Subject: [PATCH 14/75] fixes for windows and osx --- wrappers/python/pyproject.toml | 5 ++++- wrappers/python/setup.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 8312e5b2b8..6dc30b944b 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -36,12 +36,15 @@ build-backend = "setuptools.build_meta" [tool.cibuildwheel] skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] -test-command = "cd {project}/wrappers/python/tests; pytest ." +test-command = "cd {project}/wrappers/python/tests && pytest ." manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" environment-pass = ["ACCELERATOR", "OPENCL_PATH"] # container-engine = "docker; create_args: --gpus all" +[tool.cibuildwheel.windows] +test-command = "cd {project}\\wrappers\\python\\tests && pytest ." + [tool.cibuildwheel.linux] repair-wheel-command = [ "auditwheel repair --exclude libOpenMM.so --exclude libOpenMMCUDA.so --exclude libOpenMMHIP.so --exclude libOpenMMOpenCL.so --exclude libOpenMMDrude.so --exclude libOpenMMAmoeba.so --exclude libOpenMMRPMD.so --exclude libOpenCL.so.1 --exclude libcuda.so.1 --exclude libcufft.so.11 --exclude libcufft.so.10 --exclude libnvrtc.so.11.2 --exclude libnvrtc.so.12 --exclude libhiprtc.so.6 --exclude libamdhip64.so.6 -w {dest_dir} {wheel}", diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index e28494cfa6..3946c292a6 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -169,7 +169,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, define_macros.append( (' _MSC_VER', None) ) extra_compile_args.append('/EHsc') else: - extra_link_args += ['-Wl,-rpath,$ORIGIN/lib'] + extra_link_args += ['-Wl'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', f'@loader_path/{openmm_lib_path}'] From 22cd17faf5574647c2f87f1affb73e319ab16ed9 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:56:03 +0300 Subject: [PATCH 15/75] osx fix --- wrappers/python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 3946c292a6..b4297eef71 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -172,7 +172,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, extra_link_args += ['-Wl'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] - extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', f'@loader_path/{openmm_lib_path}'] + extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', '@loader_path/lib'] if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ and platform.processor() != 'arm': extra_compile_args += ['-mmacosx-version-min=10.7'] extra_link_args += ['-mmacosx-version-min=10.7'] From 93290a25f13a5ad9fabd619b85a0fb733881e7dd Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 17:57:36 +0300 Subject: [PATCH 16/75] cleanup --- wrappers/python/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index b4297eef71..1440c76854 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -169,7 +169,6 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, define_macros.append( (' _MSC_VER', None) ) extra_compile_args.append('/EHsc') else: - extra_link_args += ['-Wl'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', '@loader_path/lib'] From 91d1e4da669f63517bda43c65f20d5be9b506919 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 18:07:55 +0300 Subject: [PATCH 17/75] rpath for linux --- wrappers/python/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 1440c76854..669303cd66 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -169,6 +169,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, define_macros.append( (' _MSC_VER', None) ) extra_compile_args.append('/EHsc') else: + extra_link_args += ['-Wl,-rpath,$ORIGIN/lib'] if platform.system() == 'Darwin': extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++', '-Wl', '-rpath', '@loader_path/lib'] From 0cd5007a268974d30ef8187e31b917765e01f450 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 19:14:35 +0300 Subject: [PATCH 18/75] test file paths relative to the test folder --- wrappers/python/tests/TestAmberInpcrdFile.py | 15 ++- wrappers/python/tests/TestAmberPrmtopFile.py | 38 +++--- wrappers/python/tests/TestCharmmFiles.py | 125 +++++++++--------- .../python/tests/TestCheckpointReporter.py | 6 +- wrappers/python/tests/TestDcdFile.py | 10 +- wrappers/python/tests/TestDesmondDMSFile.py | 10 +- wrappers/python/tests/TestForceField.py | 50 +++---- wrappers/python/tests/TestGenerators.py | 4 +- wrappers/python/tests/TestGromacsGroFile.py | 5 +- wrappers/python/tests/TestGromacsTopFile.py | 32 +++-- wrappers/python/tests/TestIntegrators.py | 18 ++- wrappers/python/tests/TestModeller.py | 22 +-- .../python/tests/TestNumpyCompatibility.py | 5 +- wrappers/python/tests/TestPdbFile.py | 16 ++- wrappers/python/tests/TestPdbReporter.py | 11 +- wrappers/python/tests/TestPdbxFile.py | 21 +-- wrappers/python/tests/TestPickle.py | 8 +- wrappers/python/tests/TestSimulation.py | 18 ++- .../python/tests/TestStateDataReporter.py | 3 +- wrappers/python/tests/TestTopology.py | 6 +- wrappers/python/tests/TestXtcFile.py | 17 ++- 21 files changed, 253 insertions(+), 187 deletions(-) diff --git a/wrappers/python/tests/TestAmberInpcrdFile.py b/wrappers/python/tests/TestAmberInpcrdFile.py index c93d3687e6..a1aa863964 100644 --- a/wrappers/python/tests/TestAmberInpcrdFile.py +++ b/wrappers/python/tests/TestAmberInpcrdFile.py @@ -1,3 +1,4 @@ +import os import unittest from validateConstraints import * from openmm.app import * @@ -15,13 +16,15 @@ def compareByElement(array1, array2, cmp): cmp(x, y) +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestAmberInpcrdFile(unittest.TestCase): """Test the Amber inpcrd file parser""" def test_CrdVelBox(self): """ Test parsing ASCII restarts with crds, vels, and box """ cmp = self.assertAlmostEqual - inpcrd = AmberInpcrdFile('systems/crds_vels_box.rst7') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_vels_box.rst7')) self.assertEqual(len(inpcrd.positions), 2101) compareByElement(inpcrd.positions[-1].value_in_unit(angstroms), [3.5958082, 8.4176792, -8.2954064], cmp) @@ -35,7 +38,7 @@ def test_NetCDF(self): """ Test NetCDF restart file parsing """ cmp = self.assertAlmostEqual - inpcrd = AmberInpcrdFile('systems/amber.ncrst') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'amber.ncrst')) self.assertEqual(len(inpcrd.positions), 2101) compareByElement(inpcrd.positions[0].value_in_unit(angstroms), [6.82122492718229, 6.6276250662042, -8.51668999892245], @@ -48,24 +51,24 @@ def test_NetCDF(self): def test_CrdBox(self): """ Test parsing ASCII restarts with only crds and box """ - inpcrd = AmberInpcrdFile('systems/crds_box.rst7') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_box.rst7')) self.assertEqual(len(inpcrd.positions), 18660) self.assertTrue(inpcrd.velocities is None) self.assertTrue(inpcrd.boxVectors is not None) def test_CrdVel(self): - inpcrd = AmberInpcrdFile('systems/crds_vels.rst7') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_vels.rst7')) self.assertTrue(inpcrd.boxVectors is None) self.assertTrue(inpcrd.velocities is not None) def test_CrdOnly(self): - inpcrd = AmberInpcrdFile('systems/crdsonly.rst7') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crdsonly.rst7')) self.assertTrue(inpcrd.boxVectors is None) self.assertTrue(inpcrd.velocities is None) def test_CrdBoxTruncoct(self): # Check that the box vectors come out correct. - inpcrd = AmberInpcrdFile('systems/tz2.truncoct.rst7') + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'tz2.truncoct.rst7')) ac = Vec3(42.4388485, 0.0, 0.0) * angstroms bc = Vec3(-14.146281691908937, 40.011730483685835, 0.0) * angstroms cc = Vec3(-14.146281691908937, -20.0058628205162, 34.651176446201672) * angstroms diff --git a/wrappers/python/tests/TestAmberPrmtopFile.py b/wrappers/python/tests/TestAmberPrmtopFile.py index 5f8678542d..4e9e769bc5 100644 --- a/wrappers/python/tests/TestAmberPrmtopFile.py +++ b/wrappers/python/tests/TestAmberPrmtopFile.py @@ -7,17 +7,19 @@ from openmm.unit import * import openmm.app.element as elem -inpcrd1 = AmberInpcrdFile('systems/alanine-dipeptide-explicit.inpcrd') -inpcrd3 = AmberInpcrdFile('systems/ff14ipq.rst7') -inpcrd4 = AmberInpcrdFile('systems/Mg_water.inpcrd') -inpcrd7 = AmberInpcrdFile('systems/18protein.rst7') -prmtop1 = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop') -prmtop2 = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop') -prmtop3 = AmberPrmtopFile('systems/ff14ipq.parm7', periodicBoxVectors=inpcrd3.boxVectors) -prmtop4 = AmberPrmtopFile('systems/Mg_water.prmtop', periodicBoxVectors=inpcrd4.boxVectors) -prmtop5 = AmberPrmtopFile('systems/tz2.truncoct.parm7') -prmtop6 = AmberPrmtopFile('systems/gaffwat.parm7') -prmtop7 = AmberPrmtopFile('systems/18protein.parm7', periodicBoxVectors=inpcrd7.boxVectors) +curr_dir = os.path.dirname(os.path.abspath(__file__)) + +inpcrd1 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.inpcrd')) +inpcrd3 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'ff14ipq.rst7')) +inpcrd4 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'Mg_water.inpcrd')) +inpcrd7 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', '18protein.rst7')) +prmtop1 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.prmtop')) +prmtop2 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.prmtop')) +prmtop3 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'ff14ipq.parm7'), periodicBoxVectors=inpcrd3.boxVectors) +prmtop4 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'Mg_water.prmtop'), periodicBoxVectors=inpcrd4.boxVectors) +prmtop5 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'tz2.truncoct.parm7')) +prmtop6 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'gaffwat.parm7')) +prmtop7 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', '18protein.parm7'), periodicBoxVectors=inpcrd7.boxVectors) class TestAmberPrmtopFile(unittest.TestCase): @@ -307,14 +309,14 @@ def test_ImplicitSolventForces(self): nonbondedMethod = [NoCutoff, CutoffNonPeriodic, CutoffNonPeriodic, NoCutoff, NoCutoff] salt = [0.0, 0.0, 0.5, 0.5, 0.0]*(moles/liter) file = ['HCT_NoCutoff', 'OBC1_NonPeriodic', 'OBC2_NonPeriodic_Salt', 'GBn_NoCutoff_Salt', 'GBn2_NoCutoff'] - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) for i in range(5): system = prmtop2.createSystem(implicitSolvent=solventType[i], nonbondedMethod=nonbondedMethod[i], implicitSolventSaltConc=salt[i]) integrator = VerletIntegrator(0.001) context = Context(system, integrator, Platform.getPlatform("Reference")) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml') as infile: + with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit-forces', file[i]+'.xml')) as infile: state2 = XmlSerializer.deserialize(infile.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -375,8 +377,8 @@ def test_with_dcd_reporter(self): def testChamber(self): """Test a prmtop file created with Chamber.""" - prmtop = AmberPrmtopFile('systems/ala3_solv.parm7') - crd = CharmmCrdFile('systems/ala3_solv.crd') + prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'ala3_solv.parm7')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) system = prmtop.createSystem() for i,f in enumerate(system.getForces()): f.setForceGroup(i) @@ -414,8 +416,8 @@ def testGBneckRadii(self): def testNucleicGBParametes(self): """Test that correct GB parameters are used for nucleic acids.""" - prmtop = AmberPrmtopFile('systems/DNA_mbondi3.prmtop') - inpcrd = AmberInpcrdFile('systems/DNA_mbondi3.inpcrd') + prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'DNA_mbondi3.prmtop')) + inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'DNA_mbondi3.inpcrd')) sanderEnergy = [-19223.87993545, -19527.40433175, -19788.1070698] for solvent, expectedEnergy in zip([OBC2, GBn, GBn2], sanderEnergy): system = prmtop.createSystem(implicitSolvent=solvent, gbsaModel=None) @@ -456,7 +458,7 @@ def testAmberCMAP(self): def testEPConstraints(self): """Test different types of constraints when using extra particles""" - prmtop = AmberPrmtopFile('systems/peptide_with_tip4p.prmtop') + prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'peptide_with_tip4p.prmtop')) for constraints in (HBonds, AllBonds): system = prmtop.createSystem(constraints=constraints) integrator = VerletIntegrator(0.001*picoseconds) diff --git a/wrappers/python/tests/TestCharmmFiles.py b/wrappers/python/tests/TestCharmmFiles.py index 7ac43e13a4..a66943a13c 100644 --- a/wrappers/python/tests/TestCharmmFiles.py +++ b/wrappers/python/tests/TestCharmmFiles.py @@ -14,6 +14,9 @@ else: from cStringIO import StringIO + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestCharmmFiles(unittest.TestCase): """Test the GromacsTopFile.createSystem() method.""" @@ -22,12 +25,13 @@ def setUp(self): """Set up the tests by loading the input files.""" # alanine tripeptide; no waters - self.psf_c = CharmmPsfFile('systems/ala_ala_ala.psf') - self.psf_x = CharmmPsfFile('systems/ala_ala_ala.xpsf') - self.psf_v = CharmmPsfFile('systems/ala_ala_ala.vpsf') + self.psf_c = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.psf')) + self.psf_x = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.xpsf')) + self.psf_v = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.vpsf')) self.params = CharmmParameterSet( - 'systems/charmm22.rtf', 'systems/charmm22.par') - self.pdb = PDBFile('systems/ala_ala_ala.pdb') + os.path.join(curr_dir, 'systems', 'charmm22.rtf'), + os.path.join(curr_dir, 'systems', 'charmm22.par')) + self.pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) def test_NonbondedMethod(self): """Test both non-periodic methods for the systems""" @@ -103,9 +107,9 @@ def test_HydrogenMass(self): def test_DrudeMass(self): """Test that setting the mass of Drude particles works correctly.""" - psf = CharmmPsfFile('systems/ala3_solv_drude.psf') - crd = CharmmCrdFile('systems/ala3_solv_drude.crd') - params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) system = psf.createSystem(params, drudeMass=0) trueMass = [system.getParticleMass(i) for i in range(system.getNumParticles())] drudeMass = 0.3*amu @@ -130,10 +134,10 @@ def test_DrudeMass(self): def test_NBFIX(self): """Tests CHARMM systems with NBFIX Lennard-Jones modifications""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ala3_solv.psf', unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500)*angstroms) - crd = CharmmCrdFile('systems/ala3_solv.crd') - params = CharmmParameterSet('systems/par_all36_prot.prm', - 'systems/toppar_water_ions.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500)*angstroms) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), + os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) # Turn off charges so we only test the Lennard-Jones energies for a in psf.atom_list: @@ -154,9 +158,11 @@ def test_NBFIX(self): def test_NBFIX14(self): """Tests CHARMM systems with NBFIX modifications to 1-4 interactions""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/chl1.psf') - crd = CharmmCrdFile('systems/chl1.crd') - params = CharmmParameterSet('systems/par_all36_lipid.prm', 'systems/par_all36_cgenff.prm', 'systems/toppar_all36_lipid_cholesterol.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'chl1.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'chl1.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_lipid.prm'), + os.path.join(curr_dir, 'systems', 'par_all36_cgenff.prm'), + os.path.join(curr_dir, 'systems', 'toppar_all36_lipid_cholesterol.str')) # Turn off charges so we only test the Lennard-Jones energies for a in psf.atom_list: @@ -178,9 +184,10 @@ def test_NBFIX14(self): def test_NBThole(self): """Tests CHARMM system with NBTHole""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/cyt-gua-cyt.psf') - crd = CharmmCrdFile('systems/cyt-gua-cyt.crd') - params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str','systems/toppar_drude_nucleic_acid_2017b.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'cyt-gua-cyt.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'cyt-gua-cyt.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str'), + os.path.join(curr_dir, 'systems', 'toppar_drude_nucleic_acid_2017b.str')) # Box dimensions (cubic box) psf.setBox(30.0*angstroms, 30.0*angstroms, 30.0*angstroms) @@ -197,7 +204,7 @@ def test_NBThole(self): def test_PSFSetUnitCellDimensions(self): """Test that setting the box via unit cell dimensions works correctly.""" - psf = CharmmPsfFile('systems/ala3_solv_drude.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) # Orthorhombic psf.setBox(2.1*nanometer, 2.3*nanometer, 2.4*nanometer) @@ -228,9 +235,9 @@ def test_PSFSetUnitCellDimensions(self): def test_Drude(self): """Test CHARMM systems with Drude force field""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ala3_solv_drude.psf') - crd = CharmmCrdFile('systems/ala3_solv_drude.crd') - params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) # Box dimensions (cubic box) psf.setBox(33.2*angstroms, 33.2*angstroms, 33.2*angstroms) @@ -248,10 +255,10 @@ def test_Drude(self): def test_Lonepair(self): """Test the lonepair facilities, in particular the colinear type of lonepairs""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/chlb_cgenff.psf') - crd = CharmmCrdFile('systems/chlb_cgenff.crd') - params = CharmmParameterSet('systems/top_all36_cgenff.rtf', - 'systems/par_all36_cgenff.prm') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'chlb_cgenff.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'chlb_cgenff.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'top_all36_cgenff.rtf'), + os.path.join(curr_dir, 'systems', 'par_all36_cgenff.prm')) plat = Platform.getPlatform('Reference') system = psf.createSystem(params) con = Context(system, VerletIntegrator(2*femtoseconds), plat) @@ -270,7 +277,7 @@ def test_Lonepair(self): def test_InsCode(self): """ Test the parsing of PSF files that contain insertion codes in their residue numbers """ - psf = CharmmPsfFile('systems/4TVP-dmj_wat-ion.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', '4TVP-dmj_wat-ion.psf')) self.assertEqual(len(list(psf.topology.atoms())), 66264) self.assertEqual(len(list(psf.topology.residues())), 20169) self.assertEqual(len(list(psf.topology.bonds())), 46634) @@ -278,11 +285,11 @@ def test_InsCode(self): def testSystemOptions(self): """ Test various options in CharmmPsfFile.createSystem """ warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ala3_solv.psf', + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), periodicBoxVectors=(Vec3(32.7119500, 0, 0)*angstroms, Vec3(0, 32.9959600, 0)*angstroms, Vec3(0, 0, 33.0071500)*angstroms)) - crd = CharmmCrdFile('systems/ala3_solv.crd') - params = CharmmParameterSet('systems/par_all36_prot.prm', - 'systems/toppar_water_ions.str') + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), + os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) # Check some illegal options self.assertRaises(ValueError, lambda: @@ -314,10 +321,10 @@ def test_ImplicitSolventForces(self): context = Context(system, integrator, Platform.getPlatform("Reference")) context.setPositions(self.pdb.positions) state1 = context.getState(getForces=True) - #out = open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml', 'w') + #out = open(os.path.join(curr_dir, 'systems', 'ala-ala-ala-implicit-forces', file[i]+'.xml'), 'w') #out.write(XmlSerializer.serialize(state1)) #out.close() - with open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml') as xml: + with open(os.path.join(curr_dir, 'systems', 'ala-ala-ala-implicit-forces', file[i]+'.xml')) as xml: state2 = XmlSerializer.deserialize(xml.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -326,11 +333,11 @@ def test_ImplicitSolventForces(self): def test_PermissiveRead(self): """Compare permissive and strict reading of Charmm parameters""" - psf = CharmmPsfFile('systems/5dhfr_cube.psf') - pdb = PDBFile('systems/5dhfr_cube.pdb') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', '5dhfr_cube.psf')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', '5dhfr_cube.pdb')) - params_strict = CharmmParameterSet('systems/par_all22_prot_with_mass.inp') - params_permissive = CharmmParameterSet('systems/par_all22_prot.inp', permissive=True) + params_strict = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all22_prot_with_mass.inp')) + params_permissive = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all22_prot.inp'), permissive=True) # Box dimensions (found from bounding box) psf.setBox(62.23*angstroms, 62.23*angstroms, 62.23*angstroms) @@ -361,7 +368,7 @@ def test_PermissiveRead(self): def test_Impropers(self): """Test CHARMM improper torsions.""" - psf = CharmmPsfFile('systems/improper.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'improper.psf')) system = psf.createSystem(self.params) force = [f for f in system.getForces() if isinstance(f, CustomTorsionForce)][0] group = force.getForceGroup() @@ -508,7 +515,7 @@ def test_Residues(self): hoh = ["O", "H1", "H2"] pot = ["POT"] cla = ["CLA"] - psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) for residue in psf.topology.residues(): atoms = [atom.name for atom in residue.atoms()] if residue.name == "M14": @@ -525,11 +532,11 @@ def test_Residues(self): def test_NoLongRangeCorrection(self): """Test that long range correction is disabled.""" parameters = CharmmParameterSet( - 'systems/charmm-solvated/envi.str', - 'systems/charmm-solvated/m14.rtf', - 'systems/charmm-solvated/m14.prm' + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'envi.str'), + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.rtf'), + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.prm') ) - psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) psf.setBox(3.0584*nanometers,3.0584*nanometers,3.0584*nanometers) system = psf.createSystem(parameters, nonbondedMethod=PME) for force in system.getForces(): @@ -541,20 +548,20 @@ def test_NoLongRangeCorrection(self): def test_NoPsfWarning(self): """Test that PSF warning is not thrown.""" parameters = CharmmParameterSet( - 'systems/charmm-solvated/envi.str', - 'systems/charmm-solvated/m14.rtf', - 'systems/charmm-solvated/m14.prm' + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'envi.str'), + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.rtf'), + os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.prm') ) with warnings.catch_warnings(): warnings.simplefilter("error", CharmmPSFWarning) - psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) psf.setBox(3.0584*nanometers,3.0584*nanometers,3.0584*nanometers) psf.createSystem(parameters, nonbondedMethod=PME) def test_NBXMod(self): """Test that all values of NBXMod are interpreted correctly.""" - crd = CharmmCrdFile('systems/ala_ala_ala.crd') - with open('systems/charmm22.par') as parfile: + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.crd')) + with open(os.path.join(curr_dir, 'systems', 'charmm22.par')) as parfile: par = parfile.read() # The following values were computed with CHARMM. modeEnergy = {0: 754318.20507, 1: 754318.20507, 2: 908.35224, 3: 59.65279, 4: -241.12856, 5: 39.13169} @@ -562,7 +569,7 @@ def test_NBXMod(self): with tempfile.NamedTemporaryFile(suffix='.par', mode='w', delete=False) as parfile: parfile.write(par.replace('nbxmod 5', 'nbxmod %d' % nbxmod)) parfile.close() - params = CharmmParameterSet('systems/charmm22.rtf', parfile.name) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'charmm22.rtf'), parfile.name) os.remove(parfile.name) system = self.psf_c.createSystem(params, nonbondedMethod=NoCutoff) context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) @@ -572,9 +579,9 @@ def test_NBXMod(self): def test_Nonbonded_Exclusion(self): """Test that the 1-2, 1-3 and 1-4 pairs are correctly excluded or scaled.""" - psf = CharmmPsfFile('systems/MoS2.psf') - pdb = PDBFile('systems/MoS2.pdb') - params = CharmmParameterSet('systems/MoS2.prm') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'MoS2.psf')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'MoS2.pdb')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'MoS2.prm')) system = psf.createSystem(params, nonbondedMethod=NoCutoff) context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) context.setPositions(pdb.positions) @@ -584,8 +591,8 @@ def test_Nonbonded_Exclusion(self): def test_Constraints(self): """Test that bond and angles constraints are correctly added into the system""" - psf = CharmmPsfFile('systems/water_methanol.psf') - params = CharmmParameterSet('systems/water_methanol.prm') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'water_methanol.psf')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'water_methanol.prm')) # the system is made of one water molecule and one methanol molecule hBonds_water = [[0, 1], [1, 2]] hAngles_water = [[0, 2]] @@ -619,11 +626,11 @@ def test_Constraints(self): def test_Constraints_charmm(self): """Tests that CHARMM and OpenMM implementation of CHARMM force field produce the same constraints and energy""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ala3_solv.psf', + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500) * angstroms) - crd = CharmmCrdFile('systems/ala3_solv.crd') - params = CharmmParameterSet('systems/par_all36_prot.prm', - 'systems/toppar_water_ions.str') + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), + os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) plat = Platform.getPlatform('Reference') system_charmm = psf.createSystem(params, nonbondedMethod=PME, nonbondedCutoff=8 * angstroms) diff --git a/wrappers/python/tests/TestCheckpointReporter.py b/wrappers/python/tests/TestCheckpointReporter.py index aac1e35582..7a4d35b2d4 100644 --- a/wrappers/python/tests/TestCheckpointReporter.py +++ b/wrappers/python/tests/TestCheckpointReporter.py @@ -5,12 +5,14 @@ import openmm as mm from openmm import unit +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestCheckpointReporter(unittest.TestCase): def setUp(self): - with open('systems/alanine-dipeptide-implicit.pdb') as f: + with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) as f: pdb = app.PDBFile(f) - forcefield = app.ForceField('amber99sbildn.xml') + forcefield = app.ForceField(os.path.join(curr_dir, 'systems', 'amber99sbildn.xml')) system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, nonbondedCutoff=1.0*unit.nanometers, constraints=app.HBonds) diff --git a/wrappers/python/tests/TestDcdFile.py b/wrappers/python/tests/TestDcdFile.py index 048da3af73..42e8d19b0d 100644 --- a/wrappers/python/tests/TestDcdFile.py +++ b/wrappers/python/tests/TestDcdFile.py @@ -6,6 +6,8 @@ from random import random import os +curr_dir = os.path.dirname(os.path.abspath(__file__)) + def _read_dcd_header(file): import struct @@ -21,7 +23,7 @@ class TestDCDFile(unittest.TestCase): def test_dcd(self): """ Test the DCD file """ fname = tempfile.mktemp(suffix='.dcd') - pdbfile = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) natom = len(list(pdbfile.topology.atoms())) with open(fname, 'wb') as f: dcd = app.DCDFile(f, pdbfile.topology, 0.001) @@ -32,7 +34,7 @@ def test_dcd(self): def testLongTrajectory(self): """Test writing a trajectory that has more than 2^31 steps.""" fname = tempfile.mktemp(suffix='.dcd') - pdbfile = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) natom = len(list(pdbfile.topology.atoms())) with open(fname, 'wb') as f: dcd = app.DCDFile(f, pdbfile.topology, 0.001, interval=1000000000) @@ -43,7 +45,7 @@ def testLongTrajectory(self): def testAppend(self): """Test appending to an existing trajectory.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) @@ -87,7 +89,7 @@ def testAppend(self): def testAtomSubset(self): """Test writing a DCD file containing a subset of atoms""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) diff --git a/wrappers/python/tests/TestDesmondDMSFile.py b/wrappers/python/tests/TestDesmondDMSFile.py index fbe7c0bb6c..9fede1a8b9 100644 --- a/wrappers/python/tests/TestDesmondDMSFile.py +++ b/wrappers/python/tests/TestDesmondDMSFile.py @@ -5,21 +5,23 @@ from openmm.unit import * import openmm.app.element as elem +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestDesmondDMSFile(unittest.TestCase): def setUp(self): """Set up the tests by loading the input files.""" # alanine dipeptide with explicit water - path = os.path.join(os.path.dirname(__file__), 'systems/alanine-dipeptide-explicit-amber99SBILDN-tip3p.dms') + path = os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit-amber99SBILDN-tip3p.dms') self.dms = DesmondDMSFile(path) #nabumetone OPLS force field - path = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_lig.dms') + path = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_lig.dms') self.dms_opls1 = DesmondDMSFile(path) #beta-cyclodextrin/nabumetone complex OPLS force field - path1 = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_lig.dms') - path2 = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_rcpt.dms') + path1 = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_lig.dms') + path2 = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_rcpt.dms') self.dms_opls2 = DesmondDMSFile([path1,path2]) def test_NonbondedMethod(self): diff --git a/wrappers/python/tests/TestForceField.py b/wrappers/python/tests/TestForceField.py index 3b0376bf95..8c5c48ed5b 100644 --- a/wrappers/python/tests/TestForceField.py +++ b/wrappers/python/tests/TestForceField.py @@ -14,6 +14,9 @@ import os import warnings + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestForceField(unittest.TestCase): """Test the ForceField.createSystem() method.""" @@ -23,13 +26,13 @@ def setUp(self): """ # alanine dipeptide with explicit water - self.pdb1 = PDBFile('systems/alanine-dipeptide-explicit.pdb') + self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) self.forcefield1 = ForceField('amber99sb.xml', 'tip3p.xml') self.topology1 = self.pdb1.topology self.topology1.setUnitCellDimensions(Vec3(2, 2, 2)) # alanine dipeptide with implicit water - self.pdb2 = PDBFile('systems/alanine-dipeptide-implicit.pdb') + self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) self.forcefield2 = ForceField('amber99sb.xml', 'amber99_obc.xml') @@ -258,7 +261,7 @@ def test_DrudeMass(self): """Test that setting the mass of Drude particles works correctly.""" forcefield = ForceField('charmm_polar_2013.xml') - pdb = PDBFile('systems/ala_ala_ala.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) modeller = Modeller(pdb.topology, pdb.positions) modeller.addExtraParticles(forcefield) system = forcefield.createSystem(modeller.topology, drudeMass=0) @@ -297,13 +300,13 @@ def test_UnusedArgs(self): def test_Forces(self): """Compute forces and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed.""" - pdb = PDBFile('systems/lysozyme-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'lysozyme-implicit.pdb')) system = self.forcefield2.createSystem(pdb.topology) integrator = VerletIntegrator(0.001) context = Context(system, integrator) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open('systems/lysozyme-implicit-forces.xml') as input: + with open(os.path.join(curr_dir, 'systems', 'lysozyme-implicit-forces.xml')) as input: state2 = XmlSerializer.deserialize(input.read()) numDifferences = 0 for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): @@ -327,7 +330,7 @@ def test_ImplicitSolventForces(self): context.setPositions(self.pdb2.positions) state1 = context.getState(getForces=True) if file[i] is not None: - with open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml') as infile: + with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit-forces', file[i]+'.xml')) as infile: state2 = XmlSerializer.deserialize(infile.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -607,7 +610,7 @@ def test_residueMatcher(self): ff = ForceField(StringIO(xml)) # Load a water box. - prmtop = AmberPrmtopFile('systems/water-box-216.prmtop') + prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'water-box-216.prmtop')) top = prmtop.topology # Building a System should fail, because two templates match each residue. @@ -1103,10 +1106,9 @@ def test_CMAPTorsionGeneratorMapAssignment(self): def test_LennardJonesGenerator(self): """ Test the LennardJones generator""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ions.psf') - pdb = PDBFile('systems/ions.pdb') - params = CharmmParameterSet('systems/toppar_water_ions.str' - ) + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ions.psf')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) # Box dimensions (found from bounding box) psf.setBox(12.009*angstroms, 12.338*angstroms, 11.510*angstroms) @@ -1266,7 +1268,7 @@ def test_ImpropersOrdering(self): """ - pdb = PDBFile('systems/impropers_ordering_tetrapeptide.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'impropers_ordering_tetrapeptide.pdb')) # ff1 uses default ordering of impropers, ff2 uses "amber" for the one # problematic improper ff1 = ForceField('amber99sbildn.xml') @@ -1316,7 +1318,7 @@ def test_ImpropersOrdering_smirnoff(self): """ - pdb = PDBFile('systems/formaldehyde.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'formaldehyde.pdb')) # ff1 uses default ordering of impropers, ff2 uses "amber" for the one # problematic improper ff = ForceField(StringIO(xml)) @@ -1335,7 +1337,7 @@ def test_ImpropersOrdering_smirnoff(self): def test_Disulfides(self): """Test that various force fields handle disulfides correctly.""" - pdb = PDBFile('systems/bpti.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'bpti.pdb')) for ff in ['amber99sb.xml', 'amber14-all.xml', 'charmm36.xml', 'amberfb15.xml', 'amoeba2013.xml']: forcefield = ForceField(ff) system = forcefield.createSystem(pdb.topology) @@ -1370,7 +1372,7 @@ def test_IdenticalTemplates(self): def test_CharmmPolar(self): """Test the CHARMM polarizable force field.""" - pdb = PDBFile('systems/ala_ala_ala_drude.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala_drude.pdb')) pdb.topology.setUnitCellDimensions(Vec3(3, 3, 3)) ff = ForceField('charmm_polar_2019.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1.2*nanometers) @@ -1452,7 +1454,7 @@ def test_InitializationScript(self): def test_Glycam(self): """Test computing energy with GLYCAM.""" ff = ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml') - pdb = PDBFile('systems/glycopeptide.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) system = ff.createSystem(pdb.topology) for i, f in enumerate(system.getForces()): f.setForceGroup(i) @@ -1474,7 +1476,7 @@ def test_Glycam(self): def test_CustomNonbondedGenerator(self): """ Test the CustomNonbondedForce generator""" - pdb = PDBFile('systems/ions.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) xml = """ @@ -1520,7 +1522,7 @@ def test_CustomNonbondedGenerator(self): self.assertAlmostEqual(energy1, energy2) def test_OpcEnergy(self): - pdb = PDBFile('systems/opcbox.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'opcbox.pdb')) topology, positions = pdb.topology, pdb.positions self.assertEqual(len(positions), 864) forcefield = ForceField('opc.xml') @@ -1554,7 +1556,7 @@ def test_OpcEnergy(self): self.assertTrue(abs(energy1 - energy2) < energy_tolerance) def test_Opc3Energy(self): - pdb = PDBFile('systems/opc3box.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'opc3box.pdb')) topology, positions = pdb.topology, pdb.positions self.assertEqual(len(positions), 648) forcefield = ForceField('opc3.xml') @@ -1596,7 +1598,7 @@ def setUp(self): """ - self.pdb1 = PDBFile('systems/amoeba-ion-in-water.pdb') + self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'amoeba-ion-in-water.pdb')) self.forcefield1 = ForceField('amoeba2013.xml') self.topology1 = self.pdb1.topology @@ -1670,14 +1672,14 @@ def test_RigidWater(self): def test_Forces(self): """Compute forces and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) forcefield = ForceField('amoeba2013.xml', 'amoeba2013_gk.xml') system = forcefield.createSystem(pdb.topology, polarization='direct') integrator = VerletIntegrator(0.001) context = Context(system, integrator, Platform.getPlatform('Reference')) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open('systems/alanine-dipeptide-amoeba-forces.xml') as input: + with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-amoeba-forces.xml')) as input: state2 = XmlSerializer.deserialize(input.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -1700,7 +1702,7 @@ def computeAmoeba18Energies(self, filename): def test_Amoeba18BPTI(self): """Test that AMOEBA18 computes energies correctly for BPTI.""" - energies = self.computeAmoeba18Energies('systems/bpti.pdb') + energies = self.computeAmoeba18Energies(os.path.join(curr_dir, 'systems', 'bpti.pdb')) # Compare to values computed with Tinker. @@ -1717,7 +1719,7 @@ def test_Amoeba18BPTI(self): def test_Amoeba18Nucleic(self): """Test that AMOEBA18 computes energies correctly for DNA and RNA.""" - energies = self.computeAmoeba18Energies('systems/nucleic.pdb') + energies = self.computeAmoeba18Energies(os.path.join(curr_dir, 'systems', 'nucleic.pdb')) # Compare to values computed with Tinker. diff --git a/wrappers/python/tests/TestGenerators.py b/wrappers/python/tests/TestGenerators.py index 8a67347cfa..28506267f6 100644 --- a/wrappers/python/tests/TestGenerators.py +++ b/wrappers/python/tests/TestGenerators.py @@ -13,12 +13,14 @@ import os import warnings +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestGenerators(unittest.TestCase): """Test the various generators found in forcefield.py.""" def setUp(self): # alanine dipeptide with implicit water - self.pdb1 = PDBFile('systems/alanine-dipeptide-implicit.pdb') + self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) def test_CustomHbondGenerator(self): diff --git a/wrappers/python/tests/TestGromacsGroFile.py b/wrappers/python/tests/TestGromacsGroFile.py index b18107bde0..2413362465 100644 --- a/wrappers/python/tests/TestGromacsGroFile.py +++ b/wrappers/python/tests/TestGromacsGroFile.py @@ -3,13 +3,16 @@ from openmm import * from openmm.unit import * import openmm.app.element as elem +import os + +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestGromacsGroFile(unittest.TestCase): """Test the Gromacs GRO file parser""" def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - gro = GromacsGroFile('systems/triclinic.gro') + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'triclinic.gro')) self.assertEqual(len(gro.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), diff --git a/wrappers/python/tests/TestGromacsTopFile.py b/wrappers/python/tests/TestGromacsTopFile.py index 08ab6ecb2c..9d6bc3ef45 100644 --- a/wrappers/python/tests/TestGromacsTopFile.py +++ b/wrappers/python/tests/TestGromacsTopFile.py @@ -6,9 +6,13 @@ from openmm.app.gromacstopfile import _defaultGromacsIncludeDir import openmm.app.element as elem from numpy.testing import assert_allclose +import os GROMACS_INCLUDE = _defaultGromacsIncludeDir() + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + @unittest.skipIf(not os.path.exists(GROMACS_INCLUDE), 'GROMACS is not installed') class TestGromacsTopFile(unittest.TestCase): @@ -18,7 +22,7 @@ def setUp(self): """Set up the tests by loading the input files.""" # alanine dipeptide with explicit water - self.top1 = GromacsTopFile('systems/explicit.top', unitCellDimensions=Vec3(6.223, 6.223, 6.223)*nanometers) + self.top1 = GromacsTopFile(os.path.join(curr_dir, 'systems', 'explicit.top'), unitCellDimensions=Vec3(6.223, 6.223, 6.223)*nanometers) def test_NonbondedMethod(self): """Test all six options for the nonbondedMethod parameter.""" @@ -38,8 +42,8 @@ def test_NonbondedMethod(self): def test_ff99SBILDN(self): """ Test Gromacs topology #define replacement as used in ff99SB-ILDN """ - top = GromacsTopFile('systems/aidilnaaaaa.top') - gro = GromacsGroFile('systems/aidilnaaaaa.gro') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'aidilnaaaaa.top')) + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'aidilnaaaaa.gro')) system = top.createSystem() for force in system.getForces(): if isinstance(force, PeriodicTorsionForce): @@ -52,8 +56,8 @@ def test_ff99SBILDN(self): def test_SMOG(self): """ Test to ensure that SMOG models can be run without problems """ - top = GromacsTopFile('systems/2ci2.pdb.top') - gro = GromacsGroFile('systems/2ci2.pdb.gro') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', '2ci2.pdb.top')) + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', '2ci2.pdb.gro')) system = top.createSystem() context = Context(system, VerletIntegrator(1*femtosecond), @@ -64,8 +68,8 @@ def test_SMOG(self): def test_ionic(self): """Test simulating an ionic liquid""" - gro = GromacsGroFile('systems/ionic.gro') - top = GromacsTopFile('systems/ionic.top', periodicBoxVectors=gro.getPeriodicBoxVectors()) + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'ionic.gro')) + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'ionic.top'), periodicBoxVectors=gro.getPeriodicBoxVectors()) system = top.createSystem(nonbondedMethod=PME, nonbondedCutoff=1.2) for f in system.getForces(): if isinstance(f, CustomNonbondedForce): @@ -94,7 +98,7 @@ def test_Cutoff(self): def test_SwitchingFunction(self): """Test using a switching function.""" - top = GromacsTopFile('systems/ionic.top') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'ionic.top')) for distance in (None, 0.8*nanometers): system = top.createSystem(nonbondedMethod=CutoffNonPeriodic, switchDistance=distance) for f in system.getForces(): @@ -158,8 +162,8 @@ def test_HydrogenMass(self): def test_VirtualParticle(self): """Test virtual particle works correctly.""" - top = GromacsTopFile('systems/bnz.top') - gro = GromacsGroFile('systems/bnz.gro') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'bnz.top')) + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'bnz.gro')) for atom in top.topology.atoms(): if atom.name.startswith('C'): self.assertEqual(elem.carbon, atom.element) @@ -182,7 +186,7 @@ def test_VirtualParticle(self): def test_Vsite3Func1(self): """Test a three particle virtual site.""" - top = GromacsTopFile('systems/tip4pew.top') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'tip4pew.top')) system = top.createSystem() self.assertEqual(3, system.getNumConstraints()) self.assertTrue(system.isVirtualSite(3)) @@ -197,7 +201,7 @@ def test_Vsite3Func1(self): def test_Vsite3Func4(self): """Test a three particle virtual site.""" - top = GromacsTopFile('systems/tip5p.top') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'tip5p.top')) system = top.createSystem() self.assertEqual(3, system.getNumConstraints()) for i in (3, 4): @@ -217,8 +221,8 @@ def test_Vsite3Func4(self): def test_GROMOS(self): """Test a system using the GROMOS 54a7 force field.""" - top = GromacsTopFile('systems/1ppt.top') - gro = GromacsGroFile('systems/1ppt.gro') + top = GromacsTopFile(os.path.join(curr_dir, 'systems', '1ppt.top')) + gro = GromacsGroFile(os.path.join(curr_dir, 'systems', '1ppt.gro')) system = top.createSystem() for i, f in enumerate(system.getForces()): f.setForceGroup(i) diff --git a/wrappers/python/tests/TestIntegrators.py b/wrappers/python/tests/TestIntegrators.py index cff603b4d2..7855ab805a 100644 --- a/wrappers/python/tests/TestIntegrators.py +++ b/wrappers/python/tests/TestIntegrators.py @@ -6,6 +6,10 @@ from openmm.app import * from openmm.unit import * import math, random +import os + + +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestIntegrators(unittest.TestCase): """Test Python Integrator classes""" @@ -13,7 +17,7 @@ class TestIntegrators(unittest.TestCase): def testMTSIntegratorExplicit(self): """Test the MTS integrator on an explicit solvent system""" # Create a periodic solvated system with PME - pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -100,7 +104,7 @@ def testMTSIntegratorConstraints(self): def testBadGroups(self): """Test the MTS integrator with bad force group substeps.""" # Create a periodic solvated system with PME - pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -124,7 +128,7 @@ def testBadGroups(self): def testMTSLangevinIntegrator(self): """Test the MTSLangevinIntegrator on an explicit solvent system""" # Create a periodic solvated system with PME - pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -188,7 +192,7 @@ def get_final_velocities(nsubsteps): def testNoseHooverIntegrator(self): """Test partial thermostating in the NoseHooverIntegrator (only API)""" - pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -203,9 +207,9 @@ def testNoseHooverIntegrator(self): def testDrudeNoseHooverIntegrator(self): """Test the DrudeNoseHooverIntegrator""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile('systems/ala3_solv_drude.psf') - crd = CharmmCrdFile('systems/ala3_solv_drude.crd') - params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') + psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) + crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) + params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) # Box dimensions (cubic box) psf.setBox(33.2*angstroms, 33.2*angstroms, 33.2*angstroms) diff --git a/wrappers/python/tests/TestModeller.py b/wrappers/python/tests/TestModeller.py index 33d085a715..1e75b5ca13 100644 --- a/wrappers/python/tests/TestModeller.py +++ b/wrappers/python/tests/TestModeller.py @@ -6,29 +6,33 @@ from openmm.app import * from openmm import * from openmm.unit import * +import os if sys.version_info >= (3, 0): from io import StringIO else: from cStringIO import StringIO + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestModeller(unittest.TestCase): """ Test the Modeller class. """ def setUp(self): # load the alanine dipeptide pdb file - self.pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + self.pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) self.topology_start = self.pdb.topology self.positions = self.pdb.positions self.forcefield = ForceField('amber10.xml', 'tip3p.xml') # load the T4-lysozyme-L99A receptor pdb file - self.pdb2 = PDBFile('systems/lysozyme-implicit.pdb') + self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'lysozyme-implicit.pdb')) self.topology_start2 = self.pdb2.topology self.positions2 = self.pdb2.positions # load the metallothionein pdb file - self.pdb3 = PDBFile('systems/1T2Y.pdb') + self.pdb3 = PDBFile(os.path.join(curr_dir, 'systems', '1T2Y.pdb')) self.topology_start3 = self.pdb3.topology self.positions3 = self.pdb3.positions @@ -134,7 +138,7 @@ def test_add(self): """ Test the add() method. """ # load the methanol-box pdb file - pdb2 = PDBFile('systems/methanol-box.pdb') + pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'methanol-box.pdb')) topology_toAdd = pdb2.topology positions_toAdd = pdb2.positions @@ -969,7 +973,7 @@ def test_addHydrogenspH11(self): def test_addHydrogensGlycam(self): """Test adding hydrogens for GLYCAM.""" - pdb = PDBFile('systems/glycopeptide.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) Modeller.loadHydrogenDefinitions('glycam-hydrogens.xml') modeller = Modeller(pdb.topology, pdb.positions) hydrogens = [a for a in modeller.topology.atoms() if a.element == element.hydrogen] @@ -987,7 +991,7 @@ def test_addHydrogensGlycam(self): def test_addSpecificHydrogens(self): """Test specifying exactly which hydrogens to add.""" - pdb = PDBFile('systems/glycopeptide.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) variants = [None]*pdb.topology.getNumResidues() for residue in pdb.topology.residues(): if residue.name != 'ALA': @@ -1185,7 +1189,7 @@ def test_multiSiteIon(self): def test_addMembrane(self): """Test adding a membrane to a realistic system.""" - mol = PDBxFile('systems/gpcr.cif') + mol = PDBxFile(os.path.join(curr_dir, 'systems', 'gpcr.cif')) modeller = Modeller(mol.topology, mol.positions) ff = ForceField('amber14-all.xml', 'amber14/tip3p.xml') @@ -1235,7 +1239,7 @@ def test_bondTypeAndOrderPreserved(self): """ # Given: an isolated molecule - pdb = PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) topology, positions = pdb.topology, pdb.positions topology.setUnitCellDimensions(Vec3(3.5, 3.5, 3.5) * nanometers) # with some bonds carrying type and order information @@ -1282,7 +1286,7 @@ def test_bondTypeAndOrderPreserved(self): self.assertIn((Double, 2.0), [(b.type, b.order) for b in modeller.topology.bonds()]) # When (6): add a modeller (which also bears some bond info) - to_add = PDBFile('systems/methanol-box.pdb') + to_add = PDBFile(os.path.join(curr_dir, 'systems', 'methanol-box.pdb')) topology_to_add = to_add.topology positions_to_add = to_add.positions # add a dummy bond to the "to_add" system to check that it also is preserved diff --git a/wrappers/python/tests/TestNumpyCompatibility.py b/wrappers/python/tests/TestNumpyCompatibility.py index 46b55a6ba0..7f7fb5a8d5 100644 --- a/wrappers/python/tests/TestNumpyCompatibility.py +++ b/wrappers/python/tests/TestNumpyCompatibility.py @@ -2,6 +2,7 @@ from openmm import app import openmm as mm from openmm import unit +import os try: import numpy as np NUMPY_IMPORT_FAILED = False @@ -9,11 +10,13 @@ NUMPY_IMPORT_FAILED = True +curr_dir = os.path.dirname(os.path.abspath(__file__)) + @unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed') class TestNumpyCompatibility(unittest.TestCase): def setUp(self): - prmtop = app.AmberPrmtopFile('systems/water-box-216.prmtop') + prmtop = app.AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'water-box-216.prmtop')) system = prmtop.createSystem(nonbondedMethod=app.PME, nonbondedCutoff=0.9*unit.nanometers, diff --git a/wrappers/python/tests/TestPdbFile.py b/wrappers/python/tests/TestPdbFile.py index 430ce3b048..d1ee6022c9 100644 --- a/wrappers/python/tests/TestPdbFile.py +++ b/wrappers/python/tests/TestPdbFile.py @@ -5,6 +5,10 @@ from openmm.unit import * import openmm.app.element as elem from io import StringIO +import os + + +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestPdbFile(unittest.TestCase): @@ -12,7 +16,7 @@ class TestPdbFile(unittest.TestCase): def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - pdb = PDBFile('systems/triclinic.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'triclinic.pdb')) self.assertEqual(len(pdb.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), @@ -56,7 +60,7 @@ def compareFiles(pdb1, pdb2): self.assertEqual(atom1.name, atom2.name) self.assertEqual(atom1.residue.name, atom2.residue.name) - pdb1 = PDBFile('systems/triclinic.pdb') + pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'triclinic.pdb')) # First try writing to an open file object. @@ -78,13 +82,13 @@ def compareFiles(pdb1, pdb2): def test_BinaryStream(self): """Test reading a stream that was opened in binary mode.""" - with open('systems/triclinic.pdb', 'rb') as infile: + with open(os.path.join(curr_dir, 'systems', 'triclinic.pdb'), 'rb') as infile: pdb = PDBFile(infile) self.assertEqual(len(pdb.positions), 8) def test_ExtraParticles(self): """Test reading, and writing and re-reading of a file containing extra particle atoms.""" - pdb = PDBFile('systems/tip5p.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'tip5p.pdb')) for atom in pdb.topology.atoms(): if atom.index > 2: self.assertEqual(None, atom.element) @@ -99,7 +103,7 @@ def test_ExtraParticles(self): def test_AltLocs(self): """Test reading a file that includes AltLocs""" for filename in ['altlocs.pdb', 'altlocs2.pdb']: - pdb = PDBFile(f'systems/{filename}') + pdb = PDBFile(os.path.join(curr_dir, 'systems', filename)) self.assertEqual(1, pdb.topology.getNumResidues()) self.assertEqual(19, pdb.topology.getNumAtoms()) self.assertEqual(19, len(pdb.positions)) @@ -107,7 +111,7 @@ def test_AltLocs(self): def test_FormalCharges(self): """Test reading, and writing and re-reading of a file containing formal charges.""" - pdb = PDBFile('systems/formal-charges.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'formal-charges.pdb')) for atom in pdb.topology.atoms(): if atom.index == 8: self.assertEqual(+1, atom.formalCharge) diff --git a/wrappers/python/tests/TestPdbReporter.py b/wrappers/python/tests/TestPdbReporter.py index 68bc4b84c7..c117749fd3 100644 --- a/wrappers/python/tests/TestPdbReporter.py +++ b/wrappers/python/tests/TestPdbReporter.py @@ -7,6 +7,9 @@ import os import gc + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + def assertVecAlmostEqual(p1, p2, tol=1e-7): unit = p1.unit p1 = p1.value_in_unit(unit) @@ -19,7 +22,7 @@ def assertVecAlmostEqual(p1, p2, tol=1e-7): class TestPDBReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') + self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) self.forcefield = app.ForceField('amber99sbildn.xml','tip3p.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) @@ -117,7 +120,7 @@ def testBondSubset(self): # use a testcase that has CONECT records in the input pdb file ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml','amber14/tip3pfb.xml') - pdb = app.PDBFile('systems/glycopeptide.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) # add in water molecules modeller = app.Modeller(pdb.topology, pdb.positions) @@ -157,7 +160,7 @@ def testBondSubset(self): class TestPDBxReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') + self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) self.forcefield = app.ForceField('amber99sbildn.xml','tip3p.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) @@ -255,7 +258,7 @@ def testBondSubset(self): # use a testcase that has CONECT records in the input pdb file ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml','amber14/tip3pfb.xml') - pdb = app.PDBFile('systems/glycopeptide.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) # add in water molecules modeller = app.Modeller(pdb.topology, pdb.positions) diff --git a/wrappers/python/tests/TestPdbxFile.py b/wrappers/python/tests/TestPdbxFile.py index 711c5739c7..c1b7de6063 100644 --- a/wrappers/python/tests/TestPdbxFile.py +++ b/wrappers/python/tests/TestPdbxFile.py @@ -7,13 +7,16 @@ import os from io import StringIO + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestPdbxFile(unittest.TestCase): """Test the PDBx/mmCIF file parser""" def test_FormatConversion(self): """Test conversion from PDB to PDBx""" - mol = PDBFile('systems/ala_ala_ala.pdb') + mol = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) with tempfile.TemporaryDirectory() as tempdir: filename = os.path.join(tempdir, 'temp.pdbx') PDBxFile.writeFile(mol.topology, mol.positions, filename, keepIds=True) @@ -25,7 +28,7 @@ def test_FormatConversion(self): def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - pdb = PDBxFile('systems/triclinic.pdbx') + pdb = PDBxFile(os.path.join(curr_dir, 'systems', 'triclinic.pdbx')) self.assertEqual(len(pdb.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), @@ -66,11 +69,11 @@ def assertVecAlmostEqual(self, p1, p2, tol=1e-7): def testReporterImplicit(self): """ Tests the PDBxReporter without PBC """ - parm = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop') + parm = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.prmtop')) system = parm.createSystem() sim = Simulation(parm.topology, system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) - sim.context.setPositions(PDBFile('systems/alanine-dipeptide-implicit.pdb').getPositions()) + sim.context.setPositions(PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')).getPositions()) sim.reporters.append(PDBxReporter('test.cif', 1)) sim.step(10) pdb = PDBxFile('test.cif') @@ -98,11 +101,11 @@ def assertAlmostEqualVec(self, vec1, vec2, *args, **kwargs): def testReporterExplicit(self): """ Tests the PDBxReporter with PBC """ - parm = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop') + parm = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.prmtop')) system = parm.createSystem(nonbondedCutoff=1.0, nonbondedMethod=PME) sim = Simulation(parm.topology, system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) - orig_pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + orig_pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) sim.context.setPositions(orig_pdb.getPositions()) sim.context.setPeriodicBoxVectors(*parm.topology.getPeriodicBoxVectors()) sim.reporters.append(PDBxReporter('test.cif', 1)) @@ -132,7 +135,7 @@ def testReporterExplicit(self): def testBonds(self): """Test reading and writing a file that includes bonds.""" - pdb = PDBFile('systems/methanol_ions.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'methanol_ions.pdb')) output = StringIO() PDBxFile.writeFile(pdb.topology, pdb.positions, output) input = StringIO(output.getvalue()) @@ -146,7 +149,7 @@ def testBonds(self): def testMultiChain(self): """Test reading and writing a file that includes multiple chains""" - cif_ori = PDBxFile('systems/multichain.pdbx') + cif_ori = PDBxFile(os.path.join(curr_dir, 'systems', 'multichain.pdbx')) output = StringIO() PDBxFile.writeFile(cif_ori.topology, cif_ori.positions, output, keepIds=True) @@ -162,7 +165,7 @@ def testMultiChain(self): def testInsertionCodes(self): """Test reading a file that uses insertion codes.""" - pdbx = PDBxFile('systems/insertions.pdbx') + pdbx = PDBxFile(os.path.join(curr_dir, 'systems', 'insertions.pdbx')) residues = list(pdbx.topology.residues()) self.assertEqual(7, len(residues)) names = ['PHE', 'ASP', 'LYS', 'ILE', 'LYS', 'ASN', 'TRP'] diff --git a/wrappers/python/tests/TestPickle.py b/wrappers/python/tests/TestPickle.py index b019aa114b..eade637963 100644 --- a/wrappers/python/tests/TestPickle.py +++ b/wrappers/python/tests/TestPickle.py @@ -8,6 +8,10 @@ import openmm.app.forcefield as forcefield import copy import pickle +import os + + +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestPickle(unittest.TestCase): """Pickling / deepcopy of OpenMM objects.""" @@ -18,13 +22,13 @@ def setUp(self): """ # alanine dipeptide with explicit water - self.pdb1 = PDBFile('systems/alanine-dipeptide-explicit.pdb') + self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) self.forcefield1 = ForceField('amber99sb.xml', 'tip3p.xml') self.topology1 = self.pdb1.topology self.topology1.setUnitCellDimensions(Vec3(2, 2, 2)) # alalnine dipeptide with implicit water - self.pdb2 = PDBFile('systems/alanine-dipeptide-implicit.pdb') + self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) self.forcefield2 = ForceField('amber99sb.xml', 'amber99_obc.xml') def check_copy(self, object, object_copy): diff --git a/wrappers/python/tests/TestSimulation.py b/wrappers/python/tests/TestSimulation.py index 68ba979670..b6b7797836 100644 --- a/wrappers/python/tests/TestSimulation.py +++ b/wrappers/python/tests/TestSimulation.py @@ -4,13 +4,17 @@ from openmm import * from openmm.app import * from openmm.unit import * +import os + + +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestSimulation(unittest.TestCase): """Test the Simulation class""" def testCheckpointing(self): """Test that checkpointing works correctly.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -44,7 +48,7 @@ def testCheckpointing(self): def testLoadFromXML(self): """ Test creating a Simulation from XML files """ - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -67,7 +71,7 @@ def testLoadFromXML(self): def testSaveState(self): """Test that saving States works correctly.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -100,7 +104,7 @@ def testSaveState(self): def testStep(self): """Test the step() method.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -123,7 +127,7 @@ def testStep(self): def testRunForClockTime(self): """Test the runForClockTime() method.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -167,7 +171,7 @@ def testRunForClockTime(self): def testWrappedCoordinates(self): """Test generating reports with and without wrapped coordinates.""" - pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=CutoffPeriodic, constraints=HBonds) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) @@ -199,7 +203,7 @@ def report(self, simulation, state): def testMinimizationReporter(self): """Test invoking a reporter during minimization.""" - pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) diff --git a/wrappers/python/tests/TestStateDataReporter.py b/wrappers/python/tests/TestStateDataReporter.py index cacdae066b..d6df5283b4 100644 --- a/wrappers/python/tests/TestStateDataReporter.py +++ b/wrappers/python/tests/TestStateDataReporter.py @@ -5,10 +5,11 @@ from openmm import unit import os +curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestStateDataReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') + self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) self.forcefield = app.ForceField('amber99sbildn.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) diff --git a/wrappers/python/tests/TestTopology.py b/wrappers/python/tests/TestTopology.py index a2b6db23ee..936b51f620 100644 --- a/wrappers/python/tests/TestTopology.py +++ b/wrappers/python/tests/TestTopology.py @@ -5,12 +5,16 @@ from openmm import * from openmm.unit import * import openmm.app.element as elem +import os if sys.version_info >= (3, 0): from io import StringIO else: from cStringIO import StringIO +curr_dir = os.path.dirname(os.path.abspath(__file__)) + + class TestTopology(unittest.TestCase): """Test the Topology object""" @@ -25,7 +29,7 @@ def check_pdbfile(self, pdbfilename, natoms, nres, nchains): def test_getters(self): """Test getters for number of atoms, residues, chains.""" - self.check_pdbfile('systems/1T2Y.pdb', 271, 25, 1) + self.check_pdbfile(os.path.join(curr_dir, 'systems', '1T2Y.pdb'), 271, 25, 1) def test_bondtype_singleton(self): """ Tests that the bond types are really singletons """ diff --git a/wrappers/python/tests/TestXtcFile.py b/wrappers/python/tests/TestXtcFile.py index 2d905ccf14..fcd118517f 100644 --- a/wrappers/python/tests/TestXtcFile.py +++ b/wrappers/python/tests/TestXtcFile.py @@ -10,12 +10,15 @@ import numpy as np from openmm.app.internal.xtc_utils import read_xtc + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestXtcFile(unittest.TestCase): def test_xtc_triclinic(self): """Test the XTC file by writing a trajectory and reading it back. Using a triclinic box""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -57,7 +60,7 @@ def test_xtc_cubic(self): """Test the XTC file by writing a trajectory and reading it back. Using a cubic box""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -95,7 +98,7 @@ def test_xtc_box_from_topology(self): """Test the XTC file by writing a trajectory and reading it back. Letting the box be set from the topology""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) # Set some arbitrary size for the unit cell so that a box is included in the trajectory unitCell = mm.Vec3(random(), random(), random()) * unit.nanometers pdbfile.topology.setUnitCellDimensions(unitCell) @@ -139,7 +142,7 @@ def test_xtc_small(self): """Test the XTC file by writing a trajectory and reading it back. Using a system size below the compression threshold""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile("systems/ions.pdb") + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -181,7 +184,7 @@ def testLongTrajectory(self): """Test writing a trajectory that has more than 2^31 steps.""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) natom = len(list(pdbfile.topology.atoms())) xtc = app.XTCFile(fname, pdbfile.topology, 0.001, interval=1000000000) for i in range(5): @@ -196,7 +199,7 @@ def testAppend(self): """Test appending to an existing trajectory.""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdb = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = app.ForceField("amber99sb.xml", "tip3p.xml") system = ff.createSystem(pdb.topology) @@ -249,7 +252,7 @@ def testAtomSubset(self): """Test writing an XTC file containing a subset of atoms""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdb = app.PDBFile("systems/alanine-dipeptide-explicit.pdb") + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = app.ForceField("amber99sb.xml", "tip3p.xml") system = ff.createSystem(pdb.topology) From b9923947c8c02ee309b0e119be54114de4005f83 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 19:18:35 +0300 Subject: [PATCH 19/75] minor mistake --- wrappers/python/tests/TestCheckpointReporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/tests/TestCheckpointReporter.py b/wrappers/python/tests/TestCheckpointReporter.py index 7a4d35b2d4..70fe152486 100644 --- a/wrappers/python/tests/TestCheckpointReporter.py +++ b/wrappers/python/tests/TestCheckpointReporter.py @@ -12,7 +12,7 @@ class TestCheckpointReporter(unittest.TestCase): def setUp(self): with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) as f: pdb = app.PDBFile(f) - forcefield = app.ForceField(os.path.join(curr_dir, 'systems', 'amber99sbildn.xml')) + forcefield = app.ForceField('amber99sbildn.xml') system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, nonbondedCutoff=1.0*unit.nanometers, constraints=app.HBonds) From 5a3f39f01b2ca0f5d8bf7d5211ee3dd96dbcb0bb Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 19:19:39 +0300 Subject: [PATCH 20/75] pytest run from main dir --- wrappers/python/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 6dc30b944b..b130888631 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -36,14 +36,14 @@ build-backend = "setuptools.build_meta" [tool.cibuildwheel] skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] -test-command = "cd {project}/wrappers/python/tests && pytest ." +test-command = "pytest {project}/wrappers/python/tests" manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" environment-pass = ["ACCELERATOR", "OPENCL_PATH"] # container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.windows] -test-command = "cd {project}\\wrappers\\python\\tests && pytest ." +test-command = "pytest {project}\\wrappers\\python\\tests" [tool.cibuildwheel.linux] repair-wheel-command = [ From 4a5b441ed7ae21d9087f9dc501fce6fac47b319b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 7 Apr 2025 19:31:45 +0300 Subject: [PATCH 21/75] missing curr_dir --- wrappers/python/tests/TestForceField.py | 20 ++++++++++---------- wrappers/python/tests/TestPatches.py | 7 +++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/wrappers/python/tests/TestForceField.py b/wrappers/python/tests/TestForceField.py index 8c5c48ed5b..2a19b06677 100644 --- a/wrappers/python/tests/TestForceField.py +++ b/wrappers/python/tests/TestForceField.py @@ -681,7 +681,7 @@ def simpleTemplateGenerator(forcefield, residue): # # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml', StringIO(simple_ffxml_contents)) # Add the residue template generator. @@ -703,7 +703,7 @@ def simpleTemplateGenerator(forcefield, residue): # Test all systems with separate ForceField objects. for test in tests: # Load the PDB file. - pdb = PDBFile(os.path.join('systems', test['pdb_filename'])) + pdb = PDBFile(os.path.join(curr_dir, 'systems', test['pdb_filename'])) # Create a ForceField object. forcefield = ForceField(StringIO(simple_ffxml_contents)) # Add the residue template generator. @@ -719,7 +719,7 @@ def simpleTemplateGenerator(forcefield, residue): forcefield.registerTemplateGenerator(simpleTemplateGenerator) for test in tests: # Load the PDB file. - pdb = PDBFile(os.path.join('systems', test['pdb_filename'])) + pdb = PDBFile(os.path.join(curr_dir, 'systems', test['pdb_filename'])) # Parameterize system. system = forcefield.createSystem(pdb.topology, nonbondedMethod=test['nonbondedMethod']) # TODO: Test energies are finite? @@ -728,7 +728,7 @@ def test_getUnmatchedResidues(self): """Test retrieval of list of residues for which no templates are available.""" # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml') # Get list of unmatched residues. @@ -739,7 +739,7 @@ def test_getUnmatchedResidues(self): self.assertEqual(unmatched_residues[0].id, '163') # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) # Create a ForceField object. forcefield = ForceField('tip3p.xml') # Get list of unmatched residues. @@ -757,7 +757,7 @@ def test_generateTemplatesForUnmatchedResidues(self): # # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'nacl-water.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'nacl-water.pdb')) # Create a ForceField object. forcefield = ForceField('tip3p.xml') # Get list of unmatched residues. @@ -800,7 +800,7 @@ def test_generateTemplatesForUnmatchedResidues(self): # # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml', StringIO(simple_ffxml_contents)) # Get list of unique unmatched residues. @@ -820,7 +820,7 @@ def test_getMatchingTemplates(self): """Test retrieval of list of templates that match residues in a topology.""" # Load the PDB file. - pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml') # Get list of matching residue templates. @@ -873,7 +873,7 @@ def test_Wildcard(self): def test_ScalingFactorCombining(self): """ Tests that FFs can be combined if their scaling factors are very close """ - forcefield = ForceField('amber99sb.xml', os.path.join('systems', 'test_amber_ff.xml')) + forcefield = ForceField('amber99sb.xml', os.path.join(curr_dir, 'systems', 'test_amber_ff.xml')) # This would raise an exception if it didn't work def test_MultipleFilesandForceTags(self): @@ -1251,7 +1251,7 @@ def test_IgnoreExternalBonds(self): def test_Includes(self): """Test using a ForceField that includes other files.""" - forcefield = ForceField(os.path.join('systems', 'ff_with_includes.xml')) + forcefield = ForceField(os.path.join(curr_dir, 'systems', 'ff_with_includes.xml')) self.assertTrue(len(forcefield._atomTypes) > 10) self.assertTrue('spce-O' in forcefield._atomTypes) self.assertTrue('HOH' in forcefield._templates) diff --git a/wrappers/python/tests/TestPatches.py b/wrappers/python/tests/TestPatches.py index 1a3db2e322..d5cac60774 100644 --- a/wrappers/python/tests/TestPatches.py +++ b/wrappers/python/tests/TestPatches.py @@ -10,6 +10,9 @@ from io import StringIO import os + +curr_dir = os.path.dirname(os.path.abspath(__file__)) + class TestPatches(unittest.TestCase): """Test ForceFields that use patches.""" @@ -260,7 +263,7 @@ def testAlaAlaAla(self): """ ff = ForceField(StringIO(xml)) - pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) system = ff.createSystem(pdb.topology) nb = system.getForce(0) expectedCharges = [0.1414, 0.2719, 0.2719, 0.2719, 0.0337, 0.0823, 0.0337, 0.0603, 0.0603, 0.0603, 0.5973, -0.5679, @@ -270,7 +273,7 @@ def testAlaAlaAla(self): self.assertEqual(expectedCharges[i], nb.getParticleParameters(i)[0].value_in_unit(elementary_charge)) def testDisulfidePatch(self): - pdb = PDBFile(os.path.join('systems', 'bpti.pdb')) + pdb = PDBFile(os.path.join(curr_dir, 'systems', 'bpti.pdb')) ff = ForceField('amber99sb.xml') system1 = ff.createSystem(pdb.topology) From 8b00683770e27fa1fe7847df8514a9fed257cc1b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 09:29:54 +0300 Subject: [PATCH 22/75] try installing the right CUDA version to set the path correctly --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 264170d772..8c042c0dbc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -58,6 +58,7 @@ jobs: if: matrix.os == 'windows-2019' id: cuda-toolkit with: + cuda: ${{ matrix.accelerator == 'cu118' && '11.8' || '12.4' }} method: "network" sub-packages: '["opencl"]' @@ -87,8 +88,8 @@ jobs: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} - CIBW_BUILD: "cp310-*" OPENCL_PATH: "${{steps.cuda-toolkit.outputs.CUDA_PATH}}" + CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 with: From 5872d4a90935c63f5e74b09816611ab4e071f24a Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 09:56:34 +0300 Subject: [PATCH 23/75] manually install opencl --- .github/workflows/publish.yml | 14 ++------------ .../prepare_build_environment_windows.sh | 8 +++++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8c042c0dbc..7b62d191df 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,15 +53,6 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 if: matrix.os == 'windows-2019' - - name: "Install OpenCL" - uses: Jimver/cuda-toolkit@v0.2.16 - if: matrix.os == 'windows-2019' - id: cuda-toolkit - with: - cuda: ${{ matrix.accelerator == 'cu118' && '11.8' || '12.4' }} - method: "network" - sub-packages: '["opencl"]' - - name: "Install dependencies with choco" uses: crazy-max/ghaction-chocolatey@v3 if: matrix.os == 'windows-2019' @@ -75,7 +66,7 @@ jobs: env: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" - CUDA_VERSION: ${{ matrix.accelerator }} + # CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} CIBW_BUILD: "cp310-*" @@ -86,9 +77,8 @@ jobs: env: CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building - CUDA_VERSION: ${{ matrix.accelerator }} + # CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} - OPENCL_PATH: "${{steps.cuda-toolkit.outputs.CUDA_PATH}}" CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 714ec53cff..78aed39aad 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -23,6 +23,12 @@ if [ "$ACCELERATOR" == "hip" ]; then rm HIP.exe fi +# Download and extract OpenCL +curl --netrc-optional -L -nv -o OpenCL-SDK.zip https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2024.10.24/OpenCL-SDK-v2024.10.24-Win-x64.zip +unzip OpenCL-SDK.zip +OPENCL_PATH="$(pwd)/OpenCL-SDK-v2024.10.24-Win-x64" + + # Configure build with Cmake mkdir -p build mkdir -p openmm-install @@ -34,7 +40,7 @@ cmake -G "NMake Makefiles JOM" \ -DCMAKE_CXX_COMPILER=cl.exe \ -DCMAKE_C_COMPILER=cl.exe \ -DOPENCL_INCLUDE_DIR="${OPENCL_PATH}/include" \ - -DOPENCL_LIBRARY="${OPENCL_PATH}/lib/x64/OpenCL.lib" \ + -DOPENCL_LIBRARY="${OPENCL_PATH}/lib/OpenCL.lib" \ -DHIP_PLATFORM=amd \ .. From f43034ec4fab994f29e21bfd188ba2ee3e65eb3d Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 10:32:20 +0300 Subject: [PATCH 24/75] set CUDA_PATH on Windows builds --- .github/workflows/publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7b62d191df..c3fac0ee81 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,7 +66,6 @@ jobs: env: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" - # CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} CIBW_BUILD: "cp310-*" @@ -77,8 +76,8 @@ jobs: env: CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building - # CUDA_VERSION: ${{ matrix.accelerator }} ACCELERATOR: ${{ matrix.accelerator }} + CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 From e159b8c0c16ff88659217e4f9ad279160e186375 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 11:01:30 +0300 Subject: [PATCH 25/75] full workflow --- .github/workflows/publish.yml | 84 ++++++++++++++++++++++++++++++++-- .github/workflows/workflow.yml | 9 ++++ 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c3fac0ee81..6fa465ea8d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,7 +3,6 @@ name: Build wheels and publish on: workflow_dispatch: workflow_call: - push: jobs: build: @@ -67,7 +66,6 @@ jobs: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" ACCELERATOR: ${{ matrix.accelerator }} - CIBW_BUILD: "cp310-*" - name: Build wheels if: matrix.os == 'windows-2019' @@ -78,9 +76,89 @@ jobs: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} - CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 with: name: ${{ matrix.accelerator }}-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl + + publish-to-accelera-pypi: + name: >- + Publish Python 🐍 distribution 📦 to Acellera PyPI + needs: + - build + runs-on: ubuntu-latest + permissions: # Needed for GCP authentication + contents: "read" + id-token: "write" + strategy: + fail-fast: false + matrix: + accelerator: [cpu, cu118, cu124, hip] + + steps: + - uses: actions/checkout@v4 # Needed for GCP authentication for some reason + + - name: Set up Cloud SDK + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.GCP_PYPI_SERVICE_ACCOUNT }} + + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + pattern: "${{ matrix.accelerator }}-cibw-wheels*" + path: dist/ + merge-multiple: true + + - name: Publish distribution 📦 to Acellera PyPI + run: | + pip install build twine keyring keyrings.google-artifactregistry-auth + pip install -U packaging + twine upload --repository-url https://us-central1-python.pkg.dev/pypi-packages-455608/${{ matrix.accelerator }} dist/* --verbose --skip-existing + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - build + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + path: dist/ + merge-multiple: true + + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 + with: + inputs: >- + ./dist/*.whl + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + "$GITHUB_REF_NAME" + --repo "$GITHUB_REPOSITORY" + --notes "" + + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + "$GITHUB_REF_NAME" dist/** + --repo "$GITHUB_REPOSITORY" diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000000..45eab0be08 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,9 @@ +name: Whole + +on: [push] + +jobs: + publish: + if: startsWith(github.event.ref, 'refs/tags/v') + uses: ./.github/workflows/publish.yml + secrets: inherit From 865d989692f4f2210b029717e57f55bb3848c21b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 11:24:25 +0300 Subject: [PATCH 26/75] quick test with just 3.10 --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6fa465ea8d..ea5b967e8f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,6 +66,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" ACCELERATOR: ${{ matrix.accelerator }} + CIBW_BUILD: "cp310-*" - name: Build wheels if: matrix.os == 'windows-2019' @@ -76,6 +77,7 @@ jobs: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} + CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 with: From 2ec36e4c1e7255e0fae70c21a6a6f45b8caf93a0 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 12:14:09 +0300 Subject: [PATCH 27/75] build all versions --- .github/workflows/publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ea5b967e8f..6fa465ea8d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,7 +66,6 @@ jobs: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" ACCELERATOR: ${{ matrix.accelerator }} - CIBW_BUILD: "cp310-*" - name: Build wheels if: matrix.os == 'windows-2019' @@ -77,7 +76,6 @@ jobs: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} - CIBW_BUILD: "cp310-*" - uses: actions/upload-artifact@v4 with: From 20bc5d6ceae233803634855b802fe92813b128a6 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 12:57:44 +0300 Subject: [PATCH 28/75] can't use setuptools versioning since it will be inconsistent with the C++ version --- .github/workflows/publish.yml | 2 ++ CMakeLists.txt | 2 +- wrappers/python/pyproject.toml | 5 +---- wrappers/python/setup.py | 4 ++++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6fa465ea8d..363acf7b76 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,6 +66,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" ACCELERATOR: ${{ matrix.accelerator }} + VERSION_SUFFIX: "rc1" - name: Build wheels if: matrix.os == 'windows-2019' @@ -76,6 +77,7 @@ jobs: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} + VERSION_SUFFIX: "rc1" - uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index f7f6ffce49..1aae41d343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,7 @@ ENDIF (NOT CMAKE_CXX_FLAGS_RELEASE) SET(OPENMM_LIBRARY_NAME OpenMM) SET(OPENMM_MAJOR_VERSION 8) SET(OPENMM_MINOR_VERSION 2) -SET(OPENMM_BUILD_VERSION 0) +SET(OPENMM_BUILD_VERSION 1) ADD_DEFINITIONS(-DOPENMM_LIBRARY_NAME=${OPENMM_LIBRARY_NAME} -DOPENMM_MAJOR_VERSION=${OPENMM_MAJOR_VERSION} diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index b130888631..bb3890c33f 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -18,9 +18,6 @@ dependencies = [ "Bug Tracker" = "https://github.com/openmm/openmm/issues" "Download URL" = "https://openmm.org" -[tool.setuptools_scm] -root = "../.." - [tool.setuptools.packages.find] include = ["openmm*"] @@ -39,7 +36,7 @@ test-requires = ["pytest"] test-command = "pytest {project}/wrappers/python/tests" manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -environment-pass = ["ACCELERATOR", "OPENCL_PATH"] +environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] # container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.windows] diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 669303cd66..c882289192 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -126,6 +126,10 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, build_info=BUILD_INFO): from setuptools import Extension setupKeywords = {} + setupKeywords["version"] = "%s.%s.%s%s" % (major_version_num, + minor_version_num, + build_info, + os.getenv('VERSION_SUFFIX', '')) setupKeywords["packages"] = [ "simtk", "simtk.unit", From 2d7344c4475042b9d03169facc3329789f2471d0 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 16:18:25 +0300 Subject: [PATCH 29/75] add runtime requirements for CUDA packages --- wrappers/python/setup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index c882289192..651b41d7c1 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -84,7 +84,6 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION """ cnt = """ -import os # THIS FILE IS GENERATED FROM OPENMM SETUP.PY short_version = '%(version)s' version = '%(version)s' @@ -145,6 +144,15 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, "openmm.app.internal.pdbx.reader", "openmm.app.internal.pdbx.writer"] + setupKeywords["install_requires"] = ["numpy"] + if os.getenv("ACCELERATOR", "") in ("cu118", "cu124"): + cuda_ver = os.getenv("ACCELERATOR", "")[2:4] + setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', + f'nvidia-cuda-nvcc-cu{cuda_ver}', + f'nvidia-cuda-nvrtc-cu{cuda_ver}', + f'nvidia-cuda-cupti-cu{cuda_ver}', + f'nvidia-cufft-cu{cuda_ver}'] + define_macros = [('MAJOR_VERSION', major_version_num), ('MINOR_VERSION', minor_version_num)] From c46457a3f1d32ba3264b0545beebb66298bb4864 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Tue, 8 Apr 2025 18:35:08 +0300 Subject: [PATCH 30/75] get dependencies dynamically --- wrappers/python/pyproject.toml | 5 +---- wrappers/python/setup.py | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index bb3890c33f..054c9ab25a 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -5,13 +5,10 @@ authors = [{ name = "Peter Eastman", email = "peastman@stanford.edu" }] readme = "README.md" license = "PSF-2.0" requires-python = ">=3.8" -dynamic = ["version"] +dynamic = ["version", "dependencies"] classifiers = [ "Programming Language :: Python :: 3", ] -dependencies = [ - "numpy" -] [project.urls] "Homepage" = "https://openmm.org" diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 651b41d7c1..a0fd098990 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -85,6 +85,8 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION cnt = """ # THIS FILE IS GENERATED FROM OPENMM SETUP.PY +from openmm import openmm_library_path + short_version = '%(version)s' version = '%(version)s' full_version = '%(full_version)s' From b53e180a9413a1a31bce243a4433d912ee8e2313 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 17 Apr 2025 12:56:03 +0300 Subject: [PATCH 31/75] cuda 12.6 releases --- .github/workflows/publish.yml | 6 +++++- .../prepare_build_environment_linux.sh | 14 ++++++++++++++ .../prepare_build_environment_windows.sh | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 363acf7b76..fb07d42e71 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,18 +12,22 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] - accelerator: [cpu, cu118, cu124, hip] + accelerator: [cpu, cu118, cu124, cu126, hip] exclude: - os: ubuntu-24.04-arm accelerator: cu118 - os: ubuntu-24.04-arm accelerator: cu124 + - os: ubuntu-24.04-arm + accelerator: cu126 - os: ubuntu-24.04-arm accelerator: hip - os: macos-latest accelerator: cu118 - os: macos-latest accelerator: cu124 + - os: macos-latest + accelerator: cu126 - os: macos-latest accelerator: hip diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index 260044592f..dd4e2c658e 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -34,6 +34,20 @@ if [ "$ACCELERATOR" == "cu124" ]; then export CUDA_HOME="/usr/local/cuda" fi +if [ "$ACCELERATOR" == "cu126" ]; then + # Install CUDA 12.6 + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-compiler-12-6-12.6.3-1 \ + cuda-libraries-12-6-12.6.3-1 \ + cuda-libraries-devel-12-6-12.6.3-1 + + ln -s cuda-12.6 /usr/local/cuda + + export CUDA_HOME="/usr/local/cuda" +fi + if [ "$ACCELERATOR" == "hip" ]; then # Install HIP 6.2 dnf install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 78aed39aad..3cbeba0112 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -17,6 +17,13 @@ if [ "$ACCELERATOR" == "cu124" ]; then rm cuda.exe fi +if [ "$ACCELERATOR" == "cu126" ]; then + CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_551.61_windows.exe + ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 + rm cuda.exe +fi + if [ "$ACCELERATOR" == "hip" ]; then curl.exe --output HIP.exe --url https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe ./HIP.exe -install From ac28a564d4486ac65ce44586e1e144120f40ae8d Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 17 Apr 2025 15:03:00 +0300 Subject: [PATCH 32/75] correct build --- .../cibuildwheel_support/prepare_build_environment_windows.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 3cbeba0112..59631f16ee 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -19,7 +19,7 @@ fi if [ "$ACCELERATOR" == "cu126" ]; then CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" - curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_551.61_windows.exe + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 rm cuda.exe fi From 9a6652453b588812ef7a66ca68c2c28e3317d5ab Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 17 Apr 2025 16:06:34 +0300 Subject: [PATCH 33/75] forgot the upload part --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fb07d42e71..2c43f30352 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: false matrix: - accelerator: [cpu, cu118, cu124, hip] + accelerator: [cpu, cu118, cu124, cu126, hip] steps: - uses: actions/checkout@v4 # Needed for GCP authentication for some reason From 9705b682a0f596c3c6ba68b8b7210c7ca8fe4b30 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 17 Apr 2025 16:23:44 +0300 Subject: [PATCH 34/75] add simtk also to the package --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 054c9ab25a..fb5317154e 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -16,7 +16,7 @@ classifiers = [ "Download URL" = "https://openmm.org" [tool.setuptools.packages.find] -include = ["openmm*"] +include = ["openmm*", "simtk*"] # [tool.setuptools.exclude-package-data] From 1284ed1afc66928f209a664c316f93da8b9bf0b3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 24 Apr 2025 13:34:29 +0300 Subject: [PATCH 35/75] switch to CXX11_ABI=1 since pytorch also moved to it and we need to keep compatibility between the two for openmm-torch --- .../cibuildwheel_support/prepare_build_environment_linux.sh | 2 +- wrappers/python/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index dd4e2c658e..81d807cdf0 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -60,7 +60,7 @@ mkdir -p openmm-install cd build cmake .. \ -DCMAKE_INSTALL_PREFIX=openmm-install \ - -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' \ + -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=1' \ -DOPENMM_BUILD_OPENCL_LIB=ON \ -DOPENCL_INCLUDE_DIR=/usr/include/CL \ -DOPENCL_LIBRARY=/usr/lib64/libOpenCL.so.1 diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index a0fd098990..2ff27a8da7 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -175,7 +175,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, openmm_include_path = 'openmm/include' openmm_lib_path = 'openmm/lib' - extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'] + extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=1'] extra_link_args=[] if platform.system() == "Windows": define_macros.append( ('WIN32', None) ) From 527b9772d2192642edc32ab30f4f1a1bdb9b89ba Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 24 Apr 2025 13:48:46 +0300 Subject: [PATCH 36/75] cuda 12.8 release --- .github/workflows/publish.yml | 8 ++++---- .../prepare_build_environment_linux.sh | 12 ++++++------ .../prepare_build_environment_windows.sh | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2c43f30352..8b9458e5c0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,14 +12,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] - accelerator: [cpu, cu118, cu124, cu126, hip] + accelerator: [cpu, cu118, cu124, cu128, hip] exclude: - os: ubuntu-24.04-arm accelerator: cu118 - os: ubuntu-24.04-arm accelerator: cu124 - os: ubuntu-24.04-arm - accelerator: cu126 + accelerator: cu128 - os: ubuntu-24.04-arm accelerator: hip - os: macos-latest @@ -27,7 +27,7 @@ jobs: - os: macos-latest accelerator: cu124 - os: macos-latest - accelerator: cu126 + accelerator: cu128 - os: macos-latest accelerator: hip @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: false matrix: - accelerator: [cpu, cu118, cu124, cu126, hip] + accelerator: [cpu, cu118, cu124, cu128, hip] steps: - uses: actions/checkout@v4 # Needed for GCP authentication for some reason diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index 81d807cdf0..ebcf7ea65d 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -34,16 +34,16 @@ if [ "$ACCELERATOR" == "cu124" ]; then export CUDA_HOME="/usr/local/cuda" fi -if [ "$ACCELERATOR" == "cu126" ]; then - # Install CUDA 12.6 +if [ "$ACCELERATOR" == "cu128" ]; then + # Install CUDA 12.8 dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo dnf install --setopt=obsoletes=0 -y \ - cuda-compiler-12-6-12.6.3-1 \ - cuda-libraries-12-6-12.6.3-1 \ - cuda-libraries-devel-12-6-12.6.3-1 + cuda-compiler-12-8-12.8.1-1 \ + cuda-libraries-12-8-12.8.1-1 \ + cuda-libraries-devel-12-8-12.8.1-1 - ln -s cuda-12.6 /usr/local/cuda + ln -s cuda-12.8 /usr/local/cuda export CUDA_HOME="/usr/local/cuda" fi diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 59631f16ee..e0503b2f65 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -17,10 +17,10 @@ if [ "$ACCELERATOR" == "cu124" ]; then rm cuda.exe fi -if [ "$ACCELERATOR" == "cu126" ]; then - CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" - curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe - ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 +if [ "$ACCELERATOR" == "cu128" ]; then + CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8" + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe + ./cuda.exe -s nvcc_12.8 nvrtc_12.8 nvrtc_dev_12.8 cudart_12.8 cufft_12.8 cufft_dev_12.8 cuda_profiler_api_12.8 rm cuda.exe fi From e53385bab5162f1dc72274c625a68bb563d447fd Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 25 Apr 2025 10:34:58 +0300 Subject: [PATCH 37/75] more cuda versions to be compatible with pytorch releases --- .github/workflows/publish.yml | 9 +++++--- .../prepare_build_environment_linux.sh | 22 ++++++++++++------- .../prepare_build_environment_windows.sh | 17 +++++++------- wrappers/python/setup.py | 2 +- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8b9458e5c0..cea30b8d00 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,12 +12,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] - accelerator: [cpu, cu118, cu124, cu128, hip] + accelerator: [cpu, cu118, cu124, cu126, cu128, hip] exclude: - os: ubuntu-24.04-arm accelerator: cu118 - os: ubuntu-24.04-arm accelerator: cu124 + - os: ubuntu-24.04-arm + accelerator: cu126 - os: ubuntu-24.04-arm accelerator: cu128 - os: ubuntu-24.04-arm @@ -26,6 +28,8 @@ jobs: accelerator: cu118 - os: macos-latest accelerator: cu124 + - os: macos-latest + accelerator: cu126 - os: macos-latest accelerator: cu128 - os: macos-latest @@ -80,7 +84,6 @@ jobs: CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} - CUDA_PATH: ${{ matrix.accelerator == 'cu118' && 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8' || 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4' }} VERSION_SUFFIX: "rc1" - uses: actions/upload-artifact@v4 @@ -100,7 +103,7 @@ jobs: strategy: fail-fast: false matrix: - accelerator: [cpu, cu118, cu124, cu128, hip] + accelerator: [cpu, cu118, cu124, cu126, cu128, hip] steps: - uses: actions/checkout@v4 # Needed for GCP authentication for some reason diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index ebcf7ea65d..2120cec828 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -18,9 +18,7 @@ if [ "$ACCELERATOR" == "cu118" ]; then ln -s cuda-11.8 /usr/local/cuda export CUDA_HOME="/usr/local/cuda" -fi - -if [ "$ACCELERATOR" == "cu124" ]; then +elif [ "$ACCELERATOR" == "cu124" ]; then # Install CUDA 12.4 dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo @@ -32,9 +30,19 @@ if [ "$ACCELERATOR" == "cu124" ]; then ln -s cuda-12.4 /usr/local/cuda export CUDA_HOME="/usr/local/cuda" -fi +elif [ "$ACCELERATOR" == "cu126" ]; then + # Install CUDA 12.6 + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-compiler-12-6-12.6.3-1 \ + cuda-libraries-12-6-12.6.3-1 \ + cuda-libraries-devel-12-6-12.6.3-1 -if [ "$ACCELERATOR" == "cu128" ]; then + ln -s cuda-12.4 /usr/local/cuda + + export CUDA_HOME="/usr/local/cuda" +elif [ "$ACCELERATOR" == "cu128" ]; then # Install CUDA 12.8 dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo @@ -46,9 +54,7 @@ if [ "$ACCELERATOR" == "cu128" ]; then ln -s cuda-12.8 /usr/local/cuda export CUDA_HOME="/usr/local/cuda" -fi - -if [ "$ACCELERATOR" == "hip" ]; then +elif [ "$ACCELERATOR" == "hip" ]; then # Install HIP 6.2 dnf install -y https://repo.radeon.com/amdgpu-install/6.2.2/el/8.10/amdgpu-install-6.2.60202-1.el8.noarch.rpm dnf install -y rocm-device-libs hip-devel hip-runtime-amd hipcc diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index e0503b2f65..71ffbae87b 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -8,23 +8,22 @@ if [ "$ACCELERATOR" == "cu118" ]; then curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe ./cuda.exe -s nvcc_11.8 nvrtc_11.8 nvrtc_dev_11.8 cudart_11.8 cufft_11.8 cufft_dev_11.8 cuda_profiler_api_11.8 rm cuda.exe -fi - -if [ "$ACCELERATOR" == "cu124" ]; then +elif [ "$ACCELERATOR" == "cu124" ]; then CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 cuda_profiler_api_12.4 rm cuda.exe -fi - -if [ "$ACCELERATOR" == "cu128" ]; then +elif [ "$ACCELERATOR" == "cu126" ]; then + CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe + ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 + rm cuda.exe +elif [ "$ACCELERATOR" == "cu128" ]; then CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe ./cuda.exe -s nvcc_12.8 nvrtc_12.8 nvrtc_dev_12.8 cudart_12.8 cufft_12.8 cufft_dev_12.8 cuda_profiler_api_12.8 rm cuda.exe -fi - -if [ "$ACCELERATOR" == "hip" ]; then +elif [ "$ACCELERATOR" == "hip" ]; then curl.exe --output HIP.exe --url https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe ./HIP.exe -install rm HIP.exe diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 2ff27a8da7..2a0f43b81b 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -147,7 +147,7 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, "openmm.app.internal.pdbx.writer"] setupKeywords["install_requires"] = ["numpy"] - if os.getenv("ACCELERATOR", "") in ("cu118", "cu124"): + if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', f'nvidia-cuda-nvcc-cu{cuda_ver}', From 485911ae4a60e1cff9b65452e6b990c3903dd2aa Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 25 Apr 2025 11:03:46 +0300 Subject: [PATCH 38/75] fix test file paths --- wrappers/python/tests/TestDcdFile.py | 4 ++-- wrappers/python/tests/TestPdbxFile.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wrappers/python/tests/TestDcdFile.py b/wrappers/python/tests/TestDcdFile.py index d2e9869f29..e7bdbc0696 100644 --- a/wrappers/python/tests/TestDcdFile.py +++ b/wrappers/python/tests/TestDcdFile.py @@ -133,7 +133,7 @@ def testAtomSubset(self): def testAppendAtomCountMismatch(self): """Test that appending to a DCD file with a different number of atoms raises an error.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) @@ -166,7 +166,7 @@ def testAppendAtomCountMismatch(self): def testAppendLongCommentBlock(self): """Test appending to an existing trajectory with a long comment block.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') + pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) diff --git a/wrappers/python/tests/TestPdbxFile.py b/wrappers/python/tests/TestPdbxFile.py index 5ddd391009..38f0d6f43f 100644 --- a/wrappers/python/tests/TestPdbxFile.py +++ b/wrappers/python/tests/TestPdbxFile.py @@ -149,7 +149,7 @@ def testBonds(self): def testChemCompBonds(self): """Test creating bonds based on chem_comp_bond records.""" - pdb = PDBxFile('systems/6mvz.cif') + pdb = PDBxFile(os.path.join(curr_dir, 'systems', '6mvz.cif')) def bondCount(res1, atom1, res2, atom2): count = 0 From 81a5b6df31dfb64437547977291aff0408829e9b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 28 Apr 2025 16:23:12 +0300 Subject: [PATCH 39/75] fix cuda detection on Windows --- .../prepare_build_environment_windows.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 71ffbae87b..dd10df9951 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -4,25 +4,33 @@ set -e set -x if [ "$ACCELERATOR" == "cu118" ]; then - CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe ./cuda.exe -s nvcc_11.8 nvrtc_11.8 nvrtc_dev_11.8 cudart_11.8 cufft_11.8 cufft_dev_11.8 cuda_profiler_api_11.8 rm cuda.exe + # Move CUDA folder to a path without spaces + mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" /c/CUDA + export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "cu124" ]; then - CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 cuda_profiler_api_12.4 rm cuda.exe + # Move CUDA folder to a path without spaces + mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" /c/CUDA + export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "cu126" ]; then - CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 rm cuda.exe + # Move CUDA folder to a path without spaces + mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" /c/CUDA + export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "cu128" ]; then - CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8" curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe ./cuda.exe -s nvcc_12.8 nvrtc_12.8 nvrtc_dev_12.8 cudart_12.8 cufft_12.8 cufft_dev_12.8 cuda_profiler_api_12.8 rm cuda.exe + # Move CUDA folder to a path without spaces + mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8" /c/CUDA + export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "hip" ]; then curl.exe --output HIP.exe --url https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe ./HIP.exe -install From d74f35335acad36a467104c440825f39c69ffc85 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 12:08:50 +0300 Subject: [PATCH 40/75] run tests from inside test folder --- .github/workflows/publish.yml | 3 --- wrappers/python/pyproject.toml | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cea30b8d00..7de2cab4f3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -71,8 +71,6 @@ jobs: shell: bash -l {0} run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: - CIBW_BEFORE_ALL_LINUX: "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" - CIBW_BEFORE_ALL_MACOS: "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" ACCELERATOR: ${{ matrix.accelerator }} VERSION_SUFFIX: "rc1" @@ -81,7 +79,6 @@ jobs: shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: - CIBW_BEFORE_ALL_WINDOWS: "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} VERSION_SUFFIX: "rc1" diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index fb5317154e..dc8a5ad4b4 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -30,21 +30,24 @@ build-backend = "setuptools.build_meta" [tool.cibuildwheel] skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] -test-command = "pytest {project}/wrappers/python/tests" +test-command = "cd {project}/wrappers/python/tests; pytest" manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] # container-engine = "docker; create_args: --gpus all" [tool.cibuildwheel.windows] -test-command = "pytest {project}\\wrappers\\python\\tests" +before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" +test-command = "cd {project}/wrappers/python/tests; pytest" [tool.cibuildwheel.linux] +before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" repair-wheel-command = [ "auditwheel repair --exclude libOpenMM.so --exclude libOpenMMCUDA.so --exclude libOpenMMHIP.so --exclude libOpenMMOpenCL.so --exclude libOpenMMDrude.so --exclude libOpenMMAmoeba.so --exclude libOpenMMRPMD.so --exclude libOpenCL.so.1 --exclude libcuda.so.1 --exclude libcufft.so.11 --exclude libcufft.so.10 --exclude libnvrtc.so.11.2 --exclude libnvrtc.so.12 --exclude libhiprtc.so.6 --exclude libamdhip64.so.6 -w {dest_dir} {wheel}", ] [tool.cibuildwheel.macos] +before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_osx.sh" repair-wheel-command = [ "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}", ] \ No newline at end of file From ca87f331c2231e4bfdda1d3cb5a066e9f324bb72 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 12:09:51 +0300 Subject: [PATCH 41/75] undo path changes in OpenMM tests --- wrappers/python/tests/TestAmberInpcrdFile.py | 15 +-- wrappers/python/tests/TestAmberPrmtopFile.py | 38 +++--- wrappers/python/tests/TestCharmmFiles.py | 125 +++++++++--------- .../python/tests/TestCheckpointReporter.py | 4 +- wrappers/python/tests/TestDcdFile.py | 14 +- wrappers/python/tests/TestDesmondDMSFile.py | 10 +- wrappers/python/tests/TestForceField.py | 70 +++++----- wrappers/python/tests/TestGenerators.py | 4 +- wrappers/python/tests/TestGromacsGroFile.py | 5 +- wrappers/python/tests/TestGromacsTopFile.py | 32 ++--- wrappers/python/tests/TestIntegrators.py | 18 +-- wrappers/python/tests/TestModeller.py | 22 ++- .../python/tests/TestNumpyCompatibility.py | 5 +- wrappers/python/tests/TestPatches.py | 7 +- wrappers/python/tests/TestPdbFile.py | 16 +-- wrappers/python/tests/TestPdbReporter.py | 11 +- wrappers/python/tests/TestPdbxFile.py | 23 ++-- wrappers/python/tests/TestPickle.py | 8 +- wrappers/python/tests/TestSimulation.py | 18 +-- .../python/tests/TestStateDataReporter.py | 3 +- wrappers/python/tests/TestTopology.py | 6 +- wrappers/python/tests/TestXtcFile.py | 17 +-- 22 files changed, 201 insertions(+), 270 deletions(-) diff --git a/wrappers/python/tests/TestAmberInpcrdFile.py b/wrappers/python/tests/TestAmberInpcrdFile.py index a1aa863964..c93d3687e6 100644 --- a/wrappers/python/tests/TestAmberInpcrdFile.py +++ b/wrappers/python/tests/TestAmberInpcrdFile.py @@ -1,4 +1,3 @@ -import os import unittest from validateConstraints import * from openmm.app import * @@ -16,15 +15,13 @@ def compareByElement(array1, array2, cmp): cmp(x, y) -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestAmberInpcrdFile(unittest.TestCase): """Test the Amber inpcrd file parser""" def test_CrdVelBox(self): """ Test parsing ASCII restarts with crds, vels, and box """ cmp = self.assertAlmostEqual - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_vels_box.rst7')) + inpcrd = AmberInpcrdFile('systems/crds_vels_box.rst7') self.assertEqual(len(inpcrd.positions), 2101) compareByElement(inpcrd.positions[-1].value_in_unit(angstroms), [3.5958082, 8.4176792, -8.2954064], cmp) @@ -38,7 +35,7 @@ def test_NetCDF(self): """ Test NetCDF restart file parsing """ cmp = self.assertAlmostEqual - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'amber.ncrst')) + inpcrd = AmberInpcrdFile('systems/amber.ncrst') self.assertEqual(len(inpcrd.positions), 2101) compareByElement(inpcrd.positions[0].value_in_unit(angstroms), [6.82122492718229, 6.6276250662042, -8.51668999892245], @@ -51,24 +48,24 @@ def test_NetCDF(self): def test_CrdBox(self): """ Test parsing ASCII restarts with only crds and box """ - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_box.rst7')) + inpcrd = AmberInpcrdFile('systems/crds_box.rst7') self.assertEqual(len(inpcrd.positions), 18660) self.assertTrue(inpcrd.velocities is None) self.assertTrue(inpcrd.boxVectors is not None) def test_CrdVel(self): - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crds_vels.rst7')) + inpcrd = AmberInpcrdFile('systems/crds_vels.rst7') self.assertTrue(inpcrd.boxVectors is None) self.assertTrue(inpcrd.velocities is not None) def test_CrdOnly(self): - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'crdsonly.rst7')) + inpcrd = AmberInpcrdFile('systems/crdsonly.rst7') self.assertTrue(inpcrd.boxVectors is None) self.assertTrue(inpcrd.velocities is None) def test_CrdBoxTruncoct(self): # Check that the box vectors come out correct. - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'tz2.truncoct.rst7')) + inpcrd = AmberInpcrdFile('systems/tz2.truncoct.rst7') ac = Vec3(42.4388485, 0.0, 0.0) * angstroms bc = Vec3(-14.146281691908937, 40.011730483685835, 0.0) * angstroms cc = Vec3(-14.146281691908937, -20.0058628205162, 34.651176446201672) * angstroms diff --git a/wrappers/python/tests/TestAmberPrmtopFile.py b/wrappers/python/tests/TestAmberPrmtopFile.py index 4e9e769bc5..5f8678542d 100644 --- a/wrappers/python/tests/TestAmberPrmtopFile.py +++ b/wrappers/python/tests/TestAmberPrmtopFile.py @@ -7,19 +7,17 @@ from openmm.unit import * import openmm.app.element as elem -curr_dir = os.path.dirname(os.path.abspath(__file__)) - -inpcrd1 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.inpcrd')) -inpcrd3 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'ff14ipq.rst7')) -inpcrd4 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'Mg_water.inpcrd')) -inpcrd7 = AmberInpcrdFile(os.path.join(curr_dir, 'systems', '18protein.rst7')) -prmtop1 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.prmtop')) -prmtop2 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.prmtop')) -prmtop3 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'ff14ipq.parm7'), periodicBoxVectors=inpcrd3.boxVectors) -prmtop4 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'Mg_water.prmtop'), periodicBoxVectors=inpcrd4.boxVectors) -prmtop5 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'tz2.truncoct.parm7')) -prmtop6 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'gaffwat.parm7')) -prmtop7 = AmberPrmtopFile(os.path.join(curr_dir, 'systems', '18protein.parm7'), periodicBoxVectors=inpcrd7.boxVectors) +inpcrd1 = AmberInpcrdFile('systems/alanine-dipeptide-explicit.inpcrd') +inpcrd3 = AmberInpcrdFile('systems/ff14ipq.rst7') +inpcrd4 = AmberInpcrdFile('systems/Mg_water.inpcrd') +inpcrd7 = AmberInpcrdFile('systems/18protein.rst7') +prmtop1 = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop') +prmtop2 = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop') +prmtop3 = AmberPrmtopFile('systems/ff14ipq.parm7', periodicBoxVectors=inpcrd3.boxVectors) +prmtop4 = AmberPrmtopFile('systems/Mg_water.prmtop', periodicBoxVectors=inpcrd4.boxVectors) +prmtop5 = AmberPrmtopFile('systems/tz2.truncoct.parm7') +prmtop6 = AmberPrmtopFile('systems/gaffwat.parm7') +prmtop7 = AmberPrmtopFile('systems/18protein.parm7', periodicBoxVectors=inpcrd7.boxVectors) class TestAmberPrmtopFile(unittest.TestCase): @@ -309,14 +307,14 @@ def test_ImplicitSolventForces(self): nonbondedMethod = [NoCutoff, CutoffNonPeriodic, CutoffNonPeriodic, NoCutoff, NoCutoff] salt = [0.0, 0.0, 0.5, 0.5, 0.0]*(moles/liter) file = ['HCT_NoCutoff', 'OBC1_NonPeriodic', 'OBC2_NonPeriodic_Salt', 'GBn_NoCutoff_Salt', 'GBn2_NoCutoff'] - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') for i in range(5): system = prmtop2.createSystem(implicitSolvent=solventType[i], nonbondedMethod=nonbondedMethod[i], implicitSolventSaltConc=salt[i]) integrator = VerletIntegrator(0.001) context = Context(system, integrator, Platform.getPlatform("Reference")) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit-forces', file[i]+'.xml')) as infile: + with open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml') as infile: state2 = XmlSerializer.deserialize(infile.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -377,8 +375,8 @@ def test_with_dcd_reporter(self): def testChamber(self): """Test a prmtop file created with Chamber.""" - prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'ala3_solv.parm7')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) + prmtop = AmberPrmtopFile('systems/ala3_solv.parm7') + crd = CharmmCrdFile('systems/ala3_solv.crd') system = prmtop.createSystem() for i,f in enumerate(system.getForces()): f.setForceGroup(i) @@ -416,8 +414,8 @@ def testGBneckRadii(self): def testNucleicGBParametes(self): """Test that correct GB parameters are used for nucleic acids.""" - prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'DNA_mbondi3.prmtop')) - inpcrd = AmberInpcrdFile(os.path.join(curr_dir, 'systems', 'DNA_mbondi3.inpcrd')) + prmtop = AmberPrmtopFile('systems/DNA_mbondi3.prmtop') + inpcrd = AmberInpcrdFile('systems/DNA_mbondi3.inpcrd') sanderEnergy = [-19223.87993545, -19527.40433175, -19788.1070698] for solvent, expectedEnergy in zip([OBC2, GBn, GBn2], sanderEnergy): system = prmtop.createSystem(implicitSolvent=solvent, gbsaModel=None) @@ -458,7 +456,7 @@ def testAmberCMAP(self): def testEPConstraints(self): """Test different types of constraints when using extra particles""" - prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'peptide_with_tip4p.prmtop')) + prmtop = AmberPrmtopFile('systems/peptide_with_tip4p.prmtop') for constraints in (HBonds, AllBonds): system = prmtop.createSystem(constraints=constraints) integrator = VerletIntegrator(0.001*picoseconds) diff --git a/wrappers/python/tests/TestCharmmFiles.py b/wrappers/python/tests/TestCharmmFiles.py index a66943a13c..7ac43e13a4 100644 --- a/wrappers/python/tests/TestCharmmFiles.py +++ b/wrappers/python/tests/TestCharmmFiles.py @@ -14,9 +14,6 @@ else: from cStringIO import StringIO - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestCharmmFiles(unittest.TestCase): """Test the GromacsTopFile.createSystem() method.""" @@ -25,13 +22,12 @@ def setUp(self): """Set up the tests by loading the input files.""" # alanine tripeptide; no waters - self.psf_c = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.psf')) - self.psf_x = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.xpsf')) - self.psf_v = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.vpsf')) + self.psf_c = CharmmPsfFile('systems/ala_ala_ala.psf') + self.psf_x = CharmmPsfFile('systems/ala_ala_ala.xpsf') + self.psf_v = CharmmPsfFile('systems/ala_ala_ala.vpsf') self.params = CharmmParameterSet( - os.path.join(curr_dir, 'systems', 'charmm22.rtf'), - os.path.join(curr_dir, 'systems', 'charmm22.par')) - self.pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + 'systems/charmm22.rtf', 'systems/charmm22.par') + self.pdb = PDBFile('systems/ala_ala_ala.pdb') def test_NonbondedMethod(self): """Test both non-periodic methods for the systems""" @@ -107,9 +103,9 @@ def test_HydrogenMass(self): def test_DrudeMass(self): """Test that setting the mass of Drude particles works correctly.""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) + psf = CharmmPsfFile('systems/ala3_solv_drude.psf') + crd = CharmmCrdFile('systems/ala3_solv_drude.crd') + params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') system = psf.createSystem(params, drudeMass=0) trueMass = [system.getParticleMass(i) for i in range(system.getNumParticles())] drudeMass = 0.3*amu @@ -134,10 +130,10 @@ def test_DrudeMass(self): def test_NBFIX(self): """Tests CHARMM systems with NBFIX Lennard-Jones modifications""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500)*angstroms) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), - os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) + psf = CharmmPsfFile('systems/ala3_solv.psf', unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500)*angstroms) + crd = CharmmCrdFile('systems/ala3_solv.crd') + params = CharmmParameterSet('systems/par_all36_prot.prm', + 'systems/toppar_water_ions.str') # Turn off charges so we only test the Lennard-Jones energies for a in psf.atom_list: @@ -158,11 +154,9 @@ def test_NBFIX(self): def test_NBFIX14(self): """Tests CHARMM systems with NBFIX modifications to 1-4 interactions""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'chl1.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'chl1.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_lipid.prm'), - os.path.join(curr_dir, 'systems', 'par_all36_cgenff.prm'), - os.path.join(curr_dir, 'systems', 'toppar_all36_lipid_cholesterol.str')) + psf = CharmmPsfFile('systems/chl1.psf') + crd = CharmmCrdFile('systems/chl1.crd') + params = CharmmParameterSet('systems/par_all36_lipid.prm', 'systems/par_all36_cgenff.prm', 'systems/toppar_all36_lipid_cholesterol.str') # Turn off charges so we only test the Lennard-Jones energies for a in psf.atom_list: @@ -184,10 +178,9 @@ def test_NBFIX14(self): def test_NBThole(self): """Tests CHARMM system with NBTHole""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'cyt-gua-cyt.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'cyt-gua-cyt.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str'), - os.path.join(curr_dir, 'systems', 'toppar_drude_nucleic_acid_2017b.str')) + psf = CharmmPsfFile('systems/cyt-gua-cyt.psf') + crd = CharmmCrdFile('systems/cyt-gua-cyt.crd') + params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str','systems/toppar_drude_nucleic_acid_2017b.str') # Box dimensions (cubic box) psf.setBox(30.0*angstroms, 30.0*angstroms, 30.0*angstroms) @@ -204,7 +197,7 @@ def test_NBThole(self): def test_PSFSetUnitCellDimensions(self): """Test that setting the box via unit cell dimensions works correctly.""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) + psf = CharmmPsfFile('systems/ala3_solv_drude.psf') # Orthorhombic psf.setBox(2.1*nanometer, 2.3*nanometer, 2.4*nanometer) @@ -235,9 +228,9 @@ def test_PSFSetUnitCellDimensions(self): def test_Drude(self): """Test CHARMM systems with Drude force field""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) + psf = CharmmPsfFile('systems/ala3_solv_drude.psf') + crd = CharmmCrdFile('systems/ala3_solv_drude.crd') + params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') # Box dimensions (cubic box) psf.setBox(33.2*angstroms, 33.2*angstroms, 33.2*angstroms) @@ -255,10 +248,10 @@ def test_Drude(self): def test_Lonepair(self): """Test the lonepair facilities, in particular the colinear type of lonepairs""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'chlb_cgenff.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'chlb_cgenff.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'top_all36_cgenff.rtf'), - os.path.join(curr_dir, 'systems', 'par_all36_cgenff.prm')) + psf = CharmmPsfFile('systems/chlb_cgenff.psf') + crd = CharmmCrdFile('systems/chlb_cgenff.crd') + params = CharmmParameterSet('systems/top_all36_cgenff.rtf', + 'systems/par_all36_cgenff.prm') plat = Platform.getPlatform('Reference') system = psf.createSystem(params) con = Context(system, VerletIntegrator(2*femtoseconds), plat) @@ -277,7 +270,7 @@ def test_Lonepair(self): def test_InsCode(self): """ Test the parsing of PSF files that contain insertion codes in their residue numbers """ - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', '4TVP-dmj_wat-ion.psf')) + psf = CharmmPsfFile('systems/4TVP-dmj_wat-ion.psf') self.assertEqual(len(list(psf.topology.atoms())), 66264) self.assertEqual(len(list(psf.topology.residues())), 20169) self.assertEqual(len(list(psf.topology.bonds())), 46634) @@ -285,11 +278,11 @@ def test_InsCode(self): def testSystemOptions(self): """ Test various options in CharmmPsfFile.createSystem """ warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), + psf = CharmmPsfFile('systems/ala3_solv.psf', periodicBoxVectors=(Vec3(32.7119500, 0, 0)*angstroms, Vec3(0, 32.9959600, 0)*angstroms, Vec3(0, 0, 33.0071500)*angstroms)) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), - os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) + crd = CharmmCrdFile('systems/ala3_solv.crd') + params = CharmmParameterSet('systems/par_all36_prot.prm', + 'systems/toppar_water_ions.str') # Check some illegal options self.assertRaises(ValueError, lambda: @@ -321,10 +314,10 @@ def test_ImplicitSolventForces(self): context = Context(system, integrator, Platform.getPlatform("Reference")) context.setPositions(self.pdb.positions) state1 = context.getState(getForces=True) - #out = open(os.path.join(curr_dir, 'systems', 'ala-ala-ala-implicit-forces', file[i]+'.xml'), 'w') + #out = open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml', 'w') #out.write(XmlSerializer.serialize(state1)) #out.close() - with open(os.path.join(curr_dir, 'systems', 'ala-ala-ala-implicit-forces', file[i]+'.xml')) as xml: + with open('systems/ala-ala-ala-implicit-forces/'+file[i]+'.xml') as xml: state2 = XmlSerializer.deserialize(xml.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -333,11 +326,11 @@ def test_ImplicitSolventForces(self): def test_PermissiveRead(self): """Compare permissive and strict reading of Charmm parameters""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', '5dhfr_cube.psf')) - pdb = PDBFile(os.path.join(curr_dir, 'systems', '5dhfr_cube.pdb')) + psf = CharmmPsfFile('systems/5dhfr_cube.psf') + pdb = PDBFile('systems/5dhfr_cube.pdb') - params_strict = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all22_prot_with_mass.inp')) - params_permissive = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all22_prot.inp'), permissive=True) + params_strict = CharmmParameterSet('systems/par_all22_prot_with_mass.inp') + params_permissive = CharmmParameterSet('systems/par_all22_prot.inp', permissive=True) # Box dimensions (found from bounding box) psf.setBox(62.23*angstroms, 62.23*angstroms, 62.23*angstroms) @@ -368,7 +361,7 @@ def test_PermissiveRead(self): def test_Impropers(self): """Test CHARMM improper torsions.""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'improper.psf')) + psf = CharmmPsfFile('systems/improper.psf') system = psf.createSystem(self.params) force = [f for f in system.getForces() if isinstance(f, CustomTorsionForce)][0] group = force.getForceGroup() @@ -515,7 +508,7 @@ def test_Residues(self): hoh = ["O", "H1", "H2"] pot = ["POT"] cla = ["CLA"] - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) + psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') for residue in psf.topology.residues(): atoms = [atom.name for atom in residue.atoms()] if residue.name == "M14": @@ -532,11 +525,11 @@ def test_Residues(self): def test_NoLongRangeCorrection(self): """Test that long range correction is disabled.""" parameters = CharmmParameterSet( - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'envi.str'), - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.rtf'), - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.prm') + 'systems/charmm-solvated/envi.str', + 'systems/charmm-solvated/m14.rtf', + 'systems/charmm-solvated/m14.prm' ) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) + psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') psf.setBox(3.0584*nanometers,3.0584*nanometers,3.0584*nanometers) system = psf.createSystem(parameters, nonbondedMethod=PME) for force in system.getForces(): @@ -548,20 +541,20 @@ def test_NoLongRangeCorrection(self): def test_NoPsfWarning(self): """Test that PSF warning is not thrown.""" parameters = CharmmParameterSet( - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'envi.str'), - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.rtf'), - os.path.join(curr_dir, 'systems', 'charmm-solvated', 'm14.prm') + 'systems/charmm-solvated/envi.str', + 'systems/charmm-solvated/m14.rtf', + 'systems/charmm-solvated/m14.prm' ) with warnings.catch_warnings(): warnings.simplefilter("error", CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'charmm-solvated', 'isa_wat.3_kcl.m14.psf')) + psf = CharmmPsfFile('systems/charmm-solvated/isa_wat.3_kcl.m14.psf') psf.setBox(3.0584*nanometers,3.0584*nanometers,3.0584*nanometers) psf.createSystem(parameters, nonbondedMethod=PME) def test_NBXMod(self): """Test that all values of NBXMod are interpreted correctly.""" - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.crd')) - with open(os.path.join(curr_dir, 'systems', 'charmm22.par')) as parfile: + crd = CharmmCrdFile('systems/ala_ala_ala.crd') + with open('systems/charmm22.par') as parfile: par = parfile.read() # The following values were computed with CHARMM. modeEnergy = {0: 754318.20507, 1: 754318.20507, 2: 908.35224, 3: 59.65279, 4: -241.12856, 5: 39.13169} @@ -569,7 +562,7 @@ def test_NBXMod(self): with tempfile.NamedTemporaryFile(suffix='.par', mode='w', delete=False) as parfile: parfile.write(par.replace('nbxmod 5', 'nbxmod %d' % nbxmod)) parfile.close() - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'charmm22.rtf'), parfile.name) + params = CharmmParameterSet('systems/charmm22.rtf', parfile.name) os.remove(parfile.name) system = self.psf_c.createSystem(params, nonbondedMethod=NoCutoff) context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) @@ -579,9 +572,9 @@ def test_NBXMod(self): def test_Nonbonded_Exclusion(self): """Test that the 1-2, 1-3 and 1-4 pairs are correctly excluded or scaled.""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'MoS2.psf')) - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'MoS2.pdb')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'MoS2.prm')) + psf = CharmmPsfFile('systems/MoS2.psf') + pdb = PDBFile('systems/MoS2.pdb') + params = CharmmParameterSet('systems/MoS2.prm') system = psf.createSystem(params, nonbondedMethod=NoCutoff) context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) context.setPositions(pdb.positions) @@ -591,8 +584,8 @@ def test_Nonbonded_Exclusion(self): def test_Constraints(self): """Test that bond and angles constraints are correctly added into the system""" - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'water_methanol.psf')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'water_methanol.prm')) + psf = CharmmPsfFile('systems/water_methanol.psf') + params = CharmmParameterSet('systems/water_methanol.prm') # the system is made of one water molecule and one methanol molecule hBonds_water = [[0, 1], [1, 2]] hAngles_water = [[0, 2]] @@ -626,11 +619,11 @@ def test_Constraints(self): def test_Constraints_charmm(self): """Tests that CHARMM and OpenMM implementation of CHARMM force field produce the same constraints and energy""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv.psf'), + psf = CharmmPsfFile('systems/ala3_solv.psf', unitCellDimensions=Vec3(32.7119500, 32.9959600, 33.0071500) * angstroms) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'par_all36_prot.prm'), - os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) + crd = CharmmCrdFile('systems/ala3_solv.crd') + params = CharmmParameterSet('systems/par_all36_prot.prm', + 'systems/toppar_water_ions.str') plat = Platform.getPlatform('Reference') system_charmm = psf.createSystem(params, nonbondedMethod=PME, nonbondedCutoff=8 * angstroms) diff --git a/wrappers/python/tests/TestCheckpointReporter.py b/wrappers/python/tests/TestCheckpointReporter.py index 70fe152486..aac1e35582 100644 --- a/wrappers/python/tests/TestCheckpointReporter.py +++ b/wrappers/python/tests/TestCheckpointReporter.py @@ -5,12 +5,10 @@ import openmm as mm from openmm import unit -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestCheckpointReporter(unittest.TestCase): def setUp(self): - with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) as f: + with open('systems/alanine-dipeptide-implicit.pdb') as f: pdb = app.PDBFile(f) forcefield = app.ForceField('amber99sbildn.xml') system = forcefield.createSystem(pdb.topology, diff --git a/wrappers/python/tests/TestDcdFile.py b/wrappers/python/tests/TestDcdFile.py index e7bdbc0696..2bf54907c1 100644 --- a/wrappers/python/tests/TestDcdFile.py +++ b/wrappers/python/tests/TestDcdFile.py @@ -7,8 +7,6 @@ import os import struct -curr_dir = os.path.dirname(os.path.abspath(__file__)) - def _read_dcd_header(file): with open(file, "r+b") as f: @@ -22,7 +20,7 @@ class TestDCDFile(unittest.TestCase): def test_dcd(self): """ Test the DCD file """ fname = tempfile.mktemp(suffix='.dcd') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') natom = len(list(pdbfile.topology.atoms())) with open(fname, 'wb') as f: dcd = app.DCDFile(f, pdbfile.topology, 0.001) @@ -33,7 +31,7 @@ def test_dcd(self): def testLongTrajectory(self): """Test writing a trajectory that has more than 2^31 steps.""" fname = tempfile.mktemp(suffix='.dcd') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') natom = len(list(pdbfile.topology.atoms())) with open(fname, 'wb') as f: dcd = app.DCDFile(f, pdbfile.topology, 0.001, interval=1000000000) @@ -44,7 +42,7 @@ def testLongTrajectory(self): def testAppend(self): """Test appending to an existing trajectory.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) @@ -88,7 +86,7 @@ def testAppend(self): def testAtomSubset(self): """Test writing a DCD file containing a subset of atoms""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) @@ -133,7 +131,7 @@ def testAtomSubset(self): def testAppendAtomCountMismatch(self): """Test that appending to a DCD file with a different number of atoms raises an error.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) @@ -166,7 +164,7 @@ def testAppendAtomCountMismatch(self): def testAppendLongCommentBlock(self): """Test appending to an existing trajectory with a long comment block.""" fname = tempfile.mktemp(suffix='.dcd') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = app.ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) diff --git a/wrappers/python/tests/TestDesmondDMSFile.py b/wrappers/python/tests/TestDesmondDMSFile.py index 9fede1a8b9..fbe7c0bb6c 100644 --- a/wrappers/python/tests/TestDesmondDMSFile.py +++ b/wrappers/python/tests/TestDesmondDMSFile.py @@ -5,23 +5,21 @@ from openmm.unit import * import openmm.app.element as elem -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestDesmondDMSFile(unittest.TestCase): def setUp(self): """Set up the tests by loading the input files.""" # alanine dipeptide with explicit water - path = os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit-amber99SBILDN-tip3p.dms') + path = os.path.join(os.path.dirname(__file__), 'systems/alanine-dipeptide-explicit-amber99SBILDN-tip3p.dms') self.dms = DesmondDMSFile(path) #nabumetone OPLS force field - path = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_lig.dms') + path = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_lig.dms') self.dms_opls1 = DesmondDMSFile(path) #beta-cyclodextrin/nabumetone complex OPLS force field - path1 = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_lig.dms') - path2 = os.path.join(curr_dir, 'systems', 'bcd-nabumetone_rcpt.dms') + path1 = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_lig.dms') + path2 = os.path.join(os.path.dirname(__file__), 'systems/bcd-nabumetone_rcpt.dms') self.dms_opls2 = DesmondDMSFile([path1,path2]) def test_NonbondedMethod(self): diff --git a/wrappers/python/tests/TestForceField.py b/wrappers/python/tests/TestForceField.py index 38a50ce598..009811807f 100644 --- a/wrappers/python/tests/TestForceField.py +++ b/wrappers/python/tests/TestForceField.py @@ -14,9 +14,6 @@ import os import warnings - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestForceField(unittest.TestCase): """Test the ForceField.createSystem() method.""" @@ -26,13 +23,13 @@ def setUp(self): """ # alanine dipeptide with explicit water - self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + self.pdb1 = PDBFile('systems/alanine-dipeptide-explicit.pdb') self.forcefield1 = ForceField('amber99sb.xml', 'tip3p.xml') self.topology1 = self.pdb1.topology self.topology1.setUnitCellDimensions(Vec3(2, 2, 2)) # alanine dipeptide with implicit water - self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + self.pdb2 = PDBFile('systems/alanine-dipeptide-implicit.pdb') self.forcefield2 = ForceField('amber99sb.xml', 'amber99_obc.xml') @@ -261,7 +258,7 @@ def test_DrudeMass(self): """Test that setting the mass of Drude particles works correctly.""" forcefield = ForceField('charmm_polar_2013.xml') - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + pdb = PDBFile('systems/ala_ala_ala.pdb') modeller = Modeller(pdb.topology, pdb.positions) modeller.addExtraParticles(forcefield) system = forcefield.createSystem(modeller.topology, drudeMass=0) @@ -300,13 +297,13 @@ def test_UnusedArgs(self): def test_Forces(self): """Compute forces and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'lysozyme-implicit.pdb')) + pdb = PDBFile('systems/lysozyme-implicit.pdb') system = self.forcefield2.createSystem(pdb.topology) integrator = VerletIntegrator(0.001) context = Context(system, integrator) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open(os.path.join(curr_dir, 'systems', 'lysozyme-implicit-forces.xml')) as input: + with open('systems/lysozyme-implicit-forces.xml') as input: state2 = XmlSerializer.deserialize(input.read()) numDifferences = 0 for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): @@ -330,7 +327,7 @@ def test_ImplicitSolventForces(self): context.setPositions(self.pdb2.positions) state1 = context.getState(getForces=True) if file[i] is not None: - with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit-forces', file[i]+'.xml')) as infile: + with open('systems/alanine-dipeptide-implicit-forces/'+file[i]+'.xml') as infile: state2 = XmlSerializer.deserialize(infile.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -610,7 +607,7 @@ def test_residueMatcher(self): ff = ForceField(StringIO(xml)) # Load a water box. - prmtop = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'water-box-216.prmtop')) + prmtop = AmberPrmtopFile('systems/water-box-216.prmtop') top = prmtop.topology # Building a System should fail, because two templates match each residue. @@ -681,7 +678,7 @@ def simpleTemplateGenerator(forcefield, residue): # # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml', StringIO(simple_ffxml_contents)) # Add the residue template generator. @@ -703,7 +700,7 @@ def simpleTemplateGenerator(forcefield, residue): # Test all systems with separate ForceField objects. for test in tests: # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', test['pdb_filename'])) + pdb = PDBFile(os.path.join('systems', test['pdb_filename'])) # Create a ForceField object. forcefield = ForceField(StringIO(simple_ffxml_contents)) # Add the residue template generator. @@ -719,7 +716,7 @@ def simpleTemplateGenerator(forcefield, residue): forcefield.registerTemplateGenerator(simpleTemplateGenerator) for test in tests: # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', test['pdb_filename'])) + pdb = PDBFile(os.path.join('systems', test['pdb_filename'])) # Parameterize system. system = forcefield.createSystem(pdb.topology, nonbondedMethod=test['nonbondedMethod']) # TODO: Test energies are finite? @@ -728,7 +725,7 @@ def test_getUnmatchedResidues(self): """Test retrieval of list of residues for which no templates are available.""" # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml') # Get list of unmatched residues. @@ -739,7 +736,7 @@ def test_getUnmatchedResidues(self): self.assertEqual(unmatched_residues[0].id, '163') # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) # Create a ForceField object. forcefield = ForceField('tip3p.xml') # Get list of unmatched residues. @@ -757,7 +754,7 @@ def test_generateTemplatesForUnmatchedResidues(self): # # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'nacl-water.pdb')) + pdb = PDBFile(os.path.join('systems', 'nacl-water.pdb')) # Create a ForceField object. forcefield = ForceField('tip3p.xml') # Get list of unmatched residues. @@ -800,7 +797,7 @@ def test_generateTemplatesForUnmatchedResidues(self): # # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) + pdb = PDBFile(os.path.join('systems', 'T4-lysozyme-L99A-p-xylene-implicit.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml', 'tip3p.xml', StringIO(simple_ffxml_contents)) # Get list of unique unmatched residues. @@ -820,7 +817,7 @@ def test_getMatchingTemplates(self): """Test retrieval of list of templates that match residues in a topology.""" # Load the PDB file. - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) # Create a ForceField object. forcefield = ForceField('amber99sb.xml') # Get list of matching residue templates. @@ -873,7 +870,7 @@ def test_Wildcard(self): def test_ScalingFactorCombining(self): """ Tests that FFs can be combined if their scaling factors are very close """ - forcefield = ForceField('amber99sb.xml', os.path.join(curr_dir, 'systems', 'test_amber_ff.xml')) + forcefield = ForceField('amber99sb.xml', os.path.join('systems', 'test_amber_ff.xml')) # This would raise an exception if it didn't work def test_MultipleFilesandForceTags(self): @@ -1106,9 +1103,10 @@ def test_CMAPTorsionGeneratorMapAssignment(self): def test_LennardJonesGenerator(self): """ Test the LennardJones generator""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ions.psf')) - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_water_ions.str')) + psf = CharmmPsfFile('systems/ions.psf') + pdb = PDBFile('systems/ions.pdb') + params = CharmmParameterSet('systems/toppar_water_ions.str' + ) # Box dimensions (found from bounding box) psf.setBox(12.009*angstroms, 12.338*angstroms, 11.510*angstroms) @@ -1251,7 +1249,7 @@ def test_IgnoreExternalBonds(self): def test_Includes(self): """Test using a ForceField that includes other files.""" - forcefield = ForceField(os.path.join(curr_dir, 'systems', 'ff_with_includes.xml')) + forcefield = ForceField(os.path.join('systems', 'ff_with_includes.xml')) self.assertTrue(len(forcefield._atomTypes) > 10) self.assertTrue('spce-O' in forcefield._atomTypes) self.assertTrue('HOH' in forcefield._templates) @@ -1268,7 +1266,7 @@ def test_ImpropersOrdering(self): """ - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'impropers_ordering_tetrapeptide.pdb')) + pdb = PDBFile('systems/impropers_ordering_tetrapeptide.pdb') # ff1 uses default ordering of impropers, ff2 uses "amber" for the one # problematic improper ff1 = ForceField('amber99sbildn.xml') @@ -1318,7 +1316,7 @@ def test_ImpropersOrdering_smirnoff(self): """ - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'formaldehyde.pdb')) + pdb = PDBFile('systems/formaldehyde.pdb') # ff1 uses default ordering of impropers, ff2 uses "amber" for the one # problematic improper ff = ForceField(StringIO(xml)) @@ -1337,7 +1335,7 @@ def test_ImpropersOrdering_smirnoff(self): def test_Disulfides(self): """Test that various force fields handle disulfides correctly.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'bpti.pdb')) + pdb = PDBFile('systems/bpti.pdb') for ff in ['amber99sb.xml', 'amber14-all.xml', 'amber19-all.xml', 'charmm36.xml', 'charmm36_2024.xml', 'amberfb15.xml', 'amoeba2013.xml']: forcefield = ForceField(ff) system = forcefield.createSystem(pdb.topology) @@ -1372,7 +1370,7 @@ def test_IdenticalTemplates(self): def test_CharmmPolar(self): """Test the CHARMM polarizable force field.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala_drude.pdb')) + pdb = PDBFile('systems/ala_ala_ala_drude.pdb') pdb.topology.setUnitCellDimensions(Vec3(3, 3, 3)) ff = ForceField('charmm_polar_2019.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1.2*nanometers) @@ -1454,7 +1452,7 @@ def test_InitializationScript(self): def test_Glycam(self): """Test computing energy with GLYCAM.""" ff = ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml') - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) + pdb = PDBFile('systems/glycopeptide.pdb') system = ff.createSystem(pdb.topology) for i, f in enumerate(system.getForces()): f.setForceGroup(i) @@ -1476,7 +1474,7 @@ def test_Glycam(self): def test_CustomNonbondedGenerator(self): """ Test the CustomNonbondedForce generator""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) + pdb = PDBFile('systems/ions.pdb') xml = """ @@ -1522,7 +1520,7 @@ def test_CustomNonbondedGenerator(self): self.assertAlmostEqual(energy1, energy2) def test_OpcEnergy(self): - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'opcbox.pdb')) + pdb = PDBFile('systems/opcbox.pdb') topology, positions = pdb.topology, pdb.positions self.assertEqual(len(positions), 864) forcefield = ForceField('opc.xml') @@ -1556,7 +1554,7 @@ def test_OpcEnergy(self): self.assertTrue(abs(energy1 - energy2) < energy_tolerance) def test_Opc3Energy(self): - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'opc3box.pdb')) + pdb = PDBFile('systems/opc3box.pdb') topology, positions = pdb.topology, pdb.positions self.assertEqual(len(positions), 648) forcefield = ForceField('opc3.xml') @@ -1598,7 +1596,7 @@ def setUp(self): """ - self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'amoeba-ion-in-water.pdb')) + self.pdb1 = PDBFile('systems/amoeba-ion-in-water.pdb') self.forcefield1 = ForceField('amoeba2013.xml') self.topology1 = self.pdb1.topology @@ -1672,14 +1670,14 @@ def test_RigidWater(self): def test_Forces(self): """Compute forces and compare them to ones generated with a previous version of OpenMM to ensure they haven't changed.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') forcefield = ForceField('amoeba2013.xml', 'amoeba2013_gk.xml') system = forcefield.createSystem(pdb.topology, polarization='direct') integrator = VerletIntegrator(0.001) context = Context(system, integrator, Platform.getPlatform('Reference')) context.setPositions(pdb.positions) state1 = context.getState(getForces=True) - with open(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-amoeba-forces.xml')) as input: + with open('systems/alanine-dipeptide-amoeba-forces.xml') as input: state2 = XmlSerializer.deserialize(input.read()) for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)): diff = norm(f1-f2) @@ -1702,7 +1700,7 @@ def computeAmoeba18Energies(self, filename): def test_Amoeba18BPTI(self): """Test that AMOEBA18 computes energies correctly for BPTI.""" - energies = self.computeAmoeba18Energies(os.path.join(curr_dir, 'systems', 'bpti.pdb')) + energies = self.computeAmoeba18Energies('systems/bpti.pdb') # Compare to values computed with Tinker. @@ -1719,7 +1717,7 @@ def test_Amoeba18BPTI(self): def test_Amoeba18Nucleic(self): """Test that AMOEBA18 computes energies correctly for DNA and RNA.""" - energies = self.computeAmoeba18Energies(os.path.join(curr_dir, 'systems', 'nucleic.pdb')) + energies = self.computeAmoeba18Energies('systems/nucleic.pdb') # Compare to values computed with Tinker. diff --git a/wrappers/python/tests/TestGenerators.py b/wrappers/python/tests/TestGenerators.py index 28506267f6..8a67347cfa 100644 --- a/wrappers/python/tests/TestGenerators.py +++ b/wrappers/python/tests/TestGenerators.py @@ -13,14 +13,12 @@ import os import warnings -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestGenerators(unittest.TestCase): """Test the various generators found in forcefield.py.""" def setUp(self): # alanine dipeptide with implicit water - self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + self.pdb1 = PDBFile('systems/alanine-dipeptide-implicit.pdb') def test_CustomHbondGenerator(self): diff --git a/wrappers/python/tests/TestGromacsGroFile.py b/wrappers/python/tests/TestGromacsGroFile.py index 2413362465..b18107bde0 100644 --- a/wrappers/python/tests/TestGromacsGroFile.py +++ b/wrappers/python/tests/TestGromacsGroFile.py @@ -3,16 +3,13 @@ from openmm import * from openmm.unit import * import openmm.app.element as elem -import os - -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestGromacsGroFile(unittest.TestCase): """Test the Gromacs GRO file parser""" def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'triclinic.gro')) + gro = GromacsGroFile('systems/triclinic.gro') self.assertEqual(len(gro.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), diff --git a/wrappers/python/tests/TestGromacsTopFile.py b/wrappers/python/tests/TestGromacsTopFile.py index 9d6bc3ef45..08ab6ecb2c 100644 --- a/wrappers/python/tests/TestGromacsTopFile.py +++ b/wrappers/python/tests/TestGromacsTopFile.py @@ -6,13 +6,9 @@ from openmm.app.gromacstopfile import _defaultGromacsIncludeDir import openmm.app.element as elem from numpy.testing import assert_allclose -import os GROMACS_INCLUDE = _defaultGromacsIncludeDir() - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - @unittest.skipIf(not os.path.exists(GROMACS_INCLUDE), 'GROMACS is not installed') class TestGromacsTopFile(unittest.TestCase): @@ -22,7 +18,7 @@ def setUp(self): """Set up the tests by loading the input files.""" # alanine dipeptide with explicit water - self.top1 = GromacsTopFile(os.path.join(curr_dir, 'systems', 'explicit.top'), unitCellDimensions=Vec3(6.223, 6.223, 6.223)*nanometers) + self.top1 = GromacsTopFile('systems/explicit.top', unitCellDimensions=Vec3(6.223, 6.223, 6.223)*nanometers) def test_NonbondedMethod(self): """Test all six options for the nonbondedMethod parameter.""" @@ -42,8 +38,8 @@ def test_NonbondedMethod(self): def test_ff99SBILDN(self): """ Test Gromacs topology #define replacement as used in ff99SB-ILDN """ - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'aidilnaaaaa.top')) - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'aidilnaaaaa.gro')) + top = GromacsTopFile('systems/aidilnaaaaa.top') + gro = GromacsGroFile('systems/aidilnaaaaa.gro') system = top.createSystem() for force in system.getForces(): if isinstance(force, PeriodicTorsionForce): @@ -56,8 +52,8 @@ def test_ff99SBILDN(self): def test_SMOG(self): """ Test to ensure that SMOG models can be run without problems """ - top = GromacsTopFile(os.path.join(curr_dir, 'systems', '2ci2.pdb.top')) - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', '2ci2.pdb.gro')) + top = GromacsTopFile('systems/2ci2.pdb.top') + gro = GromacsGroFile('systems/2ci2.pdb.gro') system = top.createSystem() context = Context(system, VerletIntegrator(1*femtosecond), @@ -68,8 +64,8 @@ def test_SMOG(self): def test_ionic(self): """Test simulating an ionic liquid""" - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'ionic.gro')) - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'ionic.top'), periodicBoxVectors=gro.getPeriodicBoxVectors()) + gro = GromacsGroFile('systems/ionic.gro') + top = GromacsTopFile('systems/ionic.top', periodicBoxVectors=gro.getPeriodicBoxVectors()) system = top.createSystem(nonbondedMethod=PME, nonbondedCutoff=1.2) for f in system.getForces(): if isinstance(f, CustomNonbondedForce): @@ -98,7 +94,7 @@ def test_Cutoff(self): def test_SwitchingFunction(self): """Test using a switching function.""" - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'ionic.top')) + top = GromacsTopFile('systems/ionic.top') for distance in (None, 0.8*nanometers): system = top.createSystem(nonbondedMethod=CutoffNonPeriodic, switchDistance=distance) for f in system.getForces(): @@ -162,8 +158,8 @@ def test_HydrogenMass(self): def test_VirtualParticle(self): """Test virtual particle works correctly.""" - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'bnz.top')) - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', 'bnz.gro')) + top = GromacsTopFile('systems/bnz.top') + gro = GromacsGroFile('systems/bnz.gro') for atom in top.topology.atoms(): if atom.name.startswith('C'): self.assertEqual(elem.carbon, atom.element) @@ -186,7 +182,7 @@ def test_VirtualParticle(self): def test_Vsite3Func1(self): """Test a three particle virtual site.""" - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'tip4pew.top')) + top = GromacsTopFile('systems/tip4pew.top') system = top.createSystem() self.assertEqual(3, system.getNumConstraints()) self.assertTrue(system.isVirtualSite(3)) @@ -201,7 +197,7 @@ def test_Vsite3Func1(self): def test_Vsite3Func4(self): """Test a three particle virtual site.""" - top = GromacsTopFile(os.path.join(curr_dir, 'systems', 'tip5p.top')) + top = GromacsTopFile('systems/tip5p.top') system = top.createSystem() self.assertEqual(3, system.getNumConstraints()) for i in (3, 4): @@ -221,8 +217,8 @@ def test_Vsite3Func4(self): def test_GROMOS(self): """Test a system using the GROMOS 54a7 force field.""" - top = GromacsTopFile(os.path.join(curr_dir, 'systems', '1ppt.top')) - gro = GromacsGroFile(os.path.join(curr_dir, 'systems', '1ppt.gro')) + top = GromacsTopFile('systems/1ppt.top') + gro = GromacsGroFile('systems/1ppt.gro') system = top.createSystem() for i, f in enumerate(system.getForces()): f.setForceGroup(i) diff --git a/wrappers/python/tests/TestIntegrators.py b/wrappers/python/tests/TestIntegrators.py index 7855ab805a..cff603b4d2 100644 --- a/wrappers/python/tests/TestIntegrators.py +++ b/wrappers/python/tests/TestIntegrators.py @@ -6,10 +6,6 @@ from openmm.app import * from openmm.unit import * import math, random -import os - - -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestIntegrators(unittest.TestCase): """Test Python Integrator classes""" @@ -17,7 +13,7 @@ class TestIntegrators(unittest.TestCase): def testMTSIntegratorExplicit(self): """Test the MTS integrator on an explicit solvent system""" # Create a periodic solvated system with PME - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -104,7 +100,7 @@ def testMTSIntegratorConstraints(self): def testBadGroups(self): """Test the MTS integrator with bad force group substeps.""" # Create a periodic solvated system with PME - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -128,7 +124,7 @@ def testBadGroups(self): def testMTSLangevinIntegrator(self): """Test the MTSLangevinIntegrator on an explicit solvent system""" # Create a periodic solvated system with PME - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -192,7 +188,7 @@ def get_final_velocities(nsubsteps): def testNoseHooverIntegrator(self): """Test partial thermostating in the NoseHooverIntegrator (only API)""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = ForceField('amber99sbildn.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=PME) @@ -207,9 +203,9 @@ def testNoseHooverIntegrator(self): def testDrudeNoseHooverIntegrator(self): """Test the DrudeNoseHooverIntegrator""" warnings.filterwarnings('ignore', category=CharmmPSFWarning) - psf = CharmmPsfFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.psf')) - crd = CharmmCrdFile(os.path.join(curr_dir, 'systems', 'ala3_solv_drude.crd')) - params = CharmmParameterSet(os.path.join(curr_dir, 'systems', 'toppar_drude_master_protein_2013e.str')) + psf = CharmmPsfFile('systems/ala3_solv_drude.psf') + crd = CharmmCrdFile('systems/ala3_solv_drude.crd') + params = CharmmParameterSet('systems/toppar_drude_master_protein_2013e.str') # Box dimensions (cubic box) psf.setBox(33.2*angstroms, 33.2*angstroms, 33.2*angstroms) diff --git a/wrappers/python/tests/TestModeller.py b/wrappers/python/tests/TestModeller.py index 3caddc88d7..068cfcc1ad 100644 --- a/wrappers/python/tests/TestModeller.py +++ b/wrappers/python/tests/TestModeller.py @@ -6,33 +6,29 @@ from openmm.app import * from openmm import * from openmm.unit import * -import os if sys.version_info >= (3, 0): from io import StringIO else: from cStringIO import StringIO - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestModeller(unittest.TestCase): """ Test the Modeller class. """ def setUp(self): # load the alanine dipeptide pdb file - self.pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + self.pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') self.topology_start = self.pdb.topology self.positions = self.pdb.positions self.forcefield = ForceField('amber10.xml', 'tip3p.xml') # load the T4-lysozyme-L99A receptor pdb file - self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'lysozyme-implicit.pdb')) + self.pdb2 = PDBFile('systems/lysozyme-implicit.pdb') self.topology_start2 = self.pdb2.topology self.positions2 = self.pdb2.positions # load the metallothionein pdb file - self.pdb3 = PDBFile(os.path.join(curr_dir, 'systems', '1T2Y.pdb')) + self.pdb3 = PDBFile('systems/1T2Y.pdb') self.topology_start3 = self.pdb3.topology self.positions3 = self.pdb3.positions @@ -138,7 +134,7 @@ def test_add(self): """ Test the add() method. """ # load the methanol-box pdb file - pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'methanol-box.pdb')) + pdb2 = PDBFile('systems/methanol-box.pdb') topology_toAdd = pdb2.topology positions_toAdd = pdb2.positions @@ -973,7 +969,7 @@ def test_addHydrogenspH11(self): def test_addHydrogensGlycam(self): """Test adding hydrogens for GLYCAM.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) + pdb = PDBFile('systems/glycopeptide.pdb') Modeller.loadHydrogenDefinitions('glycam-hydrogens.xml') modeller = Modeller(pdb.topology, pdb.positions) hydrogens = [a for a in modeller.topology.atoms() if a.element == element.hydrogen] @@ -991,7 +987,7 @@ def test_addHydrogensGlycam(self): def test_addSpecificHydrogens(self): """Test specifying exactly which hydrogens to add.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) + pdb = PDBFile('systems/glycopeptide.pdb') variants = [None]*pdb.topology.getNumResidues() for residue in pdb.topology.residues(): if residue.name != 'ALA': @@ -1237,7 +1233,7 @@ def test_multiSiteIon(self): def test_addMembrane(self): """Test adding a membrane to a realistic system.""" - mol = PDBxFile(os.path.join(curr_dir, 'systems', 'gpcr.cif')) + mol = PDBxFile('systems/gpcr.cif') modeller = Modeller(mol.topology, mol.positions) ff = ForceField('amber14-all.xml', 'amber14/tip3p.xml') @@ -1287,7 +1283,7 @@ def test_bondTypeAndOrderPreserved(self): """ # Given: an isolated molecule - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile("systems/alanine-dipeptide-implicit.pdb") topology, positions = pdb.topology, pdb.positions topology.setUnitCellDimensions(Vec3(3.5, 3.5, 3.5) * nanometers) # with some bonds carrying type and order information @@ -1334,7 +1330,7 @@ def test_bondTypeAndOrderPreserved(self): self.assertIn((Double, 2.0), [(b.type, b.order) for b in modeller.topology.bonds()]) # When (6): add a modeller (which also bears some bond info) - to_add = PDBFile(os.path.join(curr_dir, 'systems', 'methanol-box.pdb')) + to_add = PDBFile('systems/methanol-box.pdb') topology_to_add = to_add.topology positions_to_add = to_add.positions # add a dummy bond to the "to_add" system to check that it also is preserved diff --git a/wrappers/python/tests/TestNumpyCompatibility.py b/wrappers/python/tests/TestNumpyCompatibility.py index 7f7fb5a8d5..46b55a6ba0 100644 --- a/wrappers/python/tests/TestNumpyCompatibility.py +++ b/wrappers/python/tests/TestNumpyCompatibility.py @@ -2,7 +2,6 @@ from openmm import app import openmm as mm from openmm import unit -import os try: import numpy as np NUMPY_IMPORT_FAILED = False @@ -10,13 +9,11 @@ NUMPY_IMPORT_FAILED = True -curr_dir = os.path.dirname(os.path.abspath(__file__)) - @unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed') class TestNumpyCompatibility(unittest.TestCase): def setUp(self): - prmtop = app.AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'water-box-216.prmtop')) + prmtop = app.AmberPrmtopFile('systems/water-box-216.prmtop') system = prmtop.createSystem(nonbondedMethod=app.PME, nonbondedCutoff=0.9*unit.nanometers, diff --git a/wrappers/python/tests/TestPatches.py b/wrappers/python/tests/TestPatches.py index d5cac60774..1a3db2e322 100644 --- a/wrappers/python/tests/TestPatches.py +++ b/wrappers/python/tests/TestPatches.py @@ -10,9 +10,6 @@ from io import StringIO import os - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestPatches(unittest.TestCase): """Test ForceFields that use patches.""" @@ -263,7 +260,7 @@ def testAlaAlaAla(self): """ ff = ForceField(StringIO(xml)) - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + pdb = PDBFile(os.path.join('systems', 'ala_ala_ala.pdb')) system = ff.createSystem(pdb.topology) nb = system.getForce(0) expectedCharges = [0.1414, 0.2719, 0.2719, 0.2719, 0.0337, 0.0823, 0.0337, 0.0603, 0.0603, 0.0603, 0.5973, -0.5679, @@ -273,7 +270,7 @@ def testAlaAlaAla(self): self.assertEqual(expectedCharges[i], nb.getParticleParameters(i)[0].value_in_unit(elementary_charge)) def testDisulfidePatch(self): - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'bpti.pdb')) + pdb = PDBFile(os.path.join('systems', 'bpti.pdb')) ff = ForceField('amber99sb.xml') system1 = ff.createSystem(pdb.topology) diff --git a/wrappers/python/tests/TestPdbFile.py b/wrappers/python/tests/TestPdbFile.py index d1ee6022c9..430ce3b048 100644 --- a/wrappers/python/tests/TestPdbFile.py +++ b/wrappers/python/tests/TestPdbFile.py @@ -5,10 +5,6 @@ from openmm.unit import * import openmm.app.element as elem from io import StringIO -import os - - -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestPdbFile(unittest.TestCase): @@ -16,7 +12,7 @@ class TestPdbFile(unittest.TestCase): def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'triclinic.pdb')) + pdb = PDBFile('systems/triclinic.pdb') self.assertEqual(len(pdb.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), @@ -60,7 +56,7 @@ def compareFiles(pdb1, pdb2): self.assertEqual(atom1.name, atom2.name) self.assertEqual(atom1.residue.name, atom2.residue.name) - pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'triclinic.pdb')) + pdb1 = PDBFile('systems/triclinic.pdb') # First try writing to an open file object. @@ -82,13 +78,13 @@ def compareFiles(pdb1, pdb2): def test_BinaryStream(self): """Test reading a stream that was opened in binary mode.""" - with open(os.path.join(curr_dir, 'systems', 'triclinic.pdb'), 'rb') as infile: + with open('systems/triclinic.pdb', 'rb') as infile: pdb = PDBFile(infile) self.assertEqual(len(pdb.positions), 8) def test_ExtraParticles(self): """Test reading, and writing and re-reading of a file containing extra particle atoms.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'tip5p.pdb')) + pdb = PDBFile('systems/tip5p.pdb') for atom in pdb.topology.atoms(): if atom.index > 2: self.assertEqual(None, atom.element) @@ -103,7 +99,7 @@ def test_ExtraParticles(self): def test_AltLocs(self): """Test reading a file that includes AltLocs""" for filename in ['altlocs.pdb', 'altlocs2.pdb']: - pdb = PDBFile(os.path.join(curr_dir, 'systems', filename)) + pdb = PDBFile(f'systems/{filename}') self.assertEqual(1, pdb.topology.getNumResidues()) self.assertEqual(19, pdb.topology.getNumAtoms()) self.assertEqual(19, len(pdb.positions)) @@ -111,7 +107,7 @@ def test_AltLocs(self): def test_FormalCharges(self): """Test reading, and writing and re-reading of a file containing formal charges.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'formal-charges.pdb')) + pdb = PDBFile('systems/formal-charges.pdb') for atom in pdb.topology.atoms(): if atom.index == 8: self.assertEqual(+1, atom.formalCharge) diff --git a/wrappers/python/tests/TestPdbReporter.py b/wrappers/python/tests/TestPdbReporter.py index 81e7b930d3..852d891c27 100644 --- a/wrappers/python/tests/TestPdbReporter.py +++ b/wrappers/python/tests/TestPdbReporter.py @@ -7,9 +7,6 @@ import os import gc - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - def assertVecAlmostEqual(p1, p2, tol=1e-7): unit = p1.unit p1 = p1.value_in_unit(unit) @@ -22,7 +19,7 @@ def assertVecAlmostEqual(p1, p2, tol=1e-7): class TestPDBReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + self.pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') self.forcefield = app.ForceField('amber99sbildn.xml','tip3p.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) @@ -120,7 +117,7 @@ def testBondSubset(self): # use a testcase that has CONECT records in the input pdb file ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml','amber14/tip3pfb.xml') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) + pdb = app.PDBFile('systems/glycopeptide.pdb') # add in water molecules modeller = app.Modeller(pdb.topology, pdb.positions) @@ -160,7 +157,7 @@ def testBondSubset(self): class TestPDBxReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + self.pdb = app.PDBFile('systems/alanine-dipeptide-explicit.pdb') self.forcefield = app.ForceField('amber99sbildn.xml','tip3p.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) @@ -258,7 +255,7 @@ def testBondSubset(self): # use a testcase that has CONECT records in the input pdb file ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/GLYCAM_06j-1.xml','amber14/tip3pfb.xml') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'glycopeptide.pdb')) + pdb = app.PDBFile('systems/glycopeptide.pdb') # add in water molecules modeller = app.Modeller(pdb.topology, pdb.positions) diff --git a/wrappers/python/tests/TestPdbxFile.py b/wrappers/python/tests/TestPdbxFile.py index 38f0d6f43f..7ba276fb3c 100644 --- a/wrappers/python/tests/TestPdbxFile.py +++ b/wrappers/python/tests/TestPdbxFile.py @@ -7,16 +7,13 @@ import os from io import StringIO - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestPdbxFile(unittest.TestCase): """Test the PDBx/mmCIF file parser""" def test_FormatConversion(self): """Test conversion from PDB to PDBx""" - mol = PDBFile(os.path.join(curr_dir, 'systems', 'ala_ala_ala.pdb')) + mol = PDBFile('systems/ala_ala_ala.pdb') with tempfile.TemporaryDirectory() as tempdir: filename = os.path.join(tempdir, 'temp.pdbx') PDBxFile.writeFile(mol.topology, mol.positions, filename, keepIds=True) @@ -28,7 +25,7 @@ def test_FormatConversion(self): def test_Triclinic(self): """Test parsing a file that describes a triclinic box.""" - pdb = PDBxFile(os.path.join(curr_dir, 'systems', 'triclinic.pdbx')) + pdb = PDBxFile('systems/triclinic.pdbx') self.assertEqual(len(pdb.positions), 8) expectedPositions = [ Vec3(1.744, 2.788, 3.162), @@ -69,11 +66,11 @@ def assertVecAlmostEqual(self, p1, p2, tol=1e-7): def testReporterImplicit(self): """ Tests the PDBxReporter without PBC """ - parm = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.prmtop')) + parm = AmberPrmtopFile('systems/alanine-dipeptide-implicit.prmtop') system = parm.createSystem() sim = Simulation(parm.topology, system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) - sim.context.setPositions(PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')).getPositions()) + sim.context.setPositions(PDBFile('systems/alanine-dipeptide-implicit.pdb').getPositions()) sim.reporters.append(PDBxReporter('test.cif', 1)) sim.step(10) pdb = PDBxFile('test.cif') @@ -101,11 +98,11 @@ def assertAlmostEqualVec(self, vec1, vec2, *args, **kwargs): def testReporterExplicit(self): """ Tests the PDBxReporter with PBC """ - parm = AmberPrmtopFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.prmtop')) + parm = AmberPrmtopFile('systems/alanine-dipeptide-explicit.prmtop') system = parm.createSystem(nonbondedCutoff=1.0, nonbondedMethod=PME) sim = Simulation(parm.topology, system, VerletIntegrator(1*femtoseconds), Platform.getPlatform('Reference')) - orig_pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + orig_pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') sim.context.setPositions(orig_pdb.getPositions()) sim.context.setPeriodicBoxVectors(*parm.topology.getPeriodicBoxVectors()) sim.reporters.append(PDBxReporter('test.cif', 1)) @@ -135,7 +132,7 @@ def testReporterExplicit(self): def testBonds(self): """Test reading and writing a file that includes bonds.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'methanol_ions.pdb')) + pdb = PDBFile('systems/methanol_ions.pdb') output = StringIO() PDBxFile.writeFile(pdb.topology, pdb.positions, output) input = StringIO(output.getvalue()) @@ -149,7 +146,7 @@ def testBonds(self): def testChemCompBonds(self): """Test creating bonds based on chem_comp_bond records.""" - pdb = PDBxFile(os.path.join(curr_dir, 'systems', '6mvz.cif')) + pdb = PDBxFile('systems/6mvz.cif') def bondCount(res1, atom1, res2, atom2): count = 0 @@ -186,7 +183,7 @@ def bondCount(res1, atom1, res2, atom2): def testMultiChain(self): """Test reading and writing a file that includes multiple chains""" - cif_ori = PDBxFile(os.path.join(curr_dir, 'systems', 'multichain.pdbx')) + cif_ori = PDBxFile('systems/multichain.pdbx') output = StringIO() PDBxFile.writeFile(cif_ori.topology, cif_ori.positions, output, keepIds=True) @@ -202,7 +199,7 @@ def testMultiChain(self): def testInsertionCodes(self): """Test reading a file that uses insertion codes.""" - pdbx = PDBxFile(os.path.join(curr_dir, 'systems', 'insertions.pdbx')) + pdbx = PDBxFile('systems/insertions.pdbx') residues = list(pdbx.topology.residues()) self.assertEqual(7, len(residues)) names = ['PHE', 'ASP', 'LYS', 'ILE', 'LYS', 'ASN', 'TRP'] diff --git a/wrappers/python/tests/TestPickle.py b/wrappers/python/tests/TestPickle.py index eade637963..b019aa114b 100644 --- a/wrappers/python/tests/TestPickle.py +++ b/wrappers/python/tests/TestPickle.py @@ -8,10 +8,6 @@ import openmm.app.forcefield as forcefield import copy import pickle -import os - - -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestPickle(unittest.TestCase): """Pickling / deepcopy of OpenMM objects.""" @@ -22,13 +18,13 @@ def setUp(self): """ # alanine dipeptide with explicit water - self.pdb1 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + self.pdb1 = PDBFile('systems/alanine-dipeptide-explicit.pdb') self.forcefield1 = ForceField('amber99sb.xml', 'tip3p.xml') self.topology1 = self.pdb1.topology self.topology1.setUnitCellDimensions(Vec3(2, 2, 2)) # alalnine dipeptide with implicit water - self.pdb2 = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + self.pdb2 = PDBFile('systems/alanine-dipeptide-implicit.pdb') self.forcefield2 = ForceField('amber99sb.xml', 'amber99_obc.xml') def check_copy(self, object, object_copy): diff --git a/wrappers/python/tests/TestSimulation.py b/wrappers/python/tests/TestSimulation.py index b6b7797836..68ba979670 100644 --- a/wrappers/python/tests/TestSimulation.py +++ b/wrappers/python/tests/TestSimulation.py @@ -4,17 +4,13 @@ from openmm import * from openmm.app import * from openmm.unit import * -import os - - -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestSimulation(unittest.TestCase): """Test the Simulation class""" def testCheckpointing(self): """Test that checkpointing works correctly.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -48,7 +44,7 @@ def testCheckpointing(self): def testLoadFromXML(self): """ Test creating a Simulation from XML files """ - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -71,7 +67,7 @@ def testLoadFromXML(self): def testSaveState(self): """Test that saving States works correctly.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -104,7 +100,7 @@ def testSaveState(self): def testStep(self): """Test the step() method.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -127,7 +123,7 @@ def testStep(self): def testRunForClockTime(self): """Test the runForClockTime() method.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = VerletIntegrator(0.001*picoseconds) @@ -171,7 +167,7 @@ def testRunForClockTime(self): def testWrappedCoordinates(self): """Test generating reports with and without wrapped coordinates.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-explicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology, nonbondedMethod=CutoffPeriodic, constraints=HBonds) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) @@ -203,7 +199,7 @@ def report(self, simulation, state): def testMinimizationReporter(self): """Test invoking a reporter during minimization.""" - pdb = PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = PDBFile('systems/alanine-dipeptide-implicit.pdb') ff = ForceField('amber99sb.xml', 'tip3p.xml') system = ff.createSystem(pdb.topology) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) diff --git a/wrappers/python/tests/TestStateDataReporter.py b/wrappers/python/tests/TestStateDataReporter.py index d6df5283b4..cacdae066b 100644 --- a/wrappers/python/tests/TestStateDataReporter.py +++ b/wrappers/python/tests/TestStateDataReporter.py @@ -5,11 +5,10 @@ from openmm import unit import os -curr_dir = os.path.dirname(os.path.abspath(__file__)) class TestStateDataReporter(unittest.TestCase): def setUp(self): - self.pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + self.pdb = app.PDBFile('systems/alanine-dipeptide-implicit.pdb') self.forcefield = app.ForceField('amber99sbildn.xml') self.system = self.forcefield.createSystem(self.pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, constraints=app.HBonds) diff --git a/wrappers/python/tests/TestTopology.py b/wrappers/python/tests/TestTopology.py index 936b51f620..a2b6db23ee 100644 --- a/wrappers/python/tests/TestTopology.py +++ b/wrappers/python/tests/TestTopology.py @@ -5,16 +5,12 @@ from openmm import * from openmm.unit import * import openmm.app.element as elem -import os if sys.version_info >= (3, 0): from io import StringIO else: from cStringIO import StringIO -curr_dir = os.path.dirname(os.path.abspath(__file__)) - - class TestTopology(unittest.TestCase): """Test the Topology object""" @@ -29,7 +25,7 @@ def check_pdbfile(self, pdbfilename, natoms, nres, nchains): def test_getters(self): """Test getters for number of atoms, residues, chains.""" - self.check_pdbfile(os.path.join(curr_dir, 'systems', '1T2Y.pdb'), 271, 25, 1) + self.check_pdbfile('systems/1T2Y.pdb', 271, 25, 1) def test_bondtype_singleton(self): """ Tests that the bond types are really singletons """ diff --git a/wrappers/python/tests/TestXtcFile.py b/wrappers/python/tests/TestXtcFile.py index fcd118517f..2d905ccf14 100644 --- a/wrappers/python/tests/TestXtcFile.py +++ b/wrappers/python/tests/TestXtcFile.py @@ -10,15 +10,12 @@ import numpy as np from openmm.app.internal.xtc_utils import read_xtc - -curr_dir = os.path.dirname(os.path.abspath(__file__)) - class TestXtcFile(unittest.TestCase): def test_xtc_triclinic(self): """Test the XTC file by writing a trajectory and reading it back. Using a triclinic box""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -60,7 +57,7 @@ def test_xtc_cubic(self): """Test the XTC file by writing a trajectory and reading it back. Using a cubic box""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -98,7 +95,7 @@ def test_xtc_box_from_topology(self): """Test the XTC file by writing a trajectory and reading it back. Letting the box be set from the topology""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") # Set some arbitrary size for the unit cell so that a box is included in the trajectory unitCell = mm.Vec3(random(), random(), random()) * unit.nanometers pdbfile.topology.setUnitCellDimensions(unitCell) @@ -142,7 +139,7 @@ def test_xtc_small(self): """Test the XTC file by writing a trajectory and reading it back. Using a system size below the compression threshold""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'ions.pdb')) + pdbfile = app.PDBFile("systems/ions.pdb") # Set some arbitrary size for the unit cell so that a box is included in the trajectory pdbfile.topology.setUnitCellDimensions([10, 10, 10]) natom = len(list(pdbfile.topology.atoms())) @@ -184,7 +181,7 @@ def testLongTrajectory(self): """Test writing a trajectory that has more than 2^31 steps.""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdbfile = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdbfile = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") natom = len(list(pdbfile.topology.atoms())) xtc = app.XTCFile(fname, pdbfile.topology, 0.001, interval=1000000000) for i in range(5): @@ -199,7 +196,7 @@ def testAppend(self): """Test appending to an existing trajectory.""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-implicit.pdb')) + pdb = app.PDBFile("systems/alanine-dipeptide-implicit.pdb") ff = app.ForceField("amber99sb.xml", "tip3p.xml") system = ff.createSystem(pdb.topology) @@ -252,7 +249,7 @@ def testAtomSubset(self): """Test writing an XTC file containing a subset of atoms""" with tempfile.TemporaryDirectory() as temp: fname = os.path.join(temp, 'traj.xtc') - pdb = app.PDBFile(os.path.join(curr_dir, 'systems', 'alanine-dipeptide-explicit.pdb')) + pdb = app.PDBFile("systems/alanine-dipeptide-explicit.pdb") ff = app.ForceField("amber99sb.xml", "tip3p.xml") system = ff.createSystem(pdb.topology) From 01ef012b5f5f275934493be332be350be26f7ef3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 12:23:42 +0300 Subject: [PATCH 42/75] fix CI test issues --- .github/workflows/workflow.yml | 2 ++ wrappers/python/openmm/__init__.py | 1 + wrappers/python/setup.py | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 45eab0be08..f3fb10801e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,6 @@ name: Whole +permissions: + contents: read on: [push] diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 3141065085..367f3a4928 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -9,6 +9,7 @@ import os, os.path import sys +from . import version openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 2a0f43b81b..40c407aa22 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -172,8 +172,8 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, libraries[ii]="%s_d" % libraries[ii] sys.stdout.write("%s\n" % libraries[ii]) - openmm_include_path = 'openmm/include' - openmm_lib_path = 'openmm/lib' + openmm_include_path = os.getenv('OPENMM_INCLUDE_PATH', 'openmm/include') + openmm_lib_path = os.getenv('OPENMM_LIB_PATH', 'openmm/lib') extra_compile_args=['-std=c++11', '-D_GLIBCXX_USE_CXX11_ABI=1'] extra_link_args=[] From 516cc0a4c64e457d988e0453316847d39b8f70b9 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 12:32:17 +0300 Subject: [PATCH 43/75] delay import to solve circular import issue --- wrappers/python/openmm/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 367f3a4928..f829168ee9 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -9,7 +9,6 @@ import os, os.path import sys -from . import version openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')) @@ -41,3 +40,5 @@ class OpenMMException(Exception): """This is the class used for all exceptions thrown by the C++ library.""" pass + +from . import version From 510a234acbf430329993b5f5a0ed1ac201053de0 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 12:40:01 +0300 Subject: [PATCH 44/75] include data files in the package --- wrappers/python/MANIFEST.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wrappers/python/MANIFEST.in b/wrappers/python/MANIFEST.in index 12cc448ab9..b26a0dc0e7 100644 --- a/wrappers/python/MANIFEST.in +++ b/wrappers/python/MANIFEST.in @@ -9,4 +9,10 @@ prune src/swig_doxygen/doxygen/html prune src/swig_doxygen/doxygen/xml global-exclude CMakeLists.txt graft openmm/lib -graft openmm/include \ No newline at end of file +graft openmm/include +include openmm/app/data/*.xml +include openmm/app/data/*.pdb +include openmm/app/data/amber14/*.xml +include openmm/app/data/amber19/*.xml +include openmm/app/data/charmm36/*.xml +include openmm/app/data/implicit/*.xml \ No newline at end of file From 556e93f219504abca99601265ef0f9d416d00a88 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 13:06:09 +0300 Subject: [PATCH 45/75] resolve github warning --- .github/workflows/publish.yml | 2 ++ wrappers/python/pyproject.toml | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7de2cab4f3..83028c26ab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,8 @@ jobs: build: name: Build wheels on ${{ matrix.os }}-${{ matrix.accelerator }} runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: false matrix: diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index dc8a5ad4b4..824872a874 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -18,15 +18,10 @@ classifiers = [ [tool.setuptools.packages.find] include = ["openmm*", "simtk*"] - -# [tool.setuptools.exclude-package-data] -# "*" = ["*.c", "*.cpp", "*.h", "*.cuh", "*.cu", ".gitignore"] - [build-system] requires = ["setuptools>=78", "setuptools-scm>=8", "numpy", "cython"] build-backend = "setuptools.build_meta" - [tool.cibuildwheel] skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] From f1c37838b337bbc55df8c6442af7877e9cfafaae Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 13:12:19 +0300 Subject: [PATCH 46/75] cleanup --- wrappers/python/MANIFEST.in | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/wrappers/python/MANIFEST.in b/wrappers/python/MANIFEST.in index b26a0dc0e7..12cc448ab9 100644 --- a/wrappers/python/MANIFEST.in +++ b/wrappers/python/MANIFEST.in @@ -9,10 +9,4 @@ prune src/swig_doxygen/doxygen/html prune src/swig_doxygen/doxygen/xml global-exclude CMakeLists.txt graft openmm/lib -graft openmm/include -include openmm/app/data/*.xml -include openmm/app/data/*.pdb -include openmm/app/data/amber14/*.xml -include openmm/app/data/amber19/*.xml -include openmm/app/data/charmm36/*.xml -include openmm/app/data/implicit/*.xml \ No newline at end of file +graft openmm/include \ No newline at end of file From d6bcc3c91debe87b16c9b340dae47c5193c840dc Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 13:14:10 +0300 Subject: [PATCH 47/75] actions permissions --- .github/workflows/workflow.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f3fb10801e..45eab0be08 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,6 +1,4 @@ name: Whole -permissions: - contents: read on: [push] From 5346fdf8b5ce7478781eb771bfbfe72c2372b10d Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 13:37:03 +0300 Subject: [PATCH 48/75] fix windows path for cd --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 824872a874..7a80969145 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -33,7 +33,7 @@ environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] [tool.cibuildwheel.windows] before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" -test-command = "cd {project}/wrappers/python/tests; pytest" +test-command = "cd {project}\\wrappers\\python\\tests; pytest" [tool.cibuildwheel.linux] before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" From 51edeaf430884fc025f344adb286609a239b9c2b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 13:52:36 +0300 Subject: [PATCH 49/75] fix windows again? --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 7a80969145..7a3f52628c 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -33,7 +33,7 @@ environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] [tool.cibuildwheel.windows] before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" -test-command = "cd {project}\\wrappers\\python\\tests; pytest" +test-command = "cd {project}\\wrappers\\python\\tests && pytest" [tool.cibuildwheel.linux] before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" From 501b42ad938fee5c5763c9cce36864cf7cff6e86 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 14:11:13 +0300 Subject: [PATCH 50/75] fix windows again? --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 7a3f52628c..a40db6fcb3 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -33,7 +33,7 @@ environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] [tool.cibuildwheel.windows] before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" -test-command = "cd {project}\\wrappers\\python\\tests && pytest" +test-command = "cd {project}\\wrappers\\python\\tests && pytest {project}\\wrappers\\python\\tests" [tool.cibuildwheel.linux] before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" From 347bfb9e345f0bc7496b950374e91efcd3ce6ba7 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 15:49:47 +0300 Subject: [PATCH 51/75] symlink the test files into current directory hoping windows pytest might work --- .../cibuildwheel_support/prepare_build_environment_windows.sh | 2 ++ wrappers/python/pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index dd10df9951..2daae832b2 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -67,3 +67,5 @@ cd .. cp -r build/python/* wrappers/python/ cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ + +ln -s wrappers/python/tests/systems . \ No newline at end of file diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index a40db6fcb3..37e1d1d521 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -33,7 +33,7 @@ environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] [tool.cibuildwheel.windows] before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" -test-command = "cd {project}\\wrappers\\python\\tests && pytest {project}\\wrappers\\python\\tests" +test-command = "pytest {project}/wrappers/python/tests" [tool.cibuildwheel.linux] before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" From 60a31684aa996b6a72ed80495b88458181729b58 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 16:31:29 +0300 Subject: [PATCH 52/75] ls the symlink --- .../cibuildwheel_support/prepare_build_environment_windows.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 2daae832b2..eaac2db247 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -68,4 +68,6 @@ cp -r build/python/* wrappers/python/ cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ -ln -s wrappers/python/tests/systems . \ No newline at end of file +ln -s wrappers/python/tests/systems . + +ls -la ./systems/ \ No newline at end of file From 112392d67bd6b6ee30a8c26cca9397078aac5573 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 16:48:58 +0300 Subject: [PATCH 53/75] try with cp --- .../cibuildwheel_support/prepare_build_environment_windows.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index eaac2db247..f2ed63cdd9 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -68,6 +68,6 @@ cp -r build/python/* wrappers/python/ cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ -ln -s wrappers/python/tests/systems . +cp -r wrappers/python/tests/systems . ls -la ./systems/ \ No newline at end of file From 1c19a5160a48e70aede8be08399060b0428fa8ca Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 23 May 2025 16:50:12 +0300 Subject: [PATCH 54/75] try cping right before the pytest --- .../cibuildwheel_support/prepare_build_environment_windows.sh | 4 ---- wrappers/python/pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index f2ed63cdd9..dd10df9951 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -67,7 +67,3 @@ cd .. cp -r build/python/* wrappers/python/ cp -r build/openmm-install/include wrappers/python/openmm/ cp -r build/openmm-install/lib wrappers/python/openmm/ - -cp -r wrappers/python/tests/systems . - -ls -la ./systems/ \ No newline at end of file diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 37e1d1d521..86c0f91cd6 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -33,7 +33,7 @@ environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] [tool.cibuildwheel.windows] before-all = "bash wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh" -test-command = "pytest {project}/wrappers/python/tests" +test-command = "cp -r {project}/wrappers/python/tests/systems . && pytest {project}/wrappers/python/tests" [tool.cibuildwheel.linux] before-all = "wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh" From 061fab2933a9b73b2eadefbab5411359c839333b Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 26 May 2025 15:22:43 +0300 Subject: [PATCH 55/75] conda publishing --- .github/workflows/conda_publish.yaml | 250 ++++++++++++++++++ conda_package/README.md | 10 + conda_package/recipe/build_openmm.bat | 44 +++ conda_package/recipe/build_openmm.sh | 85 ++++++ conda_package/recipe/meta.yaml | 145 ++++++++++ conda_package/recipe/patch_osx_tests.py | 22 ++ conda_package/recipe/test_openmm.bat | 107 ++++++++ conda_package/recipe/test_openmm.sh | 91 +++++++ conda_package/scripts/setup_cuda.ps1 | 102 +++++++ ...sion11numpy1.22python3.10.____cpython.yaml | 44 +++ ...rsion11numpy1.22python3.9.____cpython.yaml | 44 +++ ...sion11numpy1.23python3.11.____cpython.yaml | 44 +++ ...sion11numpy1.26python3.12.____cpython.yaml | 44 +++ ...sion12numpy1.22python3.10.____cpython.yaml | 44 +++ ...rsion12numpy1.22python3.9.____cpython.yaml | 44 +++ ...sion12numpy1.23python3.11.____cpython.yaml | 44 +++ ...sion12numpy1.26python3.12.____cpython.yaml | 44 +++ ...pencl_implapplepython3.10.____cpython.yaml | 43 +++ ...opencl_implapplepython3.9.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.10.____cpython.yaml | 43 +++ ...encl_implkhronospython3.9.____cpython.yaml | 43 +++ ...pencl_implapplepython3.11.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.11.____cpython.yaml | 43 +++ ...pencl_implapplepython3.12.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.12.____cpython.yaml | 43 +++ ...pencl_implapplepython3.10.____cpython.yaml | 43 +++ ...opencl_implapplepython3.9.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.10.____cpython.yaml | 43 +++ ...encl_implkhronospython3.9.____cpython.yaml | 43 +++ ...pencl_implapplepython3.11.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.11.____cpython.yaml | 43 +++ ...pencl_implapplepython3.12.____cpython.yaml | 43 +++ ...ncl_implkhronospython3.12.____cpython.yaml | 43 +++ ...on12.0numpy1.22python3.10.____cpython.yaml | 29 ++ ...ion12.0numpy1.22python3.9.____cpython.yaml | 29 ++ ...on12.0numpy1.23python3.11.____cpython.yaml | 29 ++ ...on12.0numpy1.26python3.12.____cpython.yaml | 29 ++ ...on11.8numpy1.22python3.10.____cpython.yaml | 29 ++ ...ion11.8numpy1.22python3.9.____cpython.yaml | 29 ++ ...on11.8numpy1.23python3.11.____cpython.yaml | 29 ++ ...on11.8numpy1.26python3.12.____cpython.yaml | 29 ++ 41 files changed, 2128 insertions(+) create mode 100644 .github/workflows/conda_publish.yaml create mode 100644 conda_package/README.md create mode 100644 conda_package/recipe/build_openmm.bat create mode 100644 conda_package/recipe/build_openmm.sh create mode 100644 conda_package/recipe/meta.yaml create mode 100644 conda_package/recipe/patch_osx_tests.py create mode 100644 conda_package/recipe/test_openmm.bat create mode 100644 conda_package/recipe/test_openmm.sh create mode 100644 conda_package/scripts/setup_cuda.ps1 create mode 100644 conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.10.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.9.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.23python3.11.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.26python3.12.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.10.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.9.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.23python3.11.____cpython.yaml create mode 100644 conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.26python3.12.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.10.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.23opencl_implapplepython3.11.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.26opencl_implapplepython3.12.____cpython.yaml create mode 100644 conda_package/variants/osx_64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.10.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.9.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.23opencl_implapplepython3.11.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.26opencl_implapplepython3.12.____cpython.yaml create mode 100644 conda_package/variants/osx_arm64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.10.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.9.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.23python3.11.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.26python3.12.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.9.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.23python3.11.____cpython.yaml create mode 100644 conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.26python3.12.____cpython.yaml diff --git a/.github/workflows/conda_publish.yaml b/.github/workflows/conda_publish.yaml new file mode 100644 index 0000000000..041f668991 --- /dev/null +++ b/.github/workflows/conda_publish.yaml @@ -0,0 +1,250 @@ +name: Test code and publish package + +on: + push: + tags: + - 'v*' + +jobs: + deploy_linux_cuda11: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.9.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.10.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.23python3.11.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.26python3.12.____cpython.yaml", + ] + + runs-on: ubuntu-latest + container: quay.io/condaforge/linux-anvil-cuda:11.8 + + steps: + - uses: actions/checkout@v1 + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + /opt/conda/bin/anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/linux-64/openmm-*.tar.bz2 --skip-existing + + deploy_linux_cuda12: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.9.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.10.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.23python3.11.____cpython.yaml", + "conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.26python3.12.____cpython.yaml", + ] + + runs-on: ubuntu-latest + container: quay.io/condaforge/linux-anvil-cos7-x86_64 + + steps: + - uses: actions/checkout@v1 + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + /opt/conda/bin/anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/linux-64/openmm-*.tar.bz2 --skip-existing + + deploy_osx_64: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.23opencl_implapplepython3.11.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.26opencl_implapplepython3.12.____cpython.yaml", + "conda_package/variants/osx_64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml", + ] + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: ../deploy-env + python-version: "3.10" + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda install anaconda-client conda-build + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.conda --skip-existing + + deploy_osx_arm64: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.10.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.9.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.23opencl_implapplepython3.11.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.26opencl_implapplepython3.12.____cpython.yaml", + "conda_package/variants/osx_arm64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml", + ] + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: ../deploy-env + python-version: "3.10" + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda install anaconda-client conda-build + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.conda --skip-existing + + deploy_win_64_cuda11: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.9.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.23python3.11.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.26python3.12.____cpython.yaml", + ] + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: ../deploy-env + python-version: "3.10" + channels: conda-forge + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Setup CUDA Toolkit + id: cuda-toolkit + shell: pwsh + run: scripts/setup_cuda.ps1 + env: + INPUT_CUDA_VERSION: 11.8.0 + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda install anaconda-client conda-build + conda clean --all -y + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.tar.bz2 --skip-existing + + deploy_win_64_cuda12: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.10.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.9.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.23python3.11.____cpython.yaml", + "conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.26python3.12.____cpython.yaml", + ] + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: ../deploy-env + python-version: "3.10" + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Setup CUDA Toolkit + id: cuda-toolkit + shell: pwsh + run: scripts/setup_cuda.ps1 + env: + INPUT_CUDA_VERSION: 12.0.0 + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda install anaconda-client conda-build + conda clean --all -y + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} + + - name: Upload to conda + shell: bash -l {0} + run: | + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.tar.bz2 --skip-existing diff --git a/conda_package/README.md b/conda_package/README.md new file mode 100644 index 0000000000..bf4b2743d3 --- /dev/null +++ b/conda_package/README.md @@ -0,0 +1,10 @@ +# OpeMM Feedstock by Acellera + +This is a partial fork of the conda-forge feedstock for OpenMM. +The idea is to be able to quickly create OpenMM release candidates from specific commits without having to wait for an official OpenMM release. + +To create a new release you need to: + +1. Open the recipe/meta.yaml file and change the package version at the top of the file. +2. Update the git_rev version in the meta.yaml file in the source section to point to the desired commit. +3. Push your changes diff --git a/conda_package/recipe/build_openmm.bat b/conda_package/recipe/build_openmm.bat new file mode 100644 index 0000000000..04fcdc30ca --- /dev/null +++ b/conda_package/recipe/build_openmm.bat @@ -0,0 +1,44 @@ +@echo on + +mkdir build +cd build + +set "CUDA_TOOLKIT_ROOT_DIR=%CUDA_PATH:\=/%" + +if "%with_test_suite%"=="true" ( + set "CMAKE_FLAGS=-DBUILD_TESTING=ON -DOPENMM_BUILD_CUDA_TESTS=ON -DOPENMM_BUILD_OPENCL_TESTS=ON" +) else ( + set "CMAKE_FLAGS=-DBUILD_TESTING=OFF -DOPENMM_BUILD_CUDA_TESTS=OFF -DOPENMM_BUILD_OPENCL_TESTS=OFF" +) + +cmake.exe .. -G "NMake Makefiles JOM" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^ + -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^ + -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_TOOLKIT_ROOT_DIR%" ^ + -DOPENCL_INCLUDE_DIR="%LIBRARY_INC%" ^ + -DOPENCL_LIBRARY="%LIBRARY_LIB%\opencl.lib" ^ + %CMAKE_FLAGS% ^ + || goto :error + +jom -j %NUMBER_OF_PROCESSORS% || goto :error +jom -j %NUMBER_OF_PROCESSORS% install || goto :error +jom -j %NUMBER_OF_PROCESSORS% PythonInstall || goto :error + +:: Better location for examples +mkdir %LIBRARY_PREFIX%\share\openmm || goto :error +move %LIBRARY_PREFIX%\examples %LIBRARY_PREFIX%\share\openmm || goto :error + +if "%with_test_suite%"=="true" ( + mkdir %LIBRARY_PREFIX%\share\openmm\tests\ || goto :error + find . -name "Test*" -type f -exec cp "{}" %LIBRARY_PREFIX%\share\openmm\tests\ ; || goto :error + robocopy /E python\tests\ %LIBRARY_PREFIX%\share\openmm\tests\python + if %errorlevel% GTR 1 ( exit /b %errorlevel% ) +) + + +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% diff --git a/conda_package/recipe/build_openmm.sh b/conda_package/recipe/build_openmm.sh new file mode 100644 index 0000000000..1ad92c63a8 --- /dev/null +++ b/conda_package/recipe/build_openmm.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +set -ex + + +CMAKE_FLAGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_BUILD_TYPE=Release" +if [[ "$with_test_suite" == "true" ]]; then + CMAKE_FLAGS+=" -DBUILD_TESTING=ON -DOPENMM_BUILD_OPENCL_TESTS=ON" +else + CMAKE_FLAGS+=" -DBUILD_TESTING=OFF" +fi + + +if [[ "$target_platform" == linux* ]]; then + # CFLAGS + # JRG: Had to add -ldl to prevent linking errors (dlopen, etc) + MINIMAL_CFLAGS+=" -O3 -ldl" + CFLAGS+=" $MINIMAL_CFLAGS" + CXXFLAGS+=" $MINIMAL_CFLAGS" + + # CUDA is enabled in these platforms + if [[ "$target_platform" == linux-64 || "$target_platform" == linux-ppc64le ]]; then + # # CUDA_HOME is defined by nvcc metapackage + CMAKE_FLAGS+=" -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME}" + # CUDA tests won't build, disable for now + # See https://github.com/openmm/openmm/issues/2258#issuecomment-462223634 + CMAKE_FLAGS+=" -DOPENMM_BUILD_CUDA_TESTS=OFF" + # shadow some CMAKE_ARGS bits that interfere with CUDA detection + CMAKE_FLAGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH" + fi + + # OpenCL ICD + CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" + CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" + +elif [[ "$target_platform" == osx* ]]; then + if [[ "$opencl_impl" == khronos ]]; then + CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=${PREFIX}/include" + CMAKE_FLAGS+=" -DOPENCL_LIBRARY=${PREFIX}/lib/libOpenCL${SHLIB_EXT}" + fi + # When using opencl_impl == apple, CMake will auto-locate it, so no need to provide the flags + # On Conda Forge, this will result in: + # /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/... + # ...SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenCL.framework + # On local builds, it might be: + # /System/Library/Frameworks/OpenCL.framework/OpenCL +fi + +# Set location for FFTW3 on both linux and mac +CMAKE_FLAGS+=" -DFFTW_INCLUDES=${PREFIX}/include/" +CMAKE_FLAGS+=" -DFFTW_LIBRARY=${PREFIX}/lib/libfftw3f${SHLIB_EXT}" +CMAKE_FLAGS+=" -DFFTW_THREADS_LIBRARY=${PREFIX}/lib/libfftw3f_threads${SHLIB_EXT}" +# Disambiguate swig location +CMAKE_FLAGS+=" -DSWIG_EXECUTABLE=$(which swig)" + +# Build in subdirectory and install. +mkdir -p build +cd build +cmake ${CMAKE_FLAGS} ${SRC_DIR} +make -j$CPU_COUNT +make -j$CPU_COUNT install PythonInstall + +# Put examples into an appropriate subdirectory. +mkdir -p ${PREFIX}/share/openmm/ +mv ${PREFIX}/examples ${PREFIX}/share/openmm/ + +# Fix some overlinking warnings/errors +for lib in ${PREFIX}/lib/plugins/*${SHLIB_EXT}; do + ln -s $lib ${PREFIX}/lib/$(basename $lib) || true +done + +if [[ "$with_test_suite" == "true" ]]; then + mkdir -p ${PREFIX}/share/openmm/tests/ + # BSD find vs GNU find: -executable is only available in GNU find + # +0111 is somehow equivalent in BSD, but that's not compatible in GNU + # so we use different commands for each... + if [[ "$target_platform" == osx* ]]; then + find . -name "Test*" -perm +0111 -type f \ + -exec python $RECIPE_DIR/patch_osx_tests.py "{}" \; \ + -exec cp "{}" $PREFIX/share/openmm/tests/ \; + else + find . -name "Test*" -executable -type f -exec cp "{}" $PREFIX/share/openmm/tests/ \; + fi + cp -r python/tests $PREFIX/share/openmm/tests/python +fi diff --git a/conda_package/recipe/meta.yaml b/conda_package/recipe/meta.yaml new file mode 100644 index 0000000000..af1de683d3 --- /dev/null +++ b/conda_package/recipe/meta.yaml @@ -0,0 +1,145 @@ +{% set name = "openmm" %} +{% set version = environ.get("OPENMM_VERSION", "")[1:] %} +{% set build = 0 %} +{% set with_test_suite = "false" %} +#{% set with_test_suite = "true" %} # [(osx and arm64)] + +{% if cuda_compiler_version in (None, "None", True, False) %} +{% set cuda_major = 0 %} +{% else %} +{% set cuda_major = environ.get("cuda_compiler_version", "11.8").split(".")[0] | int %} +{% endif %} + +package: + name: {{ name }} + version: {{ version }} + +source: + git_url: https://github.com/Acellera/{{ name }}.git + git_rev: {{ environ.get("OPENMM_COMMIT", "") }} + +build: + number: {{ build }} + string: "py{{ PY_VER.replace('.', '') }}h{{ PKG_HASH }}_{{ build }}_{{ opencl_impl }}" # [osx] + track_features: # make Apple OpenCL low priority + - openmm_opencl_apple # [osx and (opencl_impl == 'apple')] + skip: true # [(cuda_compiler_version in (undefined, 'None') and (linux64 or win)) or ((cuda_compiler_version != '10.2') and (ppc64le))] + # see https://github.com/conda-forge/openmm-feedstock/pull/143#issuecomment-2429793569 + skip: true # [aarch64 and (cuda_compiler_version == '11.8')] + script_env: + - CONFIG + - CUDA_HOME # [ppc64le] + missing_dso_whitelist: + - "*/libcuda.*" # [linux] + - "*/libOpenCL.*" # [unix] + - "*/nvcuda.dll" # [win] + script: + - env with_test_suite={{ with_test_suite }} bash {{ RECIPE_DIR }}/build_openmm.sh # [unix] + - set with_test_suite={{ with_test_suite }} && {{ RECIPE_DIR }}\build_openmm.bat # [win] + +requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + - cython # [build_platform != target_platform] + - numpy # [build_platform != target_platform] + - swig # [build_platform != target_platform] + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} # [(linux or win) and cuda_compiler != "None"] + - cuda-version {{ cuda_compiler_version }} # [(cuda_compiler_version or "None") != "None"] + - {{ cdt('mesa-libgl-devel') }} # [linux] + - cmake + - make # [unix] + - jom # [win] + # needed for Python wrappers + - doxygen +{% if with_test_suite == 'true' %} + - conda-build # [osx] + - m2-findutils # [win] + - m2-coreutils # [win] +{% endif %} + + host: + - python + - swig + - pthread-stubs + - lxml + - numpy + - cython + - setuptools + # OpenCL ICD + - ocl-icd # [linux] + - khronos-opencl-icd-loader # [win or (osx and opencl_impl == 'khronos')] + - cuda-version {{ cuda_compiler_version }} # [(cuda_compiler_version or "None") != "None"] + {% if cuda_major >= 12 %} + - libcufft-dev # [linux or win] + - cuda-profiler-api # [linux or win] + - cuda-nvrtc-dev # [linux or win] + # No cuda-driver-dev in windows + - cuda-driver-dev # [linux] + {% endif %} + run: + - python + - numpy + - scipy <1.14 + # OpenCL ICD + - ocl-icd # [linux] + - ocl-icd-system # [linux] + - khronos-opencl-icd-loader # [win or (osx and opencl_impl == 'khronos')] + - ocl_icd_wrapper_apple # [osx and opencl_impl == 'khronos'] + + run_constrained: + - khronos-opencl-icd-loader ==9999999999 # [osx and opencl_impl == 'apple'] + - ocl_icd_wrapper_apple ==9999999999 # [osx and opencl_impl == 'apple'] + +test: + requires: + # - git + - pocl # [linux] + {% if cuda_major >= 12 %} + # No cuda-driver-dev nor cuda-compat in windows + - cuda-driver-dev # [linux] + - cuda-compat # [linux] + {% endif %} +{% if with_test_suite == 'true' %} + - pytest + - pytest-xdist +{% endif %} + files: + - test_openmm.sh # [unix] + - test_openmm.bat # [win] + imports: + - openmm + commands: + - env with_test_suite={{ with_test_suite }} bash test_openmm.sh # [unix] + - set with_test_suite={{ with_test_suite }} && .\test_openmm.bat # [win] + +about: + home: http://openmm.org + license: LGPL-3.0-or-later + license_family: LGPL + license_file: + - docs-source/licenses/Licenses.txt + - docs-source/licenses/LGPL.txt + - docs-source/licenses/GPL.txt + summary: A high performance toolkit for molecular simulation. + + description: | + OpenMM is a toolkit for molecular simulation. It can be used either as a + stand-alone application for running simulations, or as a library you call + from your own code. It provides a combination of extreme flexibility + (through custom forces and integrators), openness, and high performance + (especially on recent GPUs) that make it truly unique among simulation + codes. OpenMM is MIT licensed with some LGPL portions (CUDA and OpenCL + platforms). + doc_url: http://docs.openmm.org + dev_url: https://github.com/openmm/openmm + +extra: + recipe-maintainers: + - mikemhenry + - jchodera + - jaimergp + - peastman diff --git a/conda_package/recipe/patch_osx_tests.py b/conda_package/recipe/patch_osx_tests.py new file mode 100644 index 0000000000..8ddbe86b9e --- /dev/null +++ b/conda_package/recipe/patch_osx_tests.py @@ -0,0 +1,22 @@ +import os +import sys +from pathlib import Path +from conda_build.os_utils import macho + + +def name_callback(path, dylib): + prefix = os.environ["SRC_DIR"] + if prefix.endswith("/"): + prefix = prefix[:-1] + + if dylib["name"].startswith(prefix): + return f"@rpath/{Path(dylib['name']).name}" + + +def main(path): + dylibs = macho.otool(path) + macho.install_name_change(path, None, name_callback, dylibs, verbose=True) + + +if __name__ == "__main__": + main(sys.argv[1]) \ No newline at end of file diff --git a/conda_package/recipe/test_openmm.bat b/conda_package/recipe/test_openmm.bat new file mode 100644 index 0000000000..1930ed6bb2 --- /dev/null +++ b/conda_package/recipe/test_openmm.bat @@ -0,0 +1,107 @@ +@echo on + +:: Are we running on CI? CONFIG is defined for the whole Azure pipeline +:: and we are bringing it in through `script_env` in meta.yaml +if not "%CONFIG%"=="" set CI="True" + +:: Existence tests +if not exist %LIBRARY_LIB%/OpenMM.lib exit 1 +if not exist %LIBRARY_LIB%/plugins/OpenMMCPU.lib exit 1 +if not exist %LIBRARY_LIB%/plugins/OpenMMPME.lib exit 1 +if not exist %LIBRARY_LIB%/plugins/OpenMMOpenCL.lib exit 1 +if not exist %LIBRARY_LIB%/plugins/OpenMMCUDA.lib exit 1 + +:: Debug silent errors in plugin loading +python -c "import openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')" + +:: Check that hardcoded library path was correctly replaced by conda-build +python -c "import os, openmm.version as v; print(v.openmm_library_path); assert os.path.isdir(v.openmm_library_path), 'Directory does not exist'" || goto :error + +:: Check all platforms +python -m openmm.testInstallation + +:: On CI, Windows will only see 2 platforms because the driver nvcuda.dll is missing and that throws a 126 error +:: We expect that people running this locally will have Nvidia properly installed, so they should all platforms (4) +if "%CI%"=="" ( + set n_platforms=4 +) else ( + set n_platforms=2 +) +python -c "from openmm import Platform as P; n = P.getNumPlatforms(); assert n == %n_platforms%, f'n_platforms ({n}) != %n_platforms%'" || goto :error + +:: Now let's run a little MD +cd %LIBRARY_PREFIX%/share/openmm/examples +python benchmark.py --test=rf --seconds=10 --platform=Reference || goto :error +python benchmark.py --test=rf --seconds=10 --platform=CPU || goto :error +if "%CI%"=="" ( + python benchmark.py --test=rf --seconds=10 --platform=CUDA || goto :error + python benchmark.py --test=rf --seconds=10 --platform=OpenCL || goto :error +) + +:: Check version metadata looks ok, only for final releases, RCs are not checked! +:: See https://stackoverflow.com/a/7006016/3407590 for substring checks in CMD +if x%PKG_VERSION:rc=%==x%PKG_VERSION% ( + if x%PKG_VERSION:beta=%==x%PKG_VERSION% ( + if x%PKG_VERSION:dev=%==x%PKG_VERSION% ( + python -c "from openmm import Platform; v = Platform.getOpenMMVersion(); assert '%PKG_VERSION%' in (v, v+'.0'), v + '!=%PKG_VERSION%'" || goto :error + for /f "usebackq tokens=1" %%a in (`git ls-remote https://github.com/openmm/openmm.git %PKG_VERSION%`) do ( + python -c "from openmm.version import git_revision; r = git_revision; assert r == '%%a', r + '!=%%a'" || goto :error + ) + ) + ) +) else ( + echo "!!! WARNING !!!" + echo "This is a release candidate build (%PKG_VERSION%). Please check versions and git hashes manually!" +) + + +(set \n=^ +%=This hack is required to store newlines=% +) + +:: Run the full test suite, if requested +if "%with_test_suite%"=="true" ( + SETLOCAL EnableDelayedExpansion + @echo off + cd %LIBRARY_PREFIX%\share\openmm\tests + + :: Start with C++ tests + if not "%CI%"=="" ( + del /Q /F TestCuda* TestOpenCL* + ) + set count=0 + set exitcode=0 + set summary= + FOR %%F IN ( Test* ) do ( + set testexe=%%~F + set /a count=!count!+1 + echo; + echo #!count!: !testexe! + .\!testexe! + set thisexitcode=!errorlevel! + set summary=!summary! + if not "!thisexitcode!"=="0" ( set "summary=!summary!#!count! !testexe!\n!" ) + set /a exitcode=!exitcode!+!thisexitcode! + ) + if not "!exitcode!"=="0" ( + echo; + echo ------------ + echo Failed tests + echo ------------ + echo; + echo !summary! + exit /b !exitcode! + ) + @echo on + :: Python unit tests + cd python + python -m pytest -v -n %CPU_COUNT% || goto :error + + ENDLOCAL +) + +goto :EOF + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% diff --git a/conda_package/recipe/test_openmm.sh b/conda_package/recipe/test_openmm.sh new file mode 100644 index 0000000000..13f760b389 --- /dev/null +++ b/conda_package/recipe/test_openmm.sh @@ -0,0 +1,91 @@ +#!/bin/bash +set -ex +with_cuda="no" + +# Existence tests +test -f $PREFIX/lib/libOpenMM$SHLIB_EXT +test -f $PREFIX/lib/plugins/libOpenMMCPU$SHLIB_EXT +test -f $PREFIX/lib/plugins/libOpenMMPME$SHLIB_EXT +test -f $PREFIX/lib/plugins/libOpenMMOpenCL$SHLIB_EXT +if [[ "$target_platform" == linux-64 || "$target_platform" == linux-ppc64le ]]; then + with_cuda="yes" + test -f $PREFIX/lib/plugins/libOpenMMCUDA$SHLIB_EXT +fi + +## Do they work properly? +# Debug silent errors in plugin loading +python -c "import openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')" +# Check that hardcoded library path was correctly replaced by conda-build +python -c "import os, openmm.version as v; print(v.openmm_library_path); assert os.path.isdir(v.openmm_library_path), 'Directory does not exist'" + +# Check all platforms +if [[ "$target_platform" == linux-ppc64le || "$target_platform" == linux-aarch64 ]]; then + python -m openmm.testInstallation || true # OpenCL will fail but that's ok +else + python -m openmm.testInstallation +fi +if [[ $with_cuda == yes ]]; then + # Linux64 / PPC see all 4 platforms, but CUDA is not usable because there's no GPU there + n_platforms=4 +else + # MacOS / ARM only see 3 because CUDA is not available there + n_platforms=3 +fi +# testing cuda 12 changes, see https://github.com/conda-forge/openmm-feedstock/pull/108#issuecomment-1692190752 +#python -c "from openmm import Platform as P; n = P.getNumPlatforms(); assert n == $n_platforms, f'n_platforms ({n}) != $n_platforms'" + +# Run a small MD +cd ${PREFIX}/share/openmm/examples +python benchmark.py --test=rf --seconds=10 --platform=Reference +python benchmark.py --test=rf --seconds=10 --platform=CPU +if [[ -z ${CI-} ]]; then # Run only outside CI, assuming there will be a GPU there + python benchmark.py --test=rf --seconds=10 --platform=OpenCL + if [[ $with_cuda == yes ]]; then + python benchmark.py --test=rf --seconds=10 --platform=CUDA + fi +fi + +# Check version metadata looks ok, only for final releases, RCs are not checked! +if [[ ${PKG_VERSION} != *"rc"* && ${PKG_VERSION} != *"beta"* && ${PKG_VERSION} != *"dev"* ]]; then + python -c "from openmm import Platform; v = Platform.getOpenMMVersion(); assert \"$PKG_VERSION\" in (v, v+'.0'), v + \"!=$PKG_VERSION\"" + git_revision=$(git ls-remote https://github.com/openmm/openmm.git $PKG_VERSION | awk '{ print $1}') + python -c "from openmm.version import git_revision; r = git_revision; assert r == \"$git_revision\", r + \"!=$git_revision\"" +else + echo "!!! WARNING !!!" + echo "This is a release candidate build ($PKG_VERSION). Please check versions and git hashes manually!" +fi + +if [[ $with_test_suite == "true" ]]; then + cd $PREFIX/share/openmm/tests + set +ex + + # C++ tests + summary=""; exitcode=0; count=0; + for f in Test*; do + if [[ -n ${CI-} && ( $f == *Cuda* || $f == *OpenCL* ) ]]; then continue; fi + ((count+=1)) + echo -e "\n#$count: $f" + # Retry three times so stochastic tests have a chance + attempts=0 + while true; do + ./${f} + thisexitcode=$? + ((attempts+=1)) + if [[ $thisexitcode == 0 || $attempts == 3 ]]; then break; fi + done + if [[ $thisexitcode != 0 ]]; then summary+="\n#$count ${f}"; fi + ((exitcode+=$thisexitcode)) + done + if [[ $exitcode != 0 ]]; then + echo "------------" + echo "Failed tests" + echo "------------" + echo -e "${summary}" + exit $exitcode + fi + + # Python tests + set -ex + cd python + python -m pytest -v -n $CPU_COUNT +fi diff --git a/conda_package/scripts/setup_cuda.ps1 b/conda_package/scripts/setup_cuda.ps1 new file mode 100644 index 0000000000..8029aa3be1 --- /dev/null +++ b/conda_package/scripts/setup_cuda.ps1 @@ -0,0 +1,102 @@ +$CUDA_VERSION_FULL = $env:INPUT_CUDA_VERSION # v12.5.0 or v11.8.0 or v12.0.0 + +# Make sure CUDA_VERSION_FULL is set and valid, otherwise error. +# Validate CUDA version, extracting components via regex +$cuda_ver_matched = $CUDA_VERSION_FULL -match "^(?[1-9][0-9]*)\.(?[0-9]+)\.(?[0-9]+)$" +if(-not $cuda_ver_matched){ + Write-Output "Invalid CUDA version specified, .. required. '$CUDA_VERSION_FULL'." + exit 1 +} +$CUDA_MAJOR=$Matches.major +$CUDA_MINOR=$Matches.minor +$CUDA_PATCH=$Matches.patch + +Write-Output "Selected CUDA version: $CUDA_VERSION_FULL" + +$src = "cuda" +$dst = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$($CUDA_MAJOR).$($CUDA_MINOR)" +$installer = "cuda.exe" + +if ($CUDA_VERSION_FULL -eq "12.5.0") { + $downloadUrl = "https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda_12.5.0_555.85_windows.exe" +} elseif ($CUDA_VERSION_FULL -eq "12.0.0") { + $downloadUrl = "https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda_12.0.0_527.41_windows.exe" +} elseif ($CUDA_VERSION_FULL -eq "11.8.0") { + $downloadUrl = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe" +} else { + Write-Output "Unsupported CUDA version specified" + exit 1 +} + +# Download cuda +Write-Output "Downloading CUDA from: $downloadUrl" +if (-not (Test-Path -Path $installer)) { + Write-Output "Downloading CUDA installer..." + # If the file does not exist, download it + & "C:\msys64\usr\bin\wget" $downloadUrl -O $installer -q +} + +# Extract cuda +if (-not (Test-Path -Path $src -Type Container)) { + # Extract CUDA using 7-Zip + Write-Output "Extracting CUDA using 7-Zip..." + mkdir "$src" + & 'C:\Program Files\7-Zip\7z' x $installer -o"$src" +} + +# Create destination directory if it doesn't exist +if (-Not (Test-Path -Path $dst)) { + Write-Output "Creating destination directory: $dst" + New-Item -Path $dst -ItemType Directory +} + +# Get directories to process from the source path +$directories = Get-ChildItem -Directory -Path $src +$whitelist = @("CUDA_Toolkit_Release_Notes.txt", "DOCS", "EULA.txt", "LICENSE", "README", "version.json") + +foreach ($dir in $directories) { + # Get all subdirectories and files in the current directory + $items = Get-ChildItem -Path (Join-Path $src $dir.Name) + + foreach ($item in $items) { + if ($item.PSIsContainer) { + # If the item is a directory, copy its contents + Write-Output "Copying contents of directory $($item.FullName) to $dst" + Copy-Item -Path "$($item.FullName)\*" -Destination $dst -Recurse -Force + } else { + if ($whitelist -contains $item.Name) { + Write-Output "Copying file $($item.FullName) to $dst" + Copy-Item -Path $item.FullName -Destination $dst -Force + } + } + } +} + +# Add msbuild cuda extensions +$msBuildExtensions = (Get-ChildItem "$src\visual_studio_integration\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions").fullname +(Get-ChildItem 'C:\Program Files\Microsoft Visual Studio\2022\*\MSBuild\Microsoft\VC\*\BuildCustomizations').FullName | ForEach-Object { + $destination = $_ + $msBuildExtensions | ForEach-Object { + $extension = $_ + Copy-Item $extension -Destination $destination -Force + Write-Output "Copied $extension to $destination" + } +} + +# Add to Github env +Write-Output "Setting environment variables for GitHub Actions..." + +Write-Output "CUDA_PATH=$dst" +Write-Output "CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)=$dst" +Write-Output "CUDA_PATH_VX_Y=CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)" +Write-Output "CUDA_VERSION=$CUDA_VERSION_FULL" + +Write-Output "CUDA_PATH=$dst" >> $env:GITHUB_ENV +Write-Output "CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)=$dst" >> $env:GITHUB_ENV +Write-Output "CUDA_PATH_VX_Y=CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)" >> $env:GITHUB_ENV +Write-Output "CudaToolkitDir=$dst" >> $env:GITHUB_ENV +Write-Output "CMAKE_CUDA_COMPILER=$dst\bin\nvcc.exe" >> $env:GITHUB_ENV +Write-Output "NVCC_APPEND_FLAGS=-allow-unsupported-compiler" >> $env:GITHUB_ENV + +Write-Output "CUDA_VERSION=$CUDA_VERSION_FULL" >> $env:GITHUB_ENV +Write-Output "Setup completed." diff --git a/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.10.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.10.____cpython.yaml new file mode 100644 index 0000000000..6b185941c8 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.10.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '11' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- gxx +cxx_compiler_version: +- '11' +docker_image: +- quay.io/condaforge/linux-anvil-cuda:11.8 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.9.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.9.____cpython.yaml new file mode 100644 index 0000000000..9ad9e134e0 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.22python3.9.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '11' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- gxx +cxx_compiler_version: +- '11' +docker_image: +- quay.io/condaforge/linux-anvil-cuda:11.8 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.23python3.11.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.23python3.11.____cpython.yaml new file mode 100644 index 0000000000..d8ab21ac73 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.23python3.11.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '11' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- gxx +cxx_compiler_version: +- '11' +docker_image: +- quay.io/condaforge/linux-anvil-cuda:11.8 +numpy: +- '1.23' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.26python3.12.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.26python3.12.____cpython.yaml new file mode 100644 index 0000000000..f7ca5554e2 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version11cuda_compilernvcccuda_compiler_version11.8cxx_compiler_version11numpy1.26python3.12.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '11' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- gxx +cxx_compiler_version: +- '11' +docker_image: +- quay.io/condaforge/linux-anvil-cuda:11.8 +numpy: +- '1.26' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.10.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.10.____cpython.yaml new file mode 100644 index 0000000000..50c3797f71 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.10.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '12' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- gxx +cxx_compiler_version: +- '12' +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.9.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.9.____cpython.yaml new file mode 100644 index 0000000000..0b8971faaf --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.22python3.9.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '12' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- gxx +cxx_compiler_version: +- '12' +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.23python3.11.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.23python3.11.____cpython.yaml new file mode 100644 index 0000000000..2bd7f50443 --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.23python3.11.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '12' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- gxx +cxx_compiler_version: +- '12' +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +numpy: +- '1.23' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.26python3.12.____cpython.yaml b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.26python3.12.____cpython.yaml new file mode 100644 index 0000000000..66671ce7dd --- /dev/null +++ b/conda_package/variants/linux_64_c_compiler_version12cuda_compilercuda-nvcccuda_compiler_version12.0cxx_compiler_version12numpy1.26python3.12.____cpython.yaml @@ -0,0 +1,44 @@ +c_compiler: +- gcc +c_compiler_version: +- '12' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- gxx +cxx_compiler_version: +- '12' +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +numpy: +- '1.26' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version + - c_stdlib_version + - cdt_name + - cuda_compiler + - cuda_compiler_version + - docker_image +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.10.____cpython.yaml b/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.10.____cpython.yaml new file mode 100644 index 0000000000..f147e53caa --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.10.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.22' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml b/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml new file mode 100644 index 0000000000..6a659ea44a --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.22opencl_implapplepython3.9.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.22' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml b/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml new file mode 100644 index 0000000000..881b77e905 --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.22' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml b/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml new file mode 100644 index 0000000000..604c27a1b5 --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.22' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.23opencl_implapplepython3.11.____cpython.yaml b/conda_package/variants/osx_64_numpy1.23opencl_implapplepython3.11.____cpython.yaml new file mode 100644 index 0000000000..66526dc731 --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.23opencl_implapplepython3.11.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.23' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml b/conda_package/variants/osx_64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml new file mode 100644 index 0000000000..7a41b6ed89 --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.23' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.26opencl_implapplepython3.12.____cpython.yaml b/conda_package/variants/osx_64_numpy1.26opencl_implapplepython3.12.____cpython.yaml new file mode 100644 index 0000000000..4ed488532d --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.26opencl_implapplepython3.12.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.26' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml b/conda_package/variants/osx_64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml new file mode 100644 index 0000000000..d642f02219 --- /dev/null +++ b/conda_package/variants/osx_64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- x86_64-apple-darwin13.4.0 +numpy: +- '1.26' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- osx-64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.10.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.10.____cpython.yaml new file mode 100644 index 0000000000..46289cb78a --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.10.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.22' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.9.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.9.____cpython.yaml new file mode 100644 index 0000000000..e68ce0782b --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.22opencl_implapplepython3.9.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.22' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml new file mode 100644 index 0000000000..e8cb0c3b99 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.10.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.22' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml new file mode 100644 index 0000000000..5751f6c3f1 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.22opencl_implkhronospython3.9.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.22' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.23opencl_implapplepython3.11.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.23opencl_implapplepython3.11.____cpython.yaml new file mode 100644 index 0000000000..ec02403c92 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.23opencl_implapplepython3.11.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.23' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml new file mode 100644 index 0000000000..2561123ed5 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.23opencl_implkhronospython3.11.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.23' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.26opencl_implapplepython3.12.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.26opencl_implapplepython3.12.____cpython.yaml new file mode 100644 index 0000000000..f43b3e9898 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.26opencl_implapplepython3.12.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.26' +opencl_impl: +- apple +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/osx_arm64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml b/conda_package/variants/osx_arm64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml new file mode 100644 index 0000000000..5d03516237 --- /dev/null +++ b/conda_package/variants/osx_arm64_numpy1.26opencl_implkhronospython3.12.____cpython.yaml @@ -0,0 +1,43 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '18' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- None +cuda_compiler_version: +- None +cxx_compiler: +- clangxx +cxx_compiler_version: +- '18' +macos_machine: +- arm64-apple-darwin20.0.0 +numpy: +- '1.26' +opencl_impl: +- khronos +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- osx-arm64 +zip_keys: +- - c_compiler_version + - cxx_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.10.____cpython.yaml b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.10.____cpython.yaml new file mode 100644 index 0000000000..660e26a5a1 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.10.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- vs2019 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.9.____cpython.yaml b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.9.____cpython.yaml new file mode 100644 index 0000000000..bb509a35c3 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.22python3.9.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- vs2019 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.23python3.11.____cpython.yaml b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.23python3.11.____cpython.yaml new file mode 100644 index 0000000000..fb6c253b15 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.23python3.11.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- vs2019 +numpy: +- '1.23' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.26python3.12.____cpython.yaml b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.26python3.12.____cpython.yaml new file mode 100644 index 0000000000..5aee6a6b3c --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilercuda-nvcccuda_compiler_version12.0numpy1.26python3.12.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- cuda-nvcc +cuda_compiler_version: +- '12.0' +cxx_compiler: +- vs2019 +numpy: +- '1.26' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml new file mode 100644 index 0000000000..e10dc24ff2 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- vs2019 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.10.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.9.____cpython.yaml b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.9.____cpython.yaml new file mode 100644 index 0000000000..1c4db9181b --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.9.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- vs2019 +numpy: +- '1.22' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.9.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.23python3.11.____cpython.yaml b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.23python3.11.____cpython.yaml new file mode 100644 index 0000000000..978ba439a4 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.23python3.11.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- vs2019 +numpy: +- '1.23' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.11.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy diff --git a/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.26python3.12.____cpython.yaml b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.26python3.12.____cpython.yaml new file mode 100644 index 0000000000..e6432be9d2 --- /dev/null +++ b/conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.26python3.12.____cpython.yaml @@ -0,0 +1,29 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +cuda_compiler: +- nvcc +cuda_compiler_version: +- '11.8' +cxx_compiler: +- vs2019 +numpy: +- '1.26' +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- win-64 +zip_keys: +- - cuda_compiler + - cuda_compiler_version +- - python + - numpy From bca93836a9aa549a2d21a86ce8836e566eba7a1e Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 12:37:56 +0300 Subject: [PATCH 56/75] better naming of cuda openmm packages --- conda_package/recipe/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda_package/recipe/meta.yaml b/conda_package/recipe/meta.yaml index af1de683d3..4b20bd0973 100644 --- a/conda_package/recipe/meta.yaml +++ b/conda_package/recipe/meta.yaml @@ -20,6 +20,7 @@ source: build: number: {{ build }} + string: "cuda{{ cuda_compiler_version | replace('.', '') }}py{{ PY_VER.replace('.', '') }}h{{ PKG_HASH }}_{{ build }}" # [cuda_compiler_version != "None"] string: "py{{ PY_VER.replace('.', '') }}h{{ PKG_HASH }}_{{ build }}_{{ opencl_impl }}" # [osx] track_features: # make Apple OpenCL low priority - openmm_opencl_apple # [osx and (opencl_impl == 'apple')] From 1f7e0962b1761e5f34c8448c8917d86f3a1e5e37 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 12:40:45 +0300 Subject: [PATCH 57/75] merge workflows --- .github/workflows/conda_publish.yaml | 5 ++--- .github/workflows/workflow.yml | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conda_publish.yaml b/.github/workflows/conda_publish.yaml index 041f668991..a631a770fa 100644 --- a/.github/workflows/conda_publish.yaml +++ b/.github/workflows/conda_publish.yaml @@ -1,9 +1,8 @@ name: Test code and publish package on: - push: - tags: - - 'v*' + workflow_dispatch: + workflow_call: jobs: deploy_linux_cuda11: diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 45eab0be08..e4035831cc 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -3,7 +3,12 @@ name: Whole on: [push] jobs: - publish: + publish_pypi: if: startsWith(github.event.ref, 'refs/tags/v') uses: ./.github/workflows/publish.yml secrets: inherit + + publish_conda: + if: startsWith(github.event.ref, 'refs/tags/v') + uses: ./.github/workflows/conda_publish.yml + secrets: inherit From 6b8ee9a48232018a2ed8512cb02e635322c245c3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 12:43:01 +0300 Subject: [PATCH 58/75] rename yaml --- .github/workflows/{conda_publish.yaml => conda_publish.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{conda_publish.yaml => conda_publish.yml} (100%) diff --git a/.github/workflows/conda_publish.yaml b/.github/workflows/conda_publish.yml similarity index 100% rename from .github/workflows/conda_publish.yaml rename to .github/workflows/conda_publish.yml From 2709892018d7124c4d2252acf8b69c9bbad4efe3 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 13:29:07 +0300 Subject: [PATCH 59/75] fallback if openmm_library_path is not in openmm/lib to search in env/lib instead --- wrappers/python/openmm/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index f829168ee9..ebaddbb872 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -12,6 +12,13 @@ openmm_library_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')) +if not os.path.exists(openmm_library_path): + # The conda package installs all the libraries in the env/lib directory + import site + + sp_dir = site.getsitepackages()[0] + openmm_library_path = os.path.abspath(os.path.join(sp_dir, '..', '..')) + if sys.platform == 'win32': _path = os.environ['PATH'] os.environ['PATH'] = r'%(lib)s;%(lib)s\plugins;%(path)s' % { From 2a58d6dba398d2e6abe0e9f311156c55413caf91 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 13:47:24 +0300 Subject: [PATCH 60/75] try to make both setup.py and pyproject.toml work at the same time --- wrappers/python/setup.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 40c407aa22..1f1e2b228e 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -146,7 +146,22 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, "openmm.app.internal.pdbx.reader", "openmm.app.internal.pdbx.writer"] - setupKeywords["install_requires"] = ["numpy"] + setupKeywords["data_files"] = [] + setupKeywords["package_data"] = {"openmm" : [], + "openmm.app" : ['data/*.xml', 'data/*.pdb', 'data/amber14/*.xml', 'data/amber19/*.xml', 'data/charmm36/*.xml', 'data/implicit/*.xml'], + "openmm.app.internal" : []} + setupKeywords["install_requires"] = ["numpy"] + setupKeywords["platforms"] = ["Linux", "Mac OS X", "Windows"] + setupKeywords["description"] = \ + "Python wrapper for OpenMM (a C++ MD package)" + setupKeywords["long_description"] = \ + """OpenMM is a toolkit for molecular simulation. It can be used either as a + stand-alone application for running simulations, or as a library you call + from your own code. It provides a combination of extreme flexibility + (through custom forces and integrators), openness, and high performance + (especially on recent GPUs) that make it truly unique among simulation codes. + """ + if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', From 12d57d76feb639ee514ba940d6a18be664d2c278 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 28 May 2025 13:58:42 +0300 Subject: [PATCH 61/75] fix windows --- .github/workflows/conda_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda_publish.yml b/.github/workflows/conda_publish.yml index a631a770fa..c6596474f6 100644 --- a/.github/workflows/conda_publish.yml +++ b/.github/workflows/conda_publish.yml @@ -180,7 +180,7 @@ jobs: - name: Setup CUDA Toolkit id: cuda-toolkit shell: pwsh - run: scripts/setup_cuda.ps1 + run: conda_package/scripts/setup_cuda.ps1 env: INPUT_CUDA_VERSION: 11.8.0 @@ -228,7 +228,7 @@ jobs: - name: Setup CUDA Toolkit id: cuda-toolkit shell: pwsh - run: scripts/setup_cuda.ps1 + run: conda_package/scripts/setup_cuda.ps1 env: INPUT_CUDA_VERSION: 12.0.0 From f66212344c0f6b34c907a05b4aff82c9dcad1451 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 13:30:16 +0300 Subject: [PATCH 62/75] test fix for conda windows builds --- .github/workflows/testwindows.yml | 46 ++++++++++++++++++++++++++++++ wrappers/python/openmm/__init__.py | 4 +++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/testwindows.yml diff --git a/.github/workflows/testwindows.yml b/.github/workflows/testwindows.yml new file mode 100644 index 0000000000..31da7657f9 --- /dev/null +++ b/.github/workflows/testwindows.yml @@ -0,0 +1,46 @@ +name: Test code and publish package + +on: + push: + +jobs: + deploy_win_64_cuda11: + strategy: + fail-fast: false + matrix: + config_file: + [ + "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml", + ] + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: ../deploy-env + python-version: "3.10" + channels: conda-forge + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Setup CUDA Toolkit + id: cuda-toolkit + shell: pwsh + run: conda_package/scripts/setup_cuda.ps1 + env: + INPUT_CUDA_VERSION: 11.8.0 + + - name: Build openmm package + shell: bash -l {0} + run: | + git config --global --add safe.directory '*' + conda install anaconda-client conda-build + conda clean --all -y + conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge + env: + OPENMM_VERSION: ${{ github.ref_name }} + OPENMM_COMMIT: ${{ github.sha }} diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index ebaddbb872..9316d30a38 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -18,6 +18,10 @@ sp_dir = site.getsitepackages()[0] openmm_library_path = os.path.abspath(os.path.join(sp_dir, '..', '..')) + if sys.platform == 'win32': + # Don't move this in the next if below. it should only happen on conda packages where + # lib is not under the package root. + openmm_library_path = os.path.join(openmm_library_path, '..', 'Library', 'lib') if sys.platform == 'win32': _path = os.environ['PATH'] From ae2e068b4d456b960b0694cfbf0cdccfa7220394 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 15:07:31 +0300 Subject: [PATCH 63/75] some debugging prints --- wrappers/python/openmm/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 9316d30a38..a2ec86c1a2 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -23,14 +23,18 @@ # lib is not under the package root. openmm_library_path = os.path.join(openmm_library_path, '..', 'Library', 'lib') +print(f"XXX_OPENMM_LIBRARY_PATH: {openmm_library_path}") if sys.platform == 'win32': + print("XXX_WINDOWS!!!") _path = os.environ['PATH'] os.environ['PATH'] = r'%(lib)s;%(lib)s\plugins;%(path)s' % { 'lib': openmm_library_path, 'path': _path} try: with os.add_dll_directory(openmm_library_path): from . import _openmm + print("WORKED!!!") except: + print("FAILED!!!") pass from openmm.openmm import * From 8c191d6b5dd1c4f96a8af28ad541fb4a0e7e5dfb Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 15:50:04 +0300 Subject: [PATCH 64/75] fix the directory --- wrappers/python/openmm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index a2ec86c1a2..46f31a7e3e 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -21,7 +21,7 @@ if sys.platform == 'win32': # Don't move this in the next if below. it should only happen on conda packages where # lib is not under the package root. - openmm_library_path = os.path.join(openmm_library_path, '..', 'Library', 'lib') + openmm_library_path = os.path.join(openmm_library_path, 'Library', 'lib') print(f"XXX_OPENMM_LIBRARY_PATH: {openmm_library_path}") if sys.platform == 'win32': From 9a4f0091152ff07c7cd19866f743fa4646e29d34 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 16:21:06 +0300 Subject: [PATCH 65/75] windows handles site-packages differently --- wrappers/python/openmm/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 46f31a7e3e..5fa13784ff 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -16,12 +16,11 @@ # The conda package installs all the libraries in the env/lib directory import site - sp_dir = site.getsitepackages()[0] - openmm_library_path = os.path.abspath(os.path.join(sp_dir, '..', '..')) + openmm_library_path = os.path.abspath(os.path.join(site.getsitepackages()[0], '..', '..')) if sys.platform == 'win32': # Don't move this in the next if below. it should only happen on conda packages where # lib is not under the package root. - openmm_library_path = os.path.join(openmm_library_path, 'Library', 'lib') + openmm_library_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'Library', 'lib') print(f"XXX_OPENMM_LIBRARY_PATH: {openmm_library_path}") if sys.platform == 'win32': From bc5af824ad467d2c1b144759b3691465961b2962 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 16:51:01 +0300 Subject: [PATCH 66/75] fixed windows, removing debugging --- .github/workflows/testwindows.yml | 46 ------------------------------ wrappers/python/openmm/__init__.py | 4 --- 2 files changed, 50 deletions(-) delete mode 100644 .github/workflows/testwindows.yml diff --git a/.github/workflows/testwindows.yml b/.github/workflows/testwindows.yml deleted file mode 100644 index 31da7657f9..0000000000 --- a/.github/workflows/testwindows.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Test code and publish package - -on: - push: - -jobs: - deploy_win_64_cuda11: - strategy: - fail-fast: false - matrix: - config_file: - [ - "conda_package/variants/win_64_cuda_compilernvcccuda_compiler_version11.8numpy1.22python3.10.____cpython.yaml", - ] - runs-on: windows-2022 - - steps: - - uses: actions/checkout@v4 - - - uses: conda-incubator/setup-miniconda@v3 - with: - miniconda-version: "latest" - activate-environment: ../deploy-env - python-version: "3.10" - channels: conda-forge - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 - - - name: Setup CUDA Toolkit - id: cuda-toolkit - shell: pwsh - run: conda_package/scripts/setup_cuda.ps1 - env: - INPUT_CUDA_VERSION: 11.8.0 - - - name: Build openmm package - shell: bash -l {0} - run: | - git config --global --add safe.directory '*' - conda install anaconda-client conda-build - conda clean --all -y - conda build conda_package/recipe/ --variant-config-files ${{ matrix.config_file }} --output-folder ./pkg/ --no-include-recipe --no-anaconda-upload -c conda-forge - env: - OPENMM_VERSION: ${{ github.ref_name }} - OPENMM_COMMIT: ${{ github.sha }} diff --git a/wrappers/python/openmm/__init__.py b/wrappers/python/openmm/__init__.py index 5fa13784ff..b593a81d3d 100644 --- a/wrappers/python/openmm/__init__.py +++ b/wrappers/python/openmm/__init__.py @@ -22,18 +22,14 @@ # lib is not under the package root. openmm_library_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'Library', 'lib') -print(f"XXX_OPENMM_LIBRARY_PATH: {openmm_library_path}") if sys.platform == 'win32': - print("XXX_WINDOWS!!!") _path = os.environ['PATH'] os.environ['PATH'] = r'%(lib)s;%(lib)s\plugins;%(path)s' % { 'lib': openmm_library_path, 'path': _path} try: with os.add_dll_directory(openmm_library_path): from . import _openmm - print("WORKED!!!") except: - print("FAILED!!!") pass from openmm.openmm import * From 6692c994396e27295b1d6505e523c11f523f01dd Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Thu, 29 May 2025 17:43:39 +0300 Subject: [PATCH 67/75] correct package extension --- .github/workflows/conda_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda_publish.yml b/.github/workflows/conda_publish.yml index c6596474f6..4207ce5b7a 100644 --- a/.github/workflows/conda_publish.yml +++ b/.github/workflows/conda_publish.yml @@ -198,7 +198,7 @@ jobs: - name: Upload to conda shell: bash -l {0} run: | - anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.tar.bz2 --skip-existing + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.conda --skip-existing deploy_win_64_cuda12: strategy: @@ -246,4 +246,4 @@ jobs: - name: Upload to conda shell: bash -l {0} run: | - anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.tar.bz2 --skip-existing + anaconda -t ${{ secrets.ANACONDA_TOKEN_BASIC }} upload -u acellera pkg/*/openmm-*.conda --skip-existing From c057bb2497ef99b5dd2e18a2ce90ecc5445b7df2 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Fri, 30 May 2025 11:19:09 +0300 Subject: [PATCH 68/75] update release candidate version in CI --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 83028c26ab..41fb377755 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -74,7 +74,7 @@ jobs: run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: ACCELERATOR: ${{ matrix.accelerator }} - VERSION_SUFFIX: "rc1" + VERSION_SUFFIX: "rc2" - name: Build wheels if: matrix.os == 'windows-2019' @@ -83,7 +83,7 @@ jobs: env: DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building ACCELERATOR: ${{ matrix.accelerator }} - VERSION_SUFFIX: "rc1" + VERSION_SUFFIX: "rc2" - uses: actions/upload-artifact@v4 with: From 6810a6998760dc3a0122e2e0012df1bfb6618983 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 13 Aug 2025 11:32:52 +0300 Subject: [PATCH 69/75] public PyPI unofficial OpenMM version for cuda 11.8 and 12.0 only --- .github/workflows/publish.yml | 93 +++++++++++++------ .../prepare_build_environment_linux.sh | 12 +++ .../prepare_build_environment_windows.sh | 7 ++ wrappers/python/setup.py | 4 + 4 files changed, 86 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 41fb377755..70d79e614a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,26 +14,30 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] - accelerator: [cpu, cu118, cu124, cu126, cu128, hip] + accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] exclude: - os: ubuntu-24.04-arm accelerator: cu118 - os: ubuntu-24.04-arm - accelerator: cu124 - - os: ubuntu-24.04-arm - accelerator: cu126 - - os: ubuntu-24.04-arm - accelerator: cu128 + accelerator: cu120 + # - os: ubuntu-24.04-arm + # accelerator: cu124 + # - os: ubuntu-24.04-arm + # accelerator: cu126 + # - os: ubuntu-24.04-arm + # accelerator: cu128 - os: ubuntu-24.04-arm accelerator: hip - os: macos-latest accelerator: cu118 - os: macos-latest - accelerator: cu124 - - os: macos-latest - accelerator: cu126 - - os: macos-latest - accelerator: cu128 + accelerator: cu120 + # - os: macos-latest + # accelerator: cu124 + # - os: macos-latest + # accelerator: cu126 + # - os: macos-latest + # accelerator: cu128 - os: macos-latest accelerator: hip @@ -90,29 +94,22 @@ jobs: name: ${{ matrix.accelerator }}-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl - publish-to-accelera-pypi: + publish-to-public-pypi: name: >- - Publish Python 🐍 distribution 📦 to Acellera PyPI + Publish Python 🐍 distribution 📦 to PyPI needs: - build runs-on: ubuntu-latest - permissions: # Needed for GCP authentication - contents: "read" - id-token: "write" + environment: + name: pypi + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing strategy: fail-fast: false matrix: - accelerator: [cpu, cu118, cu124, cu126, cu128, hip] + accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] steps: - - uses: actions/checkout@v4 # Needed for GCP authentication for some reason - - - name: Set up Cloud SDK - uses: google-github-actions/auth@v2 - with: - workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} - service_account: ${{ secrets.GCP_PYPI_SERVICE_ACCOUNT }} - - name: Download all the dists uses: actions/download-artifact@v4 with: @@ -120,11 +117,47 @@ jobs: path: dist/ merge-multiple: true - - name: Publish distribution 📦 to Acellera PyPI - run: | - pip install build twine keyring keyrings.google-artifactregistry-auth - pip install -U packaging - twine upload --repository-url https://us-central1-python.pkg.dev/pypi-packages-455608/${{ matrix.accelerator }} dist/* --verbose --skip-existing + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PUBLIC_PYPI_API_TOKEN }} + skip-existing: true + + # publish-to-accelera-pypi: + # name: >- + # Publish Python 🐍 distribution 📦 to Acellera PyPI + # needs: + # - build + # runs-on: ubuntu-latest + # permissions: # Needed for GCP authentication + # contents: "read" + # id-token: "write" + # strategy: + # fail-fast: false + # matrix: + # accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] + + # steps: + # - uses: actions/checkout@v4 # Needed for GCP authentication for some reason + + # - name: Set up Cloud SDK + # uses: google-github-actions/auth@v2 + # with: + # workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} + # service_account: ${{ secrets.GCP_PYPI_SERVICE_ACCOUNT }} + + # - name: Download all the dists + # uses: actions/download-artifact@v4 + # with: + # pattern: "${{ matrix.accelerator }}-cibw-wheels*" + # path: dist/ + # merge-multiple: true + + # - name: Publish distribution 📦 to Acellera PyPI + # run: | + # pip install build twine keyring keyrings.google-artifactregistry-auth + # pip install -U packaging + # twine upload --repository-url https://us-central1-python.pkg.dev/pypi-packages-455608/${{ matrix.accelerator }} dist/* --verbose --skip-existing github-release: name: >- diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index 2120cec828..9a87136b8b 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -17,6 +17,18 @@ if [ "$ACCELERATOR" == "cu118" ]; then ln -s cuda-11.8 /usr/local/cuda + export CUDA_HOME="/usr/local/cuda" +elif [ "$ACCELERATOR" == "cu120" ]; then + # Install CUDA 12.0 + dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo + + dnf install --setopt=obsoletes=0 -y \ + cuda-compiler-12-0-12.0.1-1 \ + cuda-libraries-12-0-12.0.1-1 \ + cuda-libraries-devel-12-0-12.0.1-1 + + ln -s cuda-12.0 /usr/local/cuda + export CUDA_HOME="/usr/local/cuda" elif [ "$ACCELERATOR" == "cu124" ]; then # Install CUDA 12.4 diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index dd10df9951..22d6e45769 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -10,6 +10,13 @@ if [ "$ACCELERATOR" == "cu118" ]; then # Move CUDA folder to a path without spaces mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" /c/CUDA export CUDA_PATH="/c/CUDA" +elif [ "$ACCELERATOR" == "cu120" ]; then + curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda_12.0.0_527.41_windows.exe + ./cuda.exe -s nvcc_12.0 nvrtc_12.0 nvrtc_dev_12.0 cudart_12.0 cufft_12.0 cufft_dev_12.0 cuda_profiler_api_12.0 + rm cuda.exe + # Move CUDA folder to a path without spaces + mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.0" /c/CUDA + export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "cu124" ]; then curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 cuda_profiler_api_12.4 diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 0b5971a4c6..01523a5d1a 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -162,8 +162,12 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, (especially on recent GPUs) that make it truly unique among simulation codes. """ + setupKeywords["name"] = "openmm-unofficial-cpu" + if os.getenv("ACCELERATOR", "").startswith("hip"): + setupKeywords["name"] = "openmm-unofficial-hip" if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] + setupKeywords["name"] = f"openmm-unofficial-cu{cuda_ver}" setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', f'nvidia-cuda-nvcc-cu{cuda_ver}', f'nvidia-cuda-nvrtc-cu{cuda_ver}', From d37a039a270329a7352f7b8aa574b9b9f4a6e717 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 13 Aug 2025 11:37:11 +0300 Subject: [PATCH 70/75] update windows version --- .github/workflows/publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 70d79e614a..a35569ff16 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest] + os: [ubuntu-latest, ubuntu-24.04-arm, windows-2022, macos-latest] accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] exclude: - os: ubuntu-24.04-arm @@ -64,16 +64,16 @@ jobs: - name: Activate MSVC uses: ilammy/msvc-dev-cmd@v1 - if: matrix.os == 'windows-2019' + if: matrix.os == 'windows-2022' - name: "Install dependencies with choco" uses: crazy-max/ghaction-chocolatey@v3 - if: matrix.os == 'windows-2019' + if: matrix.os == 'windows-2022' with: args: install doxygen.install jom - name: Build wheels - if: matrix.os != 'windows-2019' + if: matrix.os != 'windows-2022' shell: bash -l {0} run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: @@ -81,7 +81,7 @@ jobs: VERSION_SUFFIX: "rc2" - name: Build wheels - if: matrix.os == 'windows-2019' + if: matrix.os == 'windows-2022' shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables run: python -m cibuildwheel wrappers/python/ --output-dir wheelhouse env: From bfb62120a02e9ed576ee580b04582a90e7cd9d93 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 13 Aug 2025 15:21:14 +0300 Subject: [PATCH 71/75] placeholder package name since pyproject doesn't allow dynamic package names --- .github/workflows/publish.yml | 2 +- conda_package/recipe/test_openmm.bat | 2 +- conda_package/recipe/test_openmm.sh | 2 +- wrappers/python/pyproject.toml | 6 ++---- wrappers/python/setup.py | 17 ++++++++++++++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a35569ff16..b841968132 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -60,7 +60,7 @@ jobs: python-version: "3.13" - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.23.0 + run: python -m pip install cibuildwheel==3.1.3 - name: Activate MSVC uses: ilammy/msvc-dev-cmd@v1 diff --git a/conda_package/recipe/test_openmm.bat b/conda_package/recipe/test_openmm.bat index 1930ed6bb2..e732530991 100644 --- a/conda_package/recipe/test_openmm.bat +++ b/conda_package/recipe/test_openmm.bat @@ -30,7 +30,7 @@ if "%CI%"=="" ( python -c "from openmm import Platform as P; n = P.getNumPlatforms(); assert n == %n_platforms%, f'n_platforms ({n}) != %n_platforms%'" || goto :error :: Now let's run a little MD -cd %LIBRARY_PREFIX%/share/openmm/examples +cd %LIBRARY_PREFIX%/share/openmm/examples/benchmarks python benchmark.py --test=rf --seconds=10 --platform=Reference || goto :error python benchmark.py --test=rf --seconds=10 --platform=CPU || goto :error if "%CI%"=="" ( diff --git a/conda_package/recipe/test_openmm.sh b/conda_package/recipe/test_openmm.sh index 13f760b389..663016e9bb 100644 --- a/conda_package/recipe/test_openmm.sh +++ b/conda_package/recipe/test_openmm.sh @@ -35,7 +35,7 @@ fi #python -c "from openmm import Platform as P; n = P.getNumPlatforms(); assert n == $n_platforms, f'n_platforms ({n}) != $n_platforms'" # Run a small MD -cd ${PREFIX}/share/openmm/examples +cd ${PREFIX}/share/openmm/examples/benchmarks python benchmark.py --test=rf --seconds=10 --platform=Reference python benchmark.py --test=rf --seconds=10 --platform=CPU if [[ -z ${CI-} ]]; then # Run only outside CI, assuming there will be a GPU there diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index 86c0f91cd6..dac970f7cf 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "OpenMM" +name = "PLACEHOLDER" description = "Python wrapper for OpenMM (a C++ MD package)" authors = [{ name = "Peter Eastman", email = "peastman@stanford.edu" }] readme = "README.md" @@ -23,11 +23,9 @@ requires = ["setuptools>=78", "setuptools-scm>=8", "numpy", "cython"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] -skip = ["cp38-*", "pp*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] +skip = ["cp38-*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] test-command = "cd {project}/wrappers/python/tests; pytest" -manylinux-x86_64-image = "manylinux_2_28" -manylinux-aarch64-image = "manylinux_2_28" environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] # container-engine = "docker; create_args: --gpus all" diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 01523a5d1a..d4ee0fb955 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -122,6 +122,16 @@ def writeVersionPy(filename="openmm/version.py", major_version_num=MAJOR_VERSION 'isrelease': str(IS_RELEASED)}) +def _replace_name(name): + import pathlib + + pyproject_path = pathlib.Path(__file__).parent / "pyproject.toml" + with open(pyproject_path, 'r') as f: + pyproject_text = f.read() + pyproject_text = pyproject_text.replace("PLACEHOLDER", name) + with open(pyproject_path, 'w') as f: + f.write(pyproject_text) + def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, minor_version_num=MINOR_VERSION_NUM, build_info=BUILD_INFO): @@ -162,12 +172,13 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, (especially on recent GPUs) that make it truly unique among simulation codes. """ - setupKeywords["name"] = "openmm-unofficial-cpu" + if os.getenv("ACCELERATOR", "").startswith("cpu"): + _replace_name("openmm-unofficial-cpu") if os.getenv("ACCELERATOR", "").startswith("hip"): - setupKeywords["name"] = "openmm-unofficial-hip" + _replace_name("openmm-unofficial-hip") if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] - setupKeywords["name"] = f"openmm-unofficial-cu{cuda_ver}" + _replace_name(f"openmm-unofficial-cu{cuda_ver}") setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', f'nvidia-cuda-nvcc-cu{cuda_ver}', f'nvidia-cuda-nvrtc-cu{cuda_ver}', From 88facdb2ce536e0eef5e29a782c0dafcc97b44a9 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 13 Aug 2025 16:31:09 +0300 Subject: [PATCH 72/75] disable hip for now --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b841968132..063b53eb3d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-2022, macos-latest] - accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] + accelerator: [cpu, cu118, cu120] #, cu124, cu126, cu128, hip] exclude: - os: ubuntu-24.04-arm accelerator: cu118 @@ -107,7 +107,7 @@ jobs: strategy: fail-fast: false matrix: - accelerator: [cpu, cu118, cu120, hip] #cu124, cu126, cu128, hip] + accelerator: [cpu, cu118, cu120] #, hip, cu124, cu126, cu128] steps: - name: Download all the dists From 997aaccb96f82685e7b556a5adf2342a1f1e743a Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Mon, 25 Aug 2025 15:53:33 +0300 Subject: [PATCH 73/75] don't build for 3.14t release candidate --- wrappers/python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/pyproject.toml b/wrappers/python/pyproject.toml index dac970f7cf..54734e9fe4 100644 --- a/wrappers/python/pyproject.toml +++ b/wrappers/python/pyproject.toml @@ -23,7 +23,7 @@ requires = ["setuptools>=78", "setuptools-scm>=8", "numpy", "cython"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] -skip = ["cp38-*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] +skip = ["cp38-*", "cp314t-*", "*win32", "*armv7l", "*_i686", "*_ppc64le", "*_s390x", "*_universal2", "*-musllinux_*"] test-requires = ["pytest"] test-command = "cd {project}/wrappers/python/tests; pytest" environment-pass = ["ACCELERATOR", "VERSION_SUFFIX"] From 9f0909f270bccbd083023a8161ae12be11b41287 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 27 Aug 2025 11:39:16 +0300 Subject: [PATCH 74/75] updated the runtime dependencies --- .../prepare_build_environment_linux.sh | 36 ------------------- .../prepare_build_environment_windows.sh | 21 ----------- wrappers/python/setup.py | 17 ++++++--- 3 files changed, 12 insertions(+), 62 deletions(-) diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh index 9a87136b8b..27d09164e8 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_linux.sh @@ -29,42 +29,6 @@ elif [ "$ACCELERATOR" == "cu120" ]; then ln -s cuda-12.0 /usr/local/cuda - export CUDA_HOME="/usr/local/cuda" -elif [ "$ACCELERATOR" == "cu124" ]; then - # Install CUDA 12.4 - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo - - dnf install --setopt=obsoletes=0 -y \ - cuda-compiler-12-4-12.4.1-1 \ - cuda-libraries-12-4-12.4.1-1 \ - cuda-libraries-devel-12-4-12.4.1-1 - - ln -s cuda-12.4 /usr/local/cuda - - export CUDA_HOME="/usr/local/cuda" -elif [ "$ACCELERATOR" == "cu126" ]; then - # Install CUDA 12.6 - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo - - dnf install --setopt=obsoletes=0 -y \ - cuda-compiler-12-6-12.6.3-1 \ - cuda-libraries-12-6-12.6.3-1 \ - cuda-libraries-devel-12-6-12.6.3-1 - - ln -s cuda-12.4 /usr/local/cuda - - export CUDA_HOME="/usr/local/cuda" -elif [ "$ACCELERATOR" == "cu128" ]; then - # Install CUDA 12.8 - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo - - dnf install --setopt=obsoletes=0 -y \ - cuda-compiler-12-8-12.8.1-1 \ - cuda-libraries-12-8-12.8.1-1 \ - cuda-libraries-devel-12-8-12.8.1-1 - - ln -s cuda-12.8 /usr/local/cuda - export CUDA_HOME="/usr/local/cuda" elif [ "$ACCELERATOR" == "hip" ]; then # Install HIP 6.2 diff --git a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh index 22d6e45769..80dad2620a 100755 --- a/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh +++ b/wrappers/python/cibuildwheel_support/prepare_build_environment_windows.sh @@ -17,27 +17,6 @@ elif [ "$ACCELERATOR" == "cu120" ]; then # Move CUDA folder to a path without spaces mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.0" /c/CUDA export CUDA_PATH="/c/CUDA" -elif [ "$ACCELERATOR" == "cu124" ]; then - curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe - ./cuda.exe -s nvcc_12.4 nvrtc_12.4 nvrtc_dev_12.4 cudart_12.4 cufft_12.4 cufft_dev_12.4 cuda_profiler_api_12.4 - rm cuda.exe - # Move CUDA folder to a path without spaces - mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4" /c/CUDA - export CUDA_PATH="/c/CUDA" -elif [ "$ACCELERATOR" == "cu126" ]; then - curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe - ./cuda.exe -s nvcc_12.6 nvrtc_12.6 nvrtc_dev_12.6 cudart_12.6 cufft_12.6 cufft_dev_12.6 cuda_profiler_api_12.6 - rm cuda.exe - # Move CUDA folder to a path without spaces - mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6" /c/CUDA - export CUDA_PATH="/c/CUDA" -elif [ "$ACCELERATOR" == "cu128" ]; then - curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe - ./cuda.exe -s nvcc_12.8 nvrtc_12.8 nvrtc_dev_12.8 cudart_12.8 cufft_12.8 cufft_dev_12.8 cuda_profiler_api_12.8 - rm cuda.exe - # Move CUDA folder to a path without spaces - mv "/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8" /c/CUDA - export CUDA_PATH="/c/CUDA" elif [ "$ACCELERATOR" == "hip" ]; then curl.exe --output HIP.exe --url https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe ./HIP.exe -install diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index d4ee0fb955..913ddbac73 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -179,11 +179,18 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] _replace_name(f"openmm-unofficial-cu{cuda_ver}") - setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', - f'nvidia-cuda-nvcc-cu{cuda_ver}', - f'nvidia-cuda-nvrtc-cu{cuda_ver}', - f'nvidia-cuda-cupti-cu{cuda_ver}', - f'nvidia-cufft-cu{cuda_ver}'] + if cuda_ver == "12": + setupKeywords["install_requires"] += ['nvidia-cuda-runtime-cu12==12.4.99', + 'nvidia-cuda-nvcc-cu12==12.4.99', + 'nvidia-cuda-nvrtc-cu12==12.4.99', + 'nvidia-cuda-cupti-cu12==12.4.99', + 'nvidia-cufft-cu12==11.2.3.18'] + elif cuda_ver == "11": + setupKeywords["install_requires"] += ['nvidia-cuda-runtime-cu11==11.8.89', + 'nvidia-cuda-nvcc-cu11==11.8.89', + 'nvidia-cuda-nvrtc-cu11==11.8.89', + 'nvidia-cuda-cupti-cu11==11.8.87', + 'nvidia-cufft-cu11==10.9.0.58'] define_macros = [('MAJOR_VERSION', major_version_num), ('MINOR_VERSION', minor_version_num)] From 1e7b3d66a3d0509b357d54a30411b3c3c7543d44 Mon Sep 17 00:00:00 2001 From: Stefan Doerr Date: Wed, 27 Aug 2025 12:13:25 +0300 Subject: [PATCH 75/75] back to not hard-coding the cuda deps --- wrappers/python/setup.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 913ddbac73..28d261150d 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -179,18 +179,12 @@ def buildKeywordDictionary(major_version_num=MAJOR_VERSION_NUM, if os.getenv("ACCELERATOR", "").startswith("cu"): cuda_ver = os.getenv("ACCELERATOR", "")[2:4] _replace_name(f"openmm-unofficial-cu{cuda_ver}") - if cuda_ver == "12": - setupKeywords["install_requires"] += ['nvidia-cuda-runtime-cu12==12.4.99', - 'nvidia-cuda-nvcc-cu12==12.4.99', - 'nvidia-cuda-nvrtc-cu12==12.4.99', - 'nvidia-cuda-cupti-cu12==12.4.99', - 'nvidia-cufft-cu12==11.2.3.18'] - elif cuda_ver == "11": - setupKeywords["install_requires"] += ['nvidia-cuda-runtime-cu11==11.8.89', - 'nvidia-cuda-nvcc-cu11==11.8.89', - 'nvidia-cuda-nvrtc-cu11==11.8.89', - 'nvidia-cuda-cupti-cu11==11.8.87', - 'nvidia-cufft-cu11==10.9.0.58'] + setupKeywords["install_requires"] += [f'nvidia-cuda-runtime-cu{cuda_ver}', + f'nvidia-cuda-nvcc-cu{cuda_ver}', + f'nvidia-cuda-nvrtc-cu{cuda_ver}', + f'nvidia-cuda-cupti-cu{cuda_ver}', + f'nvidia-cufft-cu{cuda_ver}'] + define_macros = [('MAJOR_VERSION', major_version_num), ('MINOR_VERSION', minor_version_num)]