Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH add mpi virtual packages #4

Merged
merged 9 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ coverage.xml
.ipynb_checkpoints/
.pytest_cache/*
.pytest_cache

conda_forge_conda_plugins/_version.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ conda plugins for the `conda-forge` ecosystem

### OpenMPI Virtual Package

This plugin provides the `__openmpi` virtual package to be used in conjunction with the `external*` builds of the `conda-forge` `openmpi` package.
This plugin provides the `__openmpi` virtual package to be used in conjunction with the `external*` builds of the `conda-forge` `openmpi` package. If the `ompi_info` command is found in the path, the `__openmpi` virtual package is set to the installed version of OpenMPI. You can override the version by setting the `CONDA_OVERRIDE_OPENMPI` environment variable.
34 changes: 27 additions & 7 deletions conda_forge_conda_plugins/hooks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
from conda.plugins import CondaSubcommand, hookimpl
import os
import subprocess

from conda.plugins import CondaVirtualPackage, hookimpl


@hookimpl
def conda_subcommands():
def hello_conda(args):
print("Hello conda!")
def conda_virtual_packages():
# openmpi virtual package
openmpi_version = None
if "CONDA_OVERRIDE_OPENMPI" in os.environ:
openmpi_version = os.environ["CONDA_OVERRIDE_OPENMPI"]
else:
try:
ret = subprocess.run(
["ompi_info", "--parsable"], capture_output=True, text=True
)
if ret.returncode == 0:
for line in ret.stdout.splitlines():
if line.startswith("ompi:version:full:"):
openmpi_version = line.strip().split(":")[3]
break
except Exception:
pass

yield CondaSubcommand(
name="hello", action=hello_conda, summary='Command that prints "Hello conda!"'
)
if openmpi_version is not None:
beckermr marked this conversation as resolved.
Show resolved Hide resolved
yield CondaVirtualPackage(
name="openmpi",
version=openmpi_version,
build=None,
)