generated from conda/conda-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from regro/openmpi
ENH add mpi virtual packages
- Loading branch information
Showing
6 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,5 @@ coverage.xml | |
.ipynb_checkpoints/ | ||
.pytest_cache/* | ||
.pytest_cache | ||
|
||
conda_forge_conda_plugins/_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
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].strip() | ||
break | ||
except Exception: | ||
pass | ||
|
||
if openmpi_version: | ||
yield CondaVirtualPackage( | ||
name="openmpi", | ||
version=openmpi_version, | ||
build=None, | ||
) | ||
|
||
# mpich virtual package | ||
mpich_version = None | ||
if "CONDA_OVERRIDE_MPICH" in os.environ: | ||
mpich_version = os.environ["CONDA_OVERRIDE_MPICH"] | ||
else: | ||
try: | ||
ret = subprocess.run( | ||
["mpichversion", "--version"], capture_output=True, text=True | ||
) | ||
if ret.returncode == 0: | ||
for line in ret.stdout.splitlines(): | ||
if line.startswith("MPICH Version:"): | ||
mpich_version = line.strip().split(":")[1].strip() | ||
break | ||
except Exception: | ||
pass | ||
|
||
yield CondaSubcommand( | ||
name="hello", action=hello_conda, summary='Command that prints "Hello conda!"' | ||
) | ||
if mpich_version: | ||
yield CondaVirtualPackage( | ||
name="mpich", | ||
version=mpich_version, | ||
build=None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import os | ||
import subprocess | ||
|
||
|
||
def test_mpich_override(): | ||
env = {"CONDA_OVERRIDE_MPICH": "10.0.0"} | ||
env.update(dict(os.environ)) | ||
ret = subprocess.run( | ||
["conda", "info", "--json"], | ||
capture_output=True, | ||
text=True, | ||
env=env, | ||
) | ||
assert ret.returncode == 0 | ||
info = json.loads(ret.stdout) | ||
pkg = None | ||
for _pkg in info["virtual_pkgs"]: | ||
if _pkg[0] == "__mpich": | ||
pkg = _pkg | ||
break | ||
assert pkg is not None, info["virtual_pkgs"] | ||
assert pkg[1] == "10.0.0", pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import os | ||
import subprocess | ||
|
||
|
||
def test_openmpi_override(): | ||
env = {"CONDA_OVERRIDE_OPENMPI": "10.0.0"} | ||
env.update(dict(os.environ)) | ||
ret = subprocess.run( | ||
["conda", "info", "--json"], | ||
capture_output=True, | ||
text=True, | ||
env=env, | ||
) | ||
assert ret.returncode == 0 | ||
info = json.loads(ret.stdout) | ||
pkg = None | ||
for _pkg in info["virtual_pkgs"]: | ||
if _pkg[0] == "__openmpi": | ||
pkg = _pkg | ||
break | ||
assert pkg is not None, info["virtual_pkgs"] | ||
assert pkg[1] == "10.0.0", pkg |
This file was deleted.
Oops, something went wrong.