Пример #1
0
def test_metadata_read_metadata():
    func = PythonDistributionMetadata._read_metadata

    # Test existing file unknown key
    temp_path, fpaths = _create_test_files((
        ('', 'PKG-INFO', 'Unknown-Key: unknown\n'),
    ))
    output = func(fpaths[0])
    expected_output = odict()
    _print_output(output, expected_output)
    assert output == expected_output

    # Test existing file known key
    temp_path, fpaths = _create_test_files((
        ('', 'PKG-INFO', 'Name: spam\n'),
    ))
    output = func(fpaths[0])
    expected_output = odict(name='spam')
    _print_output(output, expected_output)
    assert output == expected_output

    # Test non existing file
    test_fpath = '/foo/bar/METADATA'
    output = func(test_fpath)
    expected_output = odict()
    _print_output(output, expected_output)
    assert output == expected_output
Пример #2
0
def test_PrefixData_contract():
    init_args = odict((
        ('self', PositionalArgument),
        ('prefix_path', PositionalArgument),
    ))
    inspect_arguments(PrefixData.__init__, init_args)

    get_args = odict((
        ('self', PositionalArgument),
        ('package_ref', PositionalArgument),
        ('default', NULL),
    ))
    inspect_arguments(PrefixData.get, get_args)

    query_args = odict((
        ('self', PositionalArgument),
        ('package_ref_or_match_spec', PositionalArgument),
    ))
    inspect_arguments(PrefixData.query, query_args)

    iter_records_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PrefixData.iter_records, iter_records_args)

    isinstance(PrefixData.is_writable, property)

    reload_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PrefixData.reload, reload_args)
Пример #3
0
def test_SubdirData_contract():
    init_args = odict((
        ('self', PositionalArgument),
        ('channel', PositionalArgument),
    ))
    inspect_arguments(SubdirData.__init__, init_args)

    query_args = odict((
        ('self', PositionalArgument),
        ('package_ref_or_match_spec', PositionalArgument),
    ))
    inspect_arguments(SubdirData.query, query_args)

    query_all_args = odict((
        ('package_ref_or_match_spec', PositionalArgument),
        ('channels', None),
        ('subdirs', None),
    ))
    inspect_arguments(SubdirData.query_all, query_all_args)

    iter_records_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(SubdirData.iter_records, iter_records_args)

    reload_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(SubdirData.reload, reload_args)
Пример #4
0
def test_get_entry_points():
    test_files = (
        ('', 'METADATA', 'Name: spam\n'),
        ('', 'entry_points.txt', '[console_scripts]\ncheese = cli:main\n'),
    )
    temp_path, fpaths = _create_test_files(test_files)

    dist = PythonEggInfoDistribution(temp_path, "2.7", None)
    output = dist.get_entry_points()
    expected_output = odict(console_scripts=odict(cheese='cli:main'))
    _print_output(output, expected_output)
    assert output == expected_output
Пример #5
0
def test_get_conda_anchor_files_and_records():
    valid_tests = [
        os.sep.join(('v', 'site-packages', 'spam', '.egg-info', 'PKG-INFO')),
        os.sep.join(('v', 'site-packages', 'foo', '.dist-info', 'RECORD')),
        os.sep.join(('v', 'site-packages', 'bar', '.egg-info')),
    ]
    invalid_tests = [
        os.sep.join(('i', 'site-packages', '.egg-link')),
        os.sep.join(('i', 'spam', '.egg-info', 'PKG-INFO')),
        os.sep.join(('i', 'foo', '.dist-info', 'RECORD')),
        os.sep.join(('i', 'bar', '.egg-info')),
        os.sep.join(('i', 'site-packages', 'spam')),
        os.sep.join(('i', 'site-packages', 'foo')),
        os.sep.join(('i', 'site-packages', 'bar')),
    ]
    tests = valid_tests + invalid_tests
    records = []
    for path in tests:
        record = DummyPythonRecord()
        record.files = [path]
        records.append(record)

    output = get_conda_anchor_files_and_records(records)
    expected_output = odict()
    for i in range(len(valid_tests)):
        expected_output[valid_tests[i]] = records[i]

    _print_output(output, expected_output)
    assert output, expected_output
