Exemplo n.º 1
0
    def test_conda_bld_path(self):
        conda_bld_path = join(gettempdir(), 'conda-bld')
        conda_bld_url = path_to_url(conda_bld_path)
        try:
            mkdir_p(conda_bld_path)
            with env_var('CONDA_BLD_PATH',
                         conda_bld_path,
                         stack_callback=conda_tests_ctxt_mgmt_def_pol):
                assert len(context.conda_build_local_paths) >= 1
                assert context.conda_build_local_paths[0] == conda_bld_path

                channel = Channel('local')
                assert channel.channel_name == "local"
                assert channel.channel_location is None
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme is None
                assert channel.canonical_name == "local"
                assert channel.url() is None
                urls = list(
                    concat((
                        join_url(url, context.subdir),
                        join_url(url, 'noarch'),
                    ) for url in context.conda_build_local_urls))
                assert channel.urls() == urls

                channel = Channel(conda_bld_url)
                assert channel.canonical_name == "local"
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme == "file"
                assert channel.urls() == [
                    join_url(conda_bld_url, context.subdir),
                    join_url(conda_bld_url, 'noarch'),
                ]
                assert channel.url() == join_url(conda_bld_url, context.subdir)
                assert channel.channel_name.lower() == win_path_backout(
                    conda_bld_path).lstrip('/').lower()
                assert channel.channel_location == ''  # location really is an empty string; all path information is in channel_name
                assert channel.canonical_name == "local"
        finally:
            rm_rf(conda_bld_path)
Exemplo n.º 2
0
    def test_conda_bld_path(self):
        conda_bld_path = join(gettempdir(), 'conda-bld')
        conda_bld_url = path_to_url(conda_bld_path)
        try:
            mkdir_p(conda_bld_path)
            with env_var('CONDA_BLD_PATH', conda_bld_path, reset_context):
                assert len(context.conda_build_local_paths) >= 1
                assert context.conda_build_local_paths[0] == conda_bld_path

                channel = Channel('local')
                assert channel.channel_name == "local"
                assert channel.channel_location is None
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme is None
                assert channel.canonical_name == "local"
                assert channel.url() is None
                urls = list(concat((
                               join_url(url, context.subdir),
                               join_url(url, 'noarch'),
                           ) for url in context.conda_build_local_urls))
                assert channel.urls() == urls

                channel = Channel(conda_bld_url)
                assert channel.canonical_name == "local"
                assert channel.platform is None
                assert channel.package_filename is None
                assert channel.auth is None
                assert channel.token is None
                assert channel.scheme == "file"
                assert channel.urls() == [
                    join_url(conda_bld_url, context.subdir),
                    join_url(conda_bld_url, 'noarch'),
                ]
                assert channel.url() == join_url(conda_bld_url, context.subdir)
                assert channel.channel_name.lower() == win_path_backout(conda_bld_path).lstrip('/').lower()
                assert channel.channel_location == ''  # location really is an empty string; all path information is in channel_name
                assert channel.canonical_name == "local"
        finally:
            rm_rf(conda_bld_path)
    def test_init_sh_user_unix(self):
        with tempdir() as conda_temp_prefix:
            target_path = join(conda_temp_prefix, '.bashrc')

            initial_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"
              export PATH="%(prefix)s/bin:$PATH"

            # >>> conda initialize >>>
            __conda_setup="$('%(prefix)s/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
            if [ $? -eq 0 ]; then
            fi
            unset __conda_setup
            # <<< conda initialize <<<

            . etc/profile.d/conda.sh
            . etc/profile.d/coda.sh
            . /somewhere/etc/profile.d/conda.sh
            source /etc/profile.d/conda.sh

            \t source %(prefix)s/etc/profile.d/conda.sh
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }

            with open(target_path, 'w') as fh:
                fh.write(initial_content)

            init_sh_user(target_path, conda_temp_prefix, 'bash')

            with open(target_path) as fh:
                new_content = fh.read()

            expected_new_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            # export PATH="%(prefix)s/bin:$PATH"  # commented out by conda initialize
            # export PATH="%(prefix)s/bin:$PATH"  # commented out by conda initialize

            # >>> conda initialize >>>
            # !! Contents within this block are managed by 'conda init' !!
            __conda_setup="$('%(prefix)s/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
            if [ $? -eq 0 ]; then
                eval "$__conda_setup"
            else
                if [ -f "%(prefix)s/etc/profile.d/conda.sh" ]; then
                    . "%(prefix)s/etc/profile.d/conda.sh"
                else
                    export PATH="%(prefix)s/bin:$PATH"
                fi
            fi
            unset __conda_setup
            # <<< conda initialize <<<

            # . etc/profile.d/conda.sh  # commented out by conda initialize
            . etc/profile.d/coda.sh
            # . /somewhere/etc/profile.d/conda.sh  # commented out by conda initialize
            # source /etc/profile.d/conda.sh  # commented out by conda initialize

            # source %(prefix)s/etc/profile.d/conda.sh  # commented out by conda initialize
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }
            print(new_content)
            assert new_content == expected_new_content

            expected_reversed_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"

            . etc/profile.d/conda.sh
            . etc/profile.d/coda.sh
            . /somewhere/etc/profile.d/conda.sh
            source /etc/profile.d/conda.sh

            source %(prefix)s/etc/profile.d/conda.sh
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }

            init_sh_user(target_path, conda_temp_prefix, 'bash', reverse=True)
            with open(target_path) as fh:
                reversed_content = fh.read()
            print(reversed_content)
            assert reversed_content == expected_reversed_content
Exemplo n.º 4
0
    def test_init_sh_user_unix(self):
        with tempdir() as conda_temp_prefix:
            target_path = join(conda_temp_prefix, '.bashrc')

            initial_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"
              export PATH="%(prefix)s/bin:$PATH"
              
            # >>> conda initialize >>>
            __conda_setup="$('%(prefix)s/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
            if [ $? -eq 0 ]; then
            fi
            unset __conda_setup
            # <<< conda initialize <<<
            
            . etc/profile.d/conda.sh
            . etc/profile.d/coda.sh
            . /somewhere/etc/profile.d/conda.sh
            source /etc/profile.d/conda.sh
            
            \t source %(prefix)s/etc/profile.d/conda.sh
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }

            with open(target_path, 'w') as fh:
                fh.write(initial_content)

            init_sh_user(target_path, conda_temp_prefix, 'bash')

            with open(target_path) as fh:
                new_content = fh.read()

            expected_new_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            # export PATH="%(prefix)s/bin:$PATH"  # commented out by conda initialize
            # export PATH="%(prefix)s/bin:$PATH"  # commented out by conda initialize
            
            # >>> conda initialize >>>
            # !! Contents within this block are managed by 'conda init' !!
            __conda_setup="$('%(prefix)s/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
            if [ $? -eq 0 ]; then
                eval "$__conda_setup"
            else
                if [ -f "%(prefix)s/etc/profile.d/conda.sh" ]; then
                    . "%(prefix)s/etc/profile.d/conda.sh"
                else
                    export PATH="%(prefix)s/bin:$PATH"
                fi
            fi
            unset __conda_setup
            # <<< conda initialize <<<
            
            # . etc/profile.d/conda.sh  # commented out by conda initialize
            . etc/profile.d/coda.sh
            # . /somewhere/etc/profile.d/conda.sh  # commented out by conda initialize
            # source /etc/profile.d/conda.sh  # commented out by conda initialize
            
            # source %(prefix)s/etc/profile.d/conda.sh  # commented out by conda initialize
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }
            print(new_content)
            assert new_content == expected_new_content

            expected_reversed_content = dals("""
            export PATH="/some/other/conda/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"
            export PATH="%(prefix)s/bin:$PATH"
            
            . etc/profile.d/conda.sh
            . etc/profile.d/coda.sh
            . /somewhere/etc/profile.d/conda.sh
            source /etc/profile.d/conda.sh
            
            source %(prefix)s/etc/profile.d/conda.sh
            """) % {
                'prefix': win_path_backout(abspath(conda_temp_prefix)),
            }

            init_sh_user(target_path, conda_temp_prefix, 'bash', reverse=True)
            with open(target_path) as fh:
                reversed_content = fh.read()
            print(reversed_content)
            assert reversed_content == expected_reversed_content
Exemplo n.º 5
0
def test_win_path_backout():
    assert win_path_backout("file://\\\\machine\\shared_folder\\path\\conda"
                            ) == "file://machine/shared_folder/path/conda"
    assert win_path_backout("file://\\\\machine\\shared\\ folder\\path\\conda"
                            ) == "file://machine/shared\\ folder/path/conda"
Exemplo n.º 6
0
def test_win_path_backout():
    assert win_path_backout("file://\\\\machine\\shared_folder\\path\\conda") == "file://machine/shared_folder/path/conda"
    assert win_path_backout("file://\\\\machine\\shared\\ folder\\path\\conda") == "file://machine/shared\\ folder/path/conda"