コード例 #1
0
    def do_test(dirname):
        envdir = os.path.join(dirname, "myenv")
        print('CONDA_EXE: {}'.format(os.environ.get('CONDA_EXE')))
        # originally we did not specify a python version here, but we
        # needed to add it with python 3.8 was released because a compatible
        # version of ipython had not been created yet.
        conda_api.create(prefix=envdir, pkgs=['python<3.8'])

        assert os.path.isdir(envdir)
        assert os.path.isdir(os.path.join(envdir, "conda-meta"))
        assert os.path.exists(os.path.join(envdir, PYTHON_BINARY))

        # test that if it exists we can't create it again
        with pytest.raises(conda_api.CondaEnvExistsError) as excinfo:
            conda_api.create(prefix=envdir, pkgs=['python'])
        assert 'already exists' in repr(excinfo.value)

        # test that we can install a package
        assert not os.path.exists(os.path.join(envdir, IPYTHON_BINARY))
        conda_api.install(prefix=envdir, pkgs=['ipython'])
        assert os.path.exists(os.path.join(envdir, IPYTHON_BINARY))

        # test that we can remove it again
        conda_api.remove(prefix=envdir, pkgs=['ipython'])
        assert not os.path.exists(os.path.join(envdir, IPYTHON_BINARY))
コード例 #2
0
    def do_test(dirname):
        envdir = os.path.join(dirname, "myenv")

        conda_api.create(prefix=envdir, pkgs=['python'])

        with pytest.raises(TypeError) as excinfo:
            conda_api.remove(prefix=envdir, pkgs=[])
        assert 'must specify a list' in repr(excinfo.value)
コード例 #3
0
 def remove_packages(self, prefix, packages):
     try:
         conda_api.remove(prefix,
                          packages,
                          stdout_callback=self._on_stdout,
                          stderr_callback=self._on_stderr)
     except conda_api.CondaError as e:
         raise CondaManagerError("Failed to remove packages from %s: %s" %
                                 (prefix, str(e)))
コード例 #4
0
 def remove_packages(self, prefix, packages, pip=False):
     if pip:
         try:
             pip_api.remove(prefix,
                            packages,
                            stdout_callback=self._on_stdout,
                            stderr_callback=self._on_stderr)
         except pip_api.PipError as e:
             raise CondaManagerError(
                 'Failed to remove pip packages from {}: {}'.format(
                     prefix, str(e)))
     else:
         try:
             conda_api.remove(prefix,
                              packages,
                              stdout_callback=self._on_stdout,
                              stderr_callback=self._on_stderr)
         except conda_api.CondaError as e:
             raise CondaManagerError(
                 "Failed to remove packages from %s: %s" % (prefix, str(e)))
コード例 #5
0
    def do_test(dirname):
        envdir = os.path.join(dirname, "myenv")
        # don't specify a python version so we use the one we already have
        # in the root env, otherwise this might take forever.
        conda_api.create(prefix=envdir, pkgs=['python'])

        assert os.path.isdir(envdir)
        assert os.path.isdir(os.path.join(envdir, "conda-meta"))
        assert os.path.exists(os.path.join(envdir, PYTHON_BINARY))

        # test that if it exists we can't create it again
        with pytest.raises(conda_api.CondaEnvExistsError) as excinfo:
            conda_api.create(prefix=envdir, pkgs=['python'])
        assert 'already exists' in repr(excinfo.value)

        # test that we can install a package
        assert not os.path.exists(os.path.join(envdir, IPYTHON_BINARY))
        conda_api.install(prefix=envdir, pkgs=['ipython'])
        assert os.path.exists(os.path.join(envdir, IPYTHON_BINARY))

        # test that we can remove it again
        conda_api.remove(prefix=envdir, pkgs=['ipython'])
        assert not os.path.exists(os.path.join(envdir, IPYTHON_BINARY))
コード例 #6
0
 def remove_packages(self, prefix, packages):
     try:
         conda_api.remove(prefix, packages)
     except conda_api.CondaError as e:
         raise CondaManagerError("Failed to remove packages from %s: %s" % (prefix, str(e)))