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

        if self.__package:
            # Override individual settings and just use the specified package
            package = self.__package

            # Deduce version strings from package name
            match = re.search(r'(?P<cuda>cuda\d+\.\d+)\.(?P<mofed>mofed\d+\.\d+)\.(?P<compiler>(gnu\d+\.\d+\.\d+)|(pgi\d+\.\d+))-(?P<version>\d+\.\d+)', package)
            cuda_string = match.groupdict()['cuda']
            mofed_string = match.groupdict()['mofed']
            compiler_string = match.groupdict()['compiler']
            self.version = match.groupdict()['version']
        else:
            # Build the version strings based on the specified options
            if self.__gnu:
                compiler_string = 'gnu{}'.format(self.__gnu_version)
            elif self.__pgi:
                compiler_string = 'pgi{}'.format(self.__pgi_version)
            else:
                logging.error('Unknown compiler')
                compiler_string = 'unknown'

            cuda_string = 'cuda{}'.format(self.__cuda_version)
            mofed_string = 'mofed{}'.format(self.__mofed_version)

            # Package filename
            package = self.__package_template.format(
                cuda_string, mofed_string, compiler_string, self.version,
                self.__release, self.__arch)

        self.__install_path = self.__install_path_template.format(
            self.version, cuda_string, mofed_string, compiler_string)

        # Download source from web
        url = '{0}/{1}/{2}/{3}'.format(self.__baseurl, self.version,
                                       mofed_string, package)
        self.__commands.append(self.download_step(url=url, directory=self.__wd))

        # Install the package
        self.__commands.append(
            self.__installer_template.format(posixpath.join(self.__wd,
                                                            package)))

        # Workaround for bad path in the MPI compiler wrappers
        self.__commands.append('(test -f /usr/bin/bash || ln -s /bin/bash /usr/bin/bash)')

        # Workaround for using compiler wrappers in the build stage
        cuda_home = '/usr/local/cuda'
        self.__commands.append('ln -s {0} {1}'.format(
            posixpath.join(cuda_home, 'lib64', 'stubs', 'nvidia-ml.so'),
            posixpath.join(cuda_home, 'lib64', 'stubs', 'nvidia-ml.so.1')))

        # Cleanup
        self.__commands.append(self.cleanup_step(
            items=[posixpath.join(self.__wd, package)]))

        # Setup environment variables
        self.environment_variables['PATH'] = '{}:$PATH'.format(
            posixpath.join(self.__install_path, 'bin'))
        # Workaround for using compiler wrappers in the build stage
        self.environment_variables['PROFILE_POSTLIB'] = '"-L{} -lnvidia-ml"'.format('/usr/local/cuda/lib64/stubs')

        # Set library path
        libpath = posixpath.join(self.__install_path, 'lib64')
        if self.ldconfig:
            self.__commands.append(self.ldcache_step(directory=libpath))
        else:
            self.environment_variables['LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format(libpath)
Construct the series of shell commands and environment variables,
           i.e., fill in self.__commands and self.environment_variables
hpccm/building_blocks/mvapich2_gdr.py