def __setup(self):
        """Construct the series of shell commands, i.e., fill in
           self.__commands"""

        # For version 2.8 and earlier, the download URL has the format
        # MAJOR.MINOR in the path and the tarball contains
        # MAJOR.MINOR.REVISION, so pull apart the full version to get
        # the individual components.
        version_string = self.__version
        if Version(self.__version) <= Version('2.8'):
            match = re.match(r'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<revision>\d+)',
                             self.__version)
            version_string = '{0}.{1}'.format(match.groupdict()['major'],
                                              match.groupdict()['minor'])

        if self.__inbox:
            # Use inbox OFED
            if Version(self.__version) >= Version('2.10'):
                # Version 2.11 and later include an extra label
                self.__label = 'hpcx-v{0}-gcc-inbox-{1}-{2}-{3}'.format(
                    self.__version, self.__oslabel, self.__buildlabel,
                    self.__arch)
            else:
                self.__label = 'hpcx-v{0}-gcc-inbox-{1}-{2}'.format(
                    self.__version, self.__oslabel, self.__arch)
        else:
            # Use MLNX OFED
            if Version(self.__version) >= Version('2.10'):
                # Version 2.10 and later include an extra label
                self.__label = 'hpcx-v{0}-{1}-{2}-{3}-{4}'.format(
                    self.__version, self.__ofedlabel, self.__oslabel, self.__buildlabel, self.__arch)
            else:
                self.__label = 'hpcx-v{0}-{1}-{2}-{3}'.format(
                    self.__version, self.__ofedlabel, self.__oslabel, self.__arch)

        tarball = self.__label + '.tbz'
        url = '{0}/v{1}/{2}'.format(self.__baseurl, version_string, tarball)

        # Download source from web
        self.__commands.append(self.download_step(url=url, directory=self.__wd))

        # "Install"
        self.__commands.append(self.untar_step(
            tarball=posixpath.join(self.__wd, tarball), directory=self.__wd))
        self.__commands.append('cp -a {0} {1}'.format(
            posixpath.join(self.__wd, self.__label), self.__prefix))

        # Set the environment
        if self.__hpcxinit:
            # Use hpcxinit script
            if self.__multi_thread:
                self.__commands.append('echo "source {0}" >> {1}'.format(
                    posixpath.join(self.__prefix, 'hpcx-mt-init-ompi.sh'),
                    self.__bashrc))
            else:
                self.__commands.append('echo "source {0}" >> {1}'.format(
                    posixpath.join(self.__prefix, 'hpcx-init-ompi.sh'),
                    self.__bashrc))
            self.__commands.append('echo "hpcx_load" >> {0}'.format(
                self.__bashrc))
        else:
            # Set environment manually
            hpcx_dir = self.__prefix
            if self.__multi_thread:
                hpcx_ucx_dir = posixpath.join(hpcx_dir, 'ucx', 'mt')
            else:
                hpcx_ucx_dir = posixpath.join(hpcx_dir, 'ucx')
            hpcx_sharp_dir = posixpath.join(hpcx_dir, 'sharp')
            hpcx_nccl_rdma_sharp_plugin_dir = posixpath.join(
                hpcx_dir, 'nccl_rdma_sharp_plugin')
            hpcx_hcoll_dir = posixpath.join(hpcx_dir, 'hcoll')
            hpcx_mpi_dir = posixpath.join(hpcx_dir, 'ompi')
            hpcx_oshmem_dir = hpcx_mpi_dir
            hpcx_mpi_tests_dir = posixpath.join(hpcx_mpi_dir, 'tests')
            if Version(self.__version) >= Version('2.7'):
                hpcx_osu_dir = posixpath.join(hpcx_mpi_tests_dir,
                                              'osu-micro-benchmarks-5.6.2')
                hpcx_osu_cuda_dir = posixpath.join(
                    hpcx_mpi_tests_dir, 'osu-micro-benchmarks-5.6.2-cuda')
            else:
                hpcx_osu_dir = posixpath.join(hpcx_mpi_tests_dir,
                                              'osu-micro-benchmarks-5.3.2')
                hpcx_osu_cuda_dir = posixpath.join(
                    hpcx_mpi_tests_dir, 'osu-micro-benchmarks-5.3.2-cuda')
            hpcx_ipm_dir = posixpath.join(hpcx_mpi_tests_dir, 'ipm-2.0.6')
            hpcx_ipm_lib = posixpath.join(hpcx_ipm_dir, 'lib', 'libipm.so')
            hpcx_clusterkit_dir = posixpath.join(hpcx_dir, 'clusterkit')

            self.environment_variables = {
                'CPATH': ':'.join([
                    posixpath.join(hpcx_hcoll_dir, 'include'),
                    posixpath.join(hpcx_mpi_dir, 'include'),
                    posixpath.join(hpcx_sharp_dir, 'include'),
                    posixpath.join(hpcx_ucx_dir, 'include'),
                    '$CPATH']),
                'HPCX_CLUSTERKIT_DIR': hpcx_clusterkit_dir,
                'HPCX_DIR': hpcx_dir,
                'HPCX_HCOLL_DIR': hpcx_hcoll_dir,
                'HPCX_IPM_DIR': hpcx_ipm_dir,
                'HPCX_IPM_LIB': hpcx_ipm_lib,
                'HPCX_MPI_DIR': hpcx_mpi_dir,
                'HPCX_MPI_TESTS_DIR': hpcx_mpi_tests_dir,
                'HPCX_NCCL_RDMA_SHARP_PLUGIN_DIR': hpcx_nccl_rdma_sharp_plugin_dir,
                'HPCX_OSHMEM_DIR': hpcx_oshmem_dir,
                'HPCX_OSU_CUDA_DIR': hpcx_osu_cuda_dir,
                'HPCX_OSU_DIR': hpcx_osu_dir,
                'HPCX_SHARP_DIR': hpcx_sharp_dir,
                'HPCX_UCX_DIR': hpcx_ucx_dir,
                'LIBRARY_PATH': ':'.join([
                    posixpath.join(hpcx_hcoll_dir, 'lib'),
                    posixpath.join(hpcx_mpi_dir, 'lib'),
                    posixpath.join(hpcx_nccl_rdma_sharp_plugin_dir, 'lib'),
                    posixpath.join(hpcx_sharp_dir, 'lib'),
                    posixpath.join(hpcx_ucx_dir, 'lib'),
                    '$LIBRARY_PATH']),
                'MPI_HOME': hpcx_mpi_dir,
                'OMPI_HOME': hpcx_mpi_dir,
                'OPAL_PREFIX': hpcx_mpi_dir,
                'OSHMEM_HOME': hpcx_mpi_dir,
                'PATH': ':'.join([
                    posixpath.join(hpcx_clusterkit_dir, 'bin'),
                    posixpath.join(hpcx_hcoll_dir, 'bin'),
                    posixpath.join(hpcx_mpi_dir, 'bin'),
                    posixpath.join(hpcx_ucx_dir, 'bin'),
                    '$PATH']),
                'PKG_CONFIG_PATH': ':'.join([
                    posixpath.join(hpcx_hcoll_dir, 'lib', 'pkgconfig'),
                    posixpath.join(hpcx_mpi_dir, 'lib', 'pkgconfig'),
                    posixpath.join(hpcx_sharp_dir, 'lib', 'pkgconfig'),
                    posixpath.join(hpcx_ucx_dir, 'lib', 'pkgconfig'),
                    '$PKG_CONFIG_PATH']),
                'SHMEM_HOME': hpcx_mpi_dir}

            # Set library path
            if self.ldconfig:
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_hcoll_dir, 'lib')))
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_mpi_dir, 'lib')))
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_nccl_rdma_sharp_plugin_dir,
                                             'lib')))
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_sharp_dir, 'lib')))
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_ucx_dir, 'lib')))
                self.__commands.append(self.ldcache_step(
                    directory=posixpath.join(hpcx_ucx_dir, 'lib', 'ucx')))
            else:
                self.environment_variables['LD_LIBRARY_PATH'] = ':'.join([
                    posixpath.join(hpcx_hcoll_dir, 'lib'),
                    posixpath.join(hpcx_mpi_dir, 'lib'),
                    posixpath.join(hpcx_nccl_rdma_sharp_plugin_dir, 'lib'),
                    posixpath.join(hpcx_sharp_dir, 'lib'),
                    posixpath.join(hpcx_ucx_dir, 'lib'),
                    posixpath.join(hpcx_ucx_dir, 'lib', 'ucx'),
                    '$LD_LIBRARY_PATH'])

        # Cleanup tarball and directory
        self.__commands.append(self.cleanup_step(
            items=[posixpath.join(self.__wd, tarball),
                   posixpath.join(self.__wd, self.__label)]))
Construct the series of shell commands, i.e., fill in
           self.__commands
hpccm/building_blocks/hpcx.py