Skip to content
Advertisement

Single “=” after dependency version specifier in setup.py

I’m looking at a setup.py with this syntax:

from setuptools import setup

setup(
...
    tests_require=["h5py>=2.9=mpi*",
                   "mpi4py"]
)

I understand the idea of the “>=” where h5py should be at least version 2.9, but I cannot for the life of me understand the =mpi* afterwards. Is it saying the version should somehow match the mpi version, while also being at least 2.9?

I can’t find anything that explains specifying python package versions that also explains the use of a single =.

The only other place I’ve found it used is some obscure blog post that seemed to imply it was sort of like importing the package with an alias, which doesn’t make much sense to me; and also the mpi4py docs that include a command line snippet conda install -c conda-forge h5py=*=mpi* netcdf4=*=mpi* but don’t really explain it.

Advertisement

Answer

Short answer

The =mpi* qualifier says that you want to install h5py pre-compiled with MPI support.

Details

If you look at the documentation for h5py, you’ll see references to having to build it with or without MPI explicitly (e.g., see https://docs.h5py.org/en/latest/build.html).

When you look at the conda-forge download files (https://anaconda.org/conda-forge/h5py/files) you’ll also see that there are a bunch of nompi variants and a bunch of mpi variants.

Adding =mpi* triggers getting a version that’s been compiled with MPI so that you get parallel MPI support, while I suspect the default version would come without MPI support.

Experimentation with and without

When I do conda install -c conda-forge h5py=3.7, conda proposes to download this bundle:

h5py-3.7.0-nompi_py39hd4deaf1_100

But when I did conda install =c conda-forget h5py=3.7=mpi*, I expected a ...-mpi_py... bundle but instead it just failed because I’m on Windows and MPI is not supported on Windows as far as I can tell. (And that makes sense, HPC clusters with MPI run on Linux.)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement