Пример #1
0
 def test_prefix_record_no_channel(self):
     pr = PrefixRecord(
         name='austin',
         version='1.2.3',
         build_string='py34_2',
         build_number=2,
         url="https://repo.continuum.io/pkgs/free/win-32/austin-1.2.3-py34_2.tar.bz2",
         subdir="win-32",
         md5='0123456789',
         files=(),
     )
     assert pr.url == "https://repo.continuum.io/pkgs/free/win-32/austin-1.2.3-py34_2.tar.bz2"
     assert pr.channel.canonical_name == 'defaults'
     assert pr.subdir == "win-32"
     assert pr.fn == "austin-1.2.3-py34_2.tar.bz2"
     channel_str = text_type(Channel("https://repo.continuum.io/pkgs/free/win-32/austin-1.2.3-py34_2.tar.bz2"))
     assert channel_str == "https://repo.continuum.io/pkgs/free"
     assert dict(pr.dump()) == dict(
         name='austin',
         version='1.2.3',
         build='py34_2',
         build_number=2,
         url="https://repo.continuum.io/pkgs/free/win-32/austin-1.2.3-py34_2.tar.bz2",
         md5='0123456789',
         files=(),
         channel=channel_str,
         subdir="win-32",
         fn="austin-1.2.3-py34_2.tar.bz2",
         constrains=(),
         depends=(),
     )
Пример #2
0
def register_dist(dist_name, target_prefix):
    """ register a distribution with conda. """

    # build path to site-packages directory
    get_python_version = UnlinkLinkTransaction.get_python_version
    python_ver = get_python_version(target_prefix, [], [])
    sp_short_path = get_python_site_packages_short_path(python_ver)
    sp_full_path = os.path.join(target_prefix, sp_short_path)

    # find package details using distlib
    dist_path = DistributionPath([
        sp_full_path,
    ], include_egg=True)
    dist = dist_path.get_distribution(dist_name)

    # create a conda PrefixRecord
    files = [
        os.path.join(sp_short_path, file_path)
        for file_path, file_hash, file_size in dist.list_installed_files()
    ]
    prefix_record = PrefixRecord.from_objects(
        name=dist.name,
        version=dist.version,
        files=files,
        build=DEFAULT_BUILD_STR,
        build_number=DEFAULT_BUILD_NUMBER,
    )
    # TODO: conda currently checks that prefix_record.fn ends with .tar.bz2.
    # This check should be supressed for prefix record entries which are not
    # derived from tarballs so that prefix_record.fn can be set to None.
    prefix_record.fn = prefix_record.fn + '.tar.bz2'

    print("creating linked package record for %s." % dist_name)
    PrefixData(target_prefix).insert(prefix_record)