コード例 #1
0
def test_retrace_to_output_file(reprozip_spec2):
    with make_tempfile() as outfile:
        args = ['retrace', '--spec', reprozip_spec2, '--output-file', outfile]
        main(args)

        ## Perform a simple check of whether the output file can be
        ## loaded.
        provenance = Provenance.factory(outfile)
        assert len(provenance.get_distributions()) == 1
コード例 #2
0
    def install_packages(self, session=None):
        """
        Install the packages associated to this distribution by the provenance
        into the environment.

        Parameters
        ----------
        session : object
            Environment sub-class instance.

        Raises
        ------
        ValueError
            Unexpected conda platform or python version
        CommandError
            If unexpected error in install commands occurs
        """

        if not self.path:  # Permit empty conda config entry
            return

        if not session:
            session = get_local_session()

        # Use the session to make a temporary directory for our install files
        tmp_dir = session.mktmpdir()
        try:
            # Install Conda
            # See if Conda root path exists and if not, install Conda
            if not session.isdir(self.path):
                # TODO: Determine if we can detect miniconda vs anaconad
                miniconda_url = get_miniconda_url(self.platform,
                                                  self.python_version)
                session.execute_command("curl %s -o %s/miniconda.sh" %
                                        (miniconda_url, tmp_dir))
                # NOTE: miniconda.sh makes parent directories automatically
                session.execute_command("bash -b %s/miniconda.sh -b -p %s" %
                                        (tmp_dir, self.path))
            ## Update root version of conda
            session.execute_command(
                "%s/bin/conda install -y conda=%s python=%s" %
                (self.path, self.conda_version,
                 self.get_simple_python_version(self.python_version)))

            # Loop through non-root packages, creating the conda-env config
            for env in self.environments:
                export_contents = self.create_conda_export(env)
                with make_tempfile(export_contents) as local_config:
                    remote_config = os.path.join(tmp_dir, env.name)
                    session.put(local_config, remote_config)
                    if not session.isdir(env.path):
                        try:
                            session.execute_command(
                                "%s/bin/conda-env create -p %s -f %s " %
                                (self.path, env.path, remote_config))
                        except CommandError:
                            # Some conda versions seg fault so try to update
                            session.execute_command(
                                "%s/bin/conda-env update -p %s -f %s " %
                                (self.path, env.path, remote_config))
                    else:
                        session.execute_command(
                            "%s/bin/conda-env update -p %s -f %s " %
                            (self.path, env.path, remote_config))

        finally:
            if tmp_dir:
                # Remove the tmp dir
                session.execute_command(["rm", "-R", tmp_dir])

        return
コード例 #3
0
ファイル: conda.py プロジェクト: jdkent/reproman
    def install_packages(self, session=None):
        """
        Install the packages associated to this distribution by the provenance
        into the environment.

        Parameters
        ----------
        session : object
            Environment sub-class instance.

        Raises
        ------
        ValueError
            Unexpected conda platform or python version
        CommandError
            If unexpected error in install commands occurs
        """

        if not self.path:  # Permit empty conda config entry
            return

        if not session:
            session = get_local_session()

        # Use the session to make a temporary directory for our install files
        tmp_dir = session.mktmpdir()
        try:
            # Install Conda
            # See if Conda root path exists and if not, install Conda
            if not session.isdir(self.path):
                # TODO: Determine if we can detect miniconda vs anaconad
                miniconda_url = get_miniconda_url(self.platform,
                                                  self.python_version)
                session.execute_command(
                    "curl --fail --silent --show-error --location "
                    "--output {}/miniconda.sh {}".format(
                        tmp_dir, miniconda_url))
                # NOTE: miniconda.sh makes parent directories automatically
                session.execute_command("bash -b %s/miniconda.sh -b -p %s" %
                                        (tmp_dir, self.path))
            envs = sorted(
                self.environments,
                # Create/update the root environment before handling anything
                # else.
                key=lambda x: "_" if x.name == "root" else "_" + x.name)
            for env in envs:
                export_contents = self.create_conda_export(env)
                with make_tempfile(export_contents) as local_config:
                    remote_config = os.path.join(tmp_dir, env.name + ".yaml")
                    session.put(local_config, remote_config)
                    if not session.isdir(env.path):
                        try:
                            session.execute_command(
                                "%s/bin/conda-env create -p %s -f %s " %
                                (self.path, env.path, remote_config))
                        except CommandError:
                            # Some conda versions seg fault so try to update
                            session.execute_command(
                                "%s/bin/conda-env update -p %s -f %s " %
                                (self.path, env.path, remote_config))
                    else:
                        session.execute_command(
                            "%s/bin/conda-env update -p %s -f %s " %
                            (self.path, env.path, remote_config))

        finally:
            if tmp_dir:
                # Remove the tmp dir
                session.execute_command(["rm", "-R", tmp_dir])

        return