Пример #6
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          darwin: https://some.url.somewhere/stuff
          chuck: http://user1:[email protected]:8080/t/tk-1234/with/path
          pkgs/free: http://192.168.0.15:8080
        migrated_custom_channels:
          darwin: s3://just/cant
          chuck: file:///var/lib/repo/
          pkgs/free: https://repo.continuum.io
        migrated_channel_aliases:
          - https://conda.anaconda.org
        channel_alias: ftp://new.url:8082
        default_channels:
          - http://192.168.0.15:8080/pkgs/free
          - http://192.168.0.15:8080/pkgs/pro
          - http://192.168.0.15:8080/pkgs/msys2
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir

        cls.DEFAULT_URLS = ['http://192.168.0.15:8080/pkgs/free/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/free/noarch',
                            'http://192.168.0.15:8080/pkgs/pro/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/pro/noarch',
                            'http://192.168.0.15:8080/pkgs/msys2/%s' % cls.platform,
                            'http://192.168.0.15:8080/pkgs/msys2/noarch',
                            ]
Пример #7
0
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     custom_multichannels:
       michele:
         - https://do.it.with/passion
         - learn_from_every_thing
       steve:
         - more-downloads
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     conda-build:
       root-dir: /some/test/path
     proxy_servers:
       http: http://user:[email protected]:8080
       https: none
       ftp:
       sftp: ''
       ftps: false
       rsync: 'false'
     aggressive_update_packages: []
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._set_raw_data(rd)
Пример #8
0
def test_get_conda_anchor_files_and_records():
    valid_tests = [
        'v/site-packages/spam.egg-info/PKG-INFO',
        'v/site-packages/foo.dist-info/RECORD',
        'v/site-packages/bar.egg-info',
    ]
    invalid_tests = [
        'v/site-packages/valid-package/_vendor/invalid-now.egg-info/PKG-INFO',
        'i/site-packages/stuff.egg-link',
        'i/spam.egg-info/PKG-INFO',
        'i/foo.dist-info/RECORD',
        'i/bar.egg-info',
        'i/site-packages/spam',
        'i/site-packages/foo',
        'i/site-packages/bar',
    ]
    tests = valid_tests + invalid_tests
    records = []
    for path in tests:
        record = DummyPythonRecord()
        record.files = [path]
        records.append(record)

    output = get_conda_anchor_files_and_records("v/site-packages", records)
    expected_output = odict()
    for i in range(len(valid_tests)):
        expected_output[valid_tests[i]] = records[i]

    _print_output(output, expected_output)
    assert output == expected_output
Пример #9
0
 def test_channels_with_dashes(self):
     # regression test for #5763
     assert context.channels == ('http://test/conda/anaconda-cluster',)
     channel_urls = prioritize_channels(context.channels)
     assert channel_urls == odict((
         ('http://test/conda/anaconda-cluster/%s' % context.subdir, ('http://test/conda/anaconda-cluster', 0)),
         ('http://test/conda/anaconda-cluster/noarch', ('http://test/conda/anaconda-cluster', 0)),
     ))
Пример #10
0
 def test_client_ssl_cert(self):
     string = dals("""
     client_ssl_cert_key: /some/key/path
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._set_raw_data(rd)
     pytest.raises(ValidationError, context.validate_configuration)
Пример #11
0
 def test_map_parameter_must_be_map(self):
     # regression test for conda/conda#3467
     string = dals("""
     proxy_servers: bad values
     """)
     data = odict(s1=YamlRawParameter.make_raw_parameters('s1', yaml_load(string)))
     config = SampleConfiguration()._set_raw_data(data)
     raises(InvalidTypeError, config.validate_all)
Пример #12
0
def test_Solver_inputs_contract():
    init_args = odict((
        ('self', PositionalArgument),
        ('prefix', PositionalArgument),
        ('channels', PositionalArgument),
        ('subdirs', ()),
        ('specs_to_add', ()),
        ('specs_to_remove', ()),
    ))
    inspect_arguments(Solver.__init__, init_args)

    solve_final_state_args = odict((
        ('self', PositionalArgument),
        ('update_modifier', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
    ))
    inspect_arguments(Solver.solve_final_state, solve_final_state_args)

    solve_for_diff_args = odict((
        ('self', PositionalArgument),
        ('update_modifier', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
        ('force_reinstall', False),
    ))
    inspect_arguments(Solver.solve_for_diff, solve_for_diff_args)

    solve_for_transaction_args = odict((
        ('self', PositionalArgument),
        ('update_modifier', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
        ('force_reinstall', False),
    ))
    inspect_arguments(Solver.solve_for_transaction, solve_for_transaction_args)
Пример #13
0
def test_basepydist_parse_entries_file_data():
    func = PythonDistribution._parse_entries_file_data
    data = '''
[a]
a = cli:main_1

[b.c]
b = cli:MAIN_2

[b.d]
C = cli:MAIN_3
'''
    expected_output = odict()
    expected_output['a'] = odict([('a', 'cli:main_1')])
    expected_output['b.c'] = odict([('b', 'cli:MAIN_2')])
    expected_output['b.d'] = odict([('C', 'cli:MAIN_3')])
    output = func(data)

    _print_output(output, expected_output)
    assert output == expected_output
Пример #14
0
def test_Solver_contract():
    init_args = odict((
        ('self', NULL),
        ('prefix', NULL),
        ('channels', NULL),
        ('subdirs', ()),
        ('specs_to_add', ()),
        ('specs_to_remove', ()),
    ))
    inspect_arguments(Solver.__init__, init_args)

    solve_final_state_args = odict((
        ('self', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
    ))
    inspect_arguments(Solver.solve_final_state, solve_final_state_args)

    solve_for_diff_args = odict((
        ('self', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
        ('force_reinstall', False),
    ))
    inspect_arguments(Solver.solve_for_diff, solve_for_diff_args)

    solve_for_transaction_args = odict((
        ('self', NULL),
        ('deps_modifier', NULL),
        ('prune', NULL),
        ('ignore_pinned', NULL),
        ('force_remove', NULL),
        ('force_reinstall', False),
    ))
    inspect_arguments(Solver.solve_for_transaction, solve_for_transaction_args)
Пример #15
0
 def to_dict(self, stream=None):
     d = odict([('name', self.name)])
     if self.channels:
         d['channels'] = self.channels
     if self.dependencies:
         d['dependencies'] = self.dependencies.raw
     if self.variables:
         d['variables'] = self.variables
     if self.prefix:
         d['prefix'] = self.prefix
     if stream is None:
         return d
     stream.write(json.dumps(d))
Пример #16
0
 def test_specify_same_channels_cli_as_in_condarc(self):
     # When the channel have been specified in condarc, these channels
     # should be used along with the one specified
     # In this test, the given channel in cli is the same as in condarc
     # 'defaults' should not be added
     # See https://github.com/conda/conda/issues/10732
     reset_context((), argparse_args=AttrDict(channel=['conda-forge']))
     string = dals("""
     channels: ['conda-forge']
     """)
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_round_trip_load(string)))
     context._set_raw_data(rd)
     assert context.channels == ('conda-forge', )
Пример #17
0
    def setUpClass(cls):
        string = dals("""
        default_channels:
           - http://test/conda/anaconda
        channels:
           - http://test/conda/anaconda-cluster
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #18
0
    def setUpClass(cls):
        string = dals("""
        default_channels:
           - http://test/conda/anaconda
        channels:
           - http://test/conda/anaconda-cluster
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #19
0
    def setUpClass(cls):
        string = dals("""
        channel_alias: https://10.2.3.4:8080/conda/t/tk-123-45
        migrated_channel_aliases:
          - https://conda.anaconda.org
          - http://10.2.3.4:7070/conda
        """)
        reset_context(())
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #20
0
    def setUpClass(cls):
        string = dals("""
        channel_alias: https://10.2.3.4:8080/conda/t/tk-123-45
        migrated_channel_aliases:
          - https://conda.anaconda.org
          - http://10.2.3.4:7070/conda
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #21
0
 def test_specify_different_channels_cli_condarc(self):
     """
     When the channel have been specified in condarc, these channels
     should be used along with the one specified
     In this test, the given channel in cli is different from condarc
     'defaults' should not be added
     """
     reset_context((), argparse_args=AttrDict(channel=['other']))
     string = dals("""
     channels: ['conda-forge']
     """)
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_round_trip_load(string)))
     context._set_raw_data(rd)
     assert context.channels == ('conda-forge', 'other')
Пример #22
0
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._add_raw_data(rd)
Пример #23
0
 def setUpClass(cls):
     channels_config = dals("""
     channels:
       - http://user22:[email protected]:8080
       
     whitelist_channels:
       - http://user22:[email protected]:8080
     
     custom_channels:
       unexpanded: http://user1:[email protected]:8080/with/path/t/tk-1234
       expanded: http://user33:[email protected]:8080/with/path/t/tk-1234
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(channels_config)))
     context._set_raw_data(rd)
Пример #24
0
 def setUpClass(cls):
     channels_config = dals("""
     channels:
       - http://user22:[email protected]:8080
       
     whitelist_channels:
       - http://user22:[email protected]:8080
     
     custom_channels:
       unexpanded: http://user1:[email protected]:8080/with/path/t/tk-1234
       expanded: http://user33:[email protected]:8080/with/path/t/tk-1234
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(channels_config)))
     context._set_raw_data(rd)
Пример #25
0
 def setUp(self):
     string = dals("""
     custom_channels:
       darwin: https://some.url.somewhere/stuff
       chuck: http://another.url:8080/with/path
     migrated_custom_channels:
       darwin: s3://just/cant
       chuck: file:///var/lib/repo/
     migrated_channel_aliases:
       - https://conda.anaconda.org
     channel_alias: ftp://new.url:8082
     """)
     reset_context()
     rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
     context._add_raw_data(rd)
Пример #26
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/anaconda
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._set_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #27
0
    def setUpClass(cls):
        string = dals("""
        custom_channels:
          chuck: http://user1:[email protected]:8080/with/path/t/tk-1234
          chuck/subchan: http://user33:[email protected]:8080/with/path/t/tk-1234
        channel_alias: ftp://nm:[email protected]:8082/t/zyx-wvut/
        channels:
          - mickey
          - https://conda.anaconda.cloud/t/tk-12-token/minnie
          - http://dont-do:[email protected]/daffy/label/main
        default_channels:
          - http://192.168.0.15:8080/pkgs/free
          - donald/label/main
          - http://us:[email protected]:8080/t/tkn-123/pkgs/r
        """)
        reset_context()
        rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
        context._add_raw_data(rd)
        Channel._reset_state()

        cls.platform = context.subdir
Пример #28
0
def test_PackageCacheData_contract():
    init_args = odict((
        ('self', PositionalArgument),
        ('pkgs_dir', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.__init__, init_args)

    get_args = odict((
        ('self', PositionalArgument),
        ('package_ref', PositionalArgument),
        ('default', NULL),
    ))
    inspect_arguments(PackageCacheData.get, get_args)

    query_args = odict((
        ('self', PositionalArgument),
        ('package_ref_or_match_spec', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.query, query_args)

    query_all_args = odict((
        ('package_ref_or_match_spec', PositionalArgument),
        ('pkgs_dirs', None),
    ))
    inspect_arguments(PackageCacheData.query_all, query_all_args)

    iter_records_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.iter_records, iter_records_args)

    isinstance(PackageCacheData.is_writable, property)

    first_writable_args = odict((
        ('pkgs_dirs', None),
    ))
    inspect_arguments(PackageCacheData.first_writable, first_writable_args)

    reload_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.reload, reload_args)
Пример #29
0
def test_PackageCacheData_contract():
    init_args = odict((
        ('self', PositionalArgument),
        ('pkgs_dir', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.__init__, init_args)

    get_args = odict((
        ('self', PositionalArgument),
        ('package_ref', PositionalArgument),
        ('default', NULL),
    ))
    inspect_arguments(PackageCacheData.get, get_args)

    query_args = odict((
        ('self', PositionalArgument),
        ('package_ref_or_match_spec', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.query, query_args)

    query_all_args = odict((
        ('package_ref_or_match_spec', PositionalArgument),
        ('pkgs_dirs', None),
    ))
    inspect_arguments(PackageCacheData.query_all, query_all_args)

    iter_records_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.iter_records, iter_records_args)

    isinstance(PackageCacheData.is_writable, property)

    first_writable_args = odict((
        ('pkgs_dirs', None),
    ))
    inspect_arguments(PackageCacheData.first_writable, first_writable_args)

    reload_args = odict((
        ('self', PositionalArgument),
    ))
    inspect_arguments(PackageCacheData.reload, reload_args)
Пример #30
0
def bypass_satsolver_on_install(
    pkg_names, conda_channel="ggd-genomics", debug=False, prefix=None
):
    """Method to bypass the sat solver used by conda when a cached recipe is being installed

    bypass_satsolver_on_install
    ============================
    This method is used to run the conda install steps to install a ggd aws cahced reicpe. The
        intsallation will skip the sat solver step, ignore packages that may be additionaly installed
        or uninstalled, and performs other steps in order to install the data package without using 
        the sat solver. 
    The majority of the work is still done by conda through the use of the conda module. This method
        should only be used when a cached recipe is being installed.

    Parameters:
    -----------
    #1) pkg_name: The name of the ggd package to install. (Example: hg19-gaps)
    1) pkg_names: A list of the names of the ggd packages to install. (Example: [hg19-gaps])
    2) conda_channel: The ggd conda channel that package is being installed from. (Example: ggd-genomics)
    """

    # -------------------------------------------------------------------------
    # import statments
    # -------------------------------------------------------------------------
    from conda.base.context import context
    from conda.cli import common
    from conda.cli import install
    from conda.core.solve import Solver
    from conda.core.solve import SolverStateContainer
    from conda.common.io import Spinner
    from conda.core.link import PrefixSetup
    from conda.core.link import UnlinkLinkTransaction
    from argparse import Namespace
    from conda._vendor.boltons.setutils import IndexedSet
    from conda.models.prefix_graph import PrefixGraph
    from conda.core.solve import diff_for_unlink_link_precs
    from conda.common.compat import iteritems, itervalues, odict, text_type
    from conda._vendor.toolz import concat, concatv
    from conda.resolve import Resolve
    from conda.models.match_spec import MatchSpec
    from conda.base.constants import UpdateModifier
    from conda.common.io import ProgressBar
    from conda.gateways.logging import set_all_logger_level, set_conda_log_level
    from conda.gateways.logging import VERBOSITY_LEVELS
    from conda.gateways.logging import log
    from logging import (
        DEBUG,
        ERROR,
        Filter,
        Formatter,
        INFO,
        StreamHandler,
        WARN,
        getLogger,
    )
    import sys

    print(
        "\n:ggd:utils:bypass: Installing %s from the %s conda channel\n"
        % (", ".join(pkg_names), conda_channel)
    )

    # -------------------------------------------------------------------------
    # Nested functions
    # -------------------------------------------------------------------------
    # def bypass_sat(package_name,ssc_object): ## Package_name will be used as a key
    def bypass_sat(package_names, ssc_object):  ## Package_name will be used as a key
        """Method used to extract information during sat solving, but to bypass the sat solving step

        bypass_sat
        ==========
        This method is used to extract and process information that would have been done during the sat
        solvering step, (Solving Enviroment), bypass the sat solver, and return a filtered set of packages
        to install.

        Parameters:
        -----------
        #1) package_name: The name of the package to extract. (This is the package that will be installed)
        1) package_names: A list of package names of the packages to extract. (This is the package that will be installed)
        2) ssc_object: A processed conda SolverStateContainer object. 

        Returns:
        +++++++
        1) The updated ssc object based off the sat bypass and package filtering. 

        """

        ## From Solver.run_sat
        specs_map_set = set(itervalues(ssc_object.specs_map))

        ## Get the specs from ssc filtered by the package name
        new_odict = odict(
            [(p_name, ssc_object.specs_map[p_name]) for p_name in package_names]
        )
        final_environment_specs = IndexedSet(
            concatv(
                itervalues(new_odict),
                ssc_object.track_features_specs,
                ssc_object.pinned_specs,
            )
        )

        ## Run the resolve process and get info for desired package
        ssc_object.solution_precs = ssc_object.r.solve(tuple(final_environment_specs))

        wanted_indices = []
        for i, info in enumerate(ssc_object.solution_precs):
            for p_name in package_names:
                if p_name in ssc_object.solution_precs[i].namekey:
                    wanted_indices.append(i)

        filtered_ssc_solution_precs = [
            ssc_object.solution_precs[x] for x in wanted_indices
        ]
        ssc_object.solution_precs = filtered_ssc_solution_precs

        ## Add the final environment specs to ssc
        ssc_object.final_environment_specs = final_environment_specs

        return ssc_object

    # -------------------------------------------------------------------------
    # Run install
    # -------------------------------------------------------------------------

    ## Set the context.always_yes to True to bypass user input
    context.always_yes = True

    target_prefix = context.target_prefix if prefix == None else prefix

    # Setup solver object
    # solve = Solver(target_prefix, (conda_channel,u'default'), context.subdirs, [pkg_name])
    solve = Solver(
        target_prefix, (conda_channel, u"default"), context.subdirs, pkg_names
    )

    ## Create a solver state container
    ### Make sure to Freeze those packages already installed in the current env in order to bypass update checking.
    ssc = SolverStateContainer(
        prefix=target_prefix,
        update_modifier=UpdateModifier.FREEZE_INSTALLED,
        deps_modifier=context.deps_modifier,
        prune=True,
        ignore_pinned=context.ignore_pinned,
        force_remove=context.force_remove,
        should_retry_solve=False,
    )

    ## Get channel metadata
    with Spinner(
        "Collecting package metadata",
        not context.verbosity and not context.quiet,
        context.json,
    ):
        ssc = solve._collect_all_metadata(ssc)

    ## Set specs map to an empty map. (No need to check other specs)
    add_spec = []
    for p_name, spec in iteritems(ssc.specs_map):
        for pkg_name in pkg_names:
            if str(p_name) in pkg_name:
                add_spec.append((pkg_name, MatchSpec(pkg_name)))

    ssc.specs_map = odict(add_spec)

    ## Process the data in the solver state container
    with Spinner(
        "Processing data", not context.verbosity and not context.quiet, context.json
    ):
        ssc = solve._add_specs(ssc)
        ssc = bypass_sat(pkg_names, ssc)
        ssc = solve._post_sat_handling(ssc)

    ## create an IndexedSet from ssc.solution_precs
    ssc.solution_precs = IndexedSet(PrefixGraph(ssc.solution_precs).graph)

    ## Get linked and unlinked
    unlink_precs, link_precs = diff_for_unlink_link_precs(
        target_prefix, ssc.solution_precs, solve.specs_to_add
    )

    # set unlinked to empty indexed set so we do not unlink/remove any pacakges
    unlink_precs = IndexedSet()

    ## Create a PrefixSetup
    stp = PrefixSetup(
        solve.prefix,
        unlink_precs,
        link_precs,
        solve.specs_to_remove,
        solve.specs_to_add,
        solve.neutered_specs,
    )

    ## Create an UnlinkLinkTransaction with stp
    unlink_link_transaction = UnlinkLinkTransaction(stp)

    # create Namespace
    args = Namespace(
        channel=None,
        cmd="install",
        deps_modifier=context.deps_modifier,
        json=False,
        packages=pkg_names,
    )

    ## Set logger level
    if debug:
        WARN, INFO, DEBUG, TRACE = VERBOSITY_LEVELS
        set_all_logger_level(DEBUG)

    ## Install package
    install.handle_txn(unlink_link_transaction, solve.prefix, args, False)

    ## Retrun True if finished
    return True
Пример #31
0
 def test_invalid_seq_parameter(self):
     data = odict(s1=YamlRawParameter.make_raw_parameters(
         's1', {'channels': 'y_u_no_tuple'}))
     config = SampleConfiguration()._set_raw_data(data)
     with raises(InvalidTypeError):
         config.channels
Пример #32
0
 def test_invalid_map_parameter(self):
     data = odict(s1=YamlRawParameter.make_raw_parameters(
         's1', {'proxy_servers': 'blah'}))
     config = SampleConfiguration()._set_raw_data(data)
     with raises(InvalidTypeError):
         config.proxy_servers
Пример #33
0
def load_from_string_data(*seq):
    return odict((f,
                  YamlRawParameter.make_raw_parameters(
                      f, yaml_round_trip_load(test_yaml_raw[f]))) for f in seq)
Пример #34
0
 def test_invalid_map_parameter(self):
     data = odict(s1=YamlRawParameter.make_raw_parameters('s1', {'proxy_servers': 'blah'}))
     config = SampleConfiguration()._set_raw_data(data)
     with raises(InvalidTypeError):
         config.proxy_servers
Пример #35
0
 def test_invalid_seq_parameter(self):
     data = odict(s1=YamlRawParameter.make_raw_parameters('s1', {'channels': 'y_u_no_tuple'}))
     config = SampleConfiguration()._set_raw_data(data)
     with raises(InvalidTypeError):
         config.channels
Пример #36
0
def load_from_string_data(*seq):
    return odict((f, YamlRawParameter.make_raw_parameters(f, yaml_load(test_yaml_raw[f])))
                 for f in seq)