def test_dist_with_non_channel_url(self): # contrived url url = "https://repo.anaconda.com/pkgs/anaconda/cffi-1.9.1-py34_0.tar.bz2" d = Dist(url) assert d.channel == '<unknown>' assert d.name == 'cffi' assert d.version == '1.9.1' assert d.build_string == 'py34_0' assert d.to_url() == url assert d.is_channel is False # file url that is not a channel url = path_to_url(join_url(context.croot, 'cffi-1.9.1-py34_0.tar.bz2')) d = Dist(url) assert d.channel == '<unknown>' assert d.name == 'cffi' assert d.version == '1.9.1' assert d.build_string == 'py34_0' assert d.to_url() == url assert d.is_channel is False # file url that is a package cache # TODO: maybe this should look up the channel in urls.txt? or maybe that's too coupled? url = join_url(path_to_url(context.pkgs_dirs[0]), 'cffi-1.9.1-py34_0.tar.bz2') d = Dist(url) assert d.channel == '<unknown>' assert d.name == 'cffi' assert d.version == '1.9.1' assert d.build_string == 'py34_0' assert d.to_url() == url assert d.is_channel is False
def test_install_tarball_from_local_channel(self): with make_temp_env("flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [ p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask' ][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(context.pkgs_dirs[0], flask_fname) # Regression test for #2812 # install from local channel flask_data = flask_data.dump() for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = { 'info': {}, 'packages': { flask_fname: IndexRecord(**flask_data) } } with make_temp_env() as channel: subchan = join(channel, context.subdir) noarch_dir = join(channel, 'noarch') channel = path_to_url(channel) os.makedirs(subchan) os.makedirs(noarch_dir) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write( json.dumps(repodata, cls=EntityEncoder).encode('utf-8')) with bz2.BZ2File(join(noarch_dir, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps({}, cls=EntityEncoder).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask', '--json') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(sys.prefix, 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) if not isdir(conda_bld_sub): os.makedirs(conda_bld_sub) tar_bld_path = join(conda_bld_sub, flask_fname) copyfile(tar_new_path, tar_bld_path) # CondaFileNotFoundError: '/home/travis/virtualenv/python2.7.9/conda-bld/linux-64/flask-0.10.1-py27_2.tar.bz2'. run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-')
def test_conda_bld_path_2(self): saved_envs_path = os.environ.get('CONDA_BLD_PATH') beginning = "C:" + os.sep if on_win else os.sep path = beginning + os.sep.join(['random', 'directory']) url = path_to_url(path) try: os.environ['CONDA_BLD_PATH'] = path reset_context() 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 assert channel.urls() == [ join_url(url, context.subdir), join_url(url, 'noarch'), ] channel = Channel(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(url, context.subdir), join_url(url, 'noarch'), ] assert channel.url() == join_url(url, context.subdir) assert channel.channel_name == basename(path) assert channel.channel_location == path_to_url( dirname(path)).replace('file://', '', 1) assert channel.canonical_name == "local" finally: if saved_envs_path: os.environ['CONDA_BLD_PATH'] = saved_envs_path else: del os.environ['CONDA_BLD_PATH']
def test_conda_bld_path_1(self): saved_envs_path = os.environ.get('CONDA_BLD_PATH') beginning = "C:" + os.sep if on_win else os.sep path = beginning + os.sep.join(['tmp', 'conda-bld']) url = path_to_url(path) try: os.environ['CONDA_BLD_PATH'] = path reset_context() 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 assert channel.urls() == [ join_url(url, context.subdir), join_url(url, 'noarch'), ] channel = Channel(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(url, context.subdir), join_url(url, 'noarch'), ] assert channel.url() == join_url(url, context.subdir) assert channel.channel_name == basename(path) assert channel.channel_location == path_to_url(dirname(path)).replace('file://', '', 1) assert channel.canonical_name == "local" finally: if saved_envs_path: os.environ['CONDA_BLD_PATH'] = saved_envs_path else: del os.environ['CONDA_BLD_PATH']
def test_dist_with_channel_url(self): # standard named channel url = "https://repo.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # standard url channel url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' # because pkgs/free is in defaults assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # another standard url channel url = "https://not.real.continuum.io/not/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'https://not.real.continuum.io/not/free' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # local file url that is a named channel url = path_to_url( join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')) d = Dist(url) assert d.channel == 'local' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True # local file url that is not a named channel url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2') d = Dist(url) assert d.channel == 'file:///some/location/on/disk' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True
def test_dist_with_channel_url(self): # standard named channel url = "https://repo.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # standard url channel url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' # because pkgs/free is in defaults assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # another standard url channel url = "https://not.real.continuum.io/not/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'https://not.real.continuum.io/not/free' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # local file url that is a named channel url = path_to_url(join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')) d = Dist(url) assert d.channel == 'local' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True # local file url that is not a named channel url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2') d = Dist(url) assert d.channel == 'file:///some/location/on/disk' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True
def test_local_channel(self): local = Channel('local') assert local.canonical_name == "local" build_path = path_to_url(context.local_build_root) local_urls = ['%s/%s/' % (build_path, context.subdir), '%s/noarch/' % build_path] assert local.urls == local_urls lc = Channel(build_path) assert lc.canonical_name == "local" assert lc.urls == local_urls lc_noarch = Channel(local_urls[1]) assert lc_noarch.canonical_name == "local" assert lc_noarch.urls == local_urls[1:]
def test_local_file_adapter_200(self): test_path = None try: with NamedTemporaryFile(delete=False) as fh: test_path = fh.name fh.write(ensure_binary('{"content": "file content"}')) test_url = path_to_url(test_path) session = CondaSession() r = session.get(test_url) r.raise_for_status() assert r.status_code == 200 assert r.json()['content'] == "file content" finally: if test_path is not None: rm_rf(test_path)
def test_install_tarball_from_local_channel(self): with make_temp_env("flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(PackageCache.first_writable().pkgs_dir, flask_fname) # Regression test for #2812 # install from local channel flask_data = flask_data.dump() for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = {'info': {}, 'packages': {flask_fname: IndexRecord(**flask_data)}} with make_temp_env() as channel: subchan = join(channel, context.subdir) noarch_dir = join(channel, 'noarch') channel = path_to_url(channel) os.makedirs(subchan) os.makedirs(noarch_dir) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps(repodata, cls=EntityEncoder).encode('utf-8')) with bz2.BZ2File(join(noarch_dir, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps({}, cls=EntityEncoder).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask', '--json') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(dirname(PackageCache.first_writable().pkgs_dir), 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) if not isdir(conda_bld_sub): os.makedirs(conda_bld_sub) tar_bld_path = join(conda_bld_sub, flask_fname) copyfile(tar_new_path, tar_bld_path) # CondaFileNotFoundError: '/home/travis/virtualenv/python2.7.9/conda-bld/linux-64/flask-0.10.1-py27_2.tar.bz2'. run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-')
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)
def test_install_tarball_from_local_channel(self): with make_temp_env("python flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(context.pkgs_dirs[0], flask_fname) # Regression test for #2812 # install from local channel for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = {'info': {}, 'packages': {flask_fname: flask_data}} with make_temp_env() as channel: subchan = join(channel, context.subdir) channel = path_to_url(channel) os.makedirs(subchan) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps(repodata, cls=EntityEncoder).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(sys.prefix, 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) tar_bld_path = join(conda_bld_sub, flask_fname) if os.path.exists(conda_bld): try: os.rename(tar_new_path, tar_bld_path) except OSError: pass else: os.makedirs(conda_bld) os.rename(subchan, conda_bld_sub) run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-')
def make_temp_channel(packages): package_reqs = [pkg.replace("-", "=") for pkg in packages] package_names = [pkg.split("-")[0] for pkg in packages] with make_temp_env(*package_reqs) as prefix: for package in packages: assert package_is_installed(prefix, package.replace("-", "=")) data = [ p for p in PrefixData(prefix).iter_records() if p["name"] in package_names ] run_command(Commands.REMOVE, prefix, *package_names) for package in packages: assert not package_is_installed(prefix, package.replace("-", "=")) repodata = {"info": {}, "packages": {}} tarfiles = {} for package_data in data: pkg_data = package_data fname = pkg_data["fn"] tarfiles[fname] = join(PackageCacheData.first_writable().pkgs_dir, fname) pkg_data = pkg_data.dump() for field in ("url", "channel", "schannel"): pkg_data.pop(field, None) repodata["packages"][fname] = PackageRecord(**pkg_data) with make_temp_env() as channel: subchan = join(channel, context.subdir) noarch_dir = join(channel, "noarch") channel = path_to_url(channel) os.makedirs(subchan) os.makedirs(noarch_dir) for fname, tar_old_path in tarfiles.items(): tar_new_path = join(subchan, fname) copyfile(tar_old_path, tar_new_path) with open(join(subchan, "repodata.json"), "w") as f: f.write(json.dumps(repodata, cls=EntityEncoder)) with open(join(noarch_dir, "repodata.json"), "w") as f: f.write(json.dumps({}, cls=EntityEncoder)) yield channel
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_dist_with_channel_url(self): # standard named channel url = "https://repo.anaconda.com/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # standard url channel url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' # because pkgs/anaconda is in defaults assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # another standard url channel url = "https://not.real.continuum.io/not/anaconda/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'https://not.real.continuum.io/not/anaconda' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # local file url that is a named channel conda_bld_path = join(gettempdir(), 'conda-bld') try: mkdir_p(conda_bld_path) with env_var('CONDA_BLD_PATH', conda_bld_path, reset_context): url = path_to_url( join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')) d = Dist(url) assert d.channel == 'local' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True finally: rm_rf(conda_bld_path) # local file url that is not a named channel url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2') d = Dist(url) assert d.channel == 'file:///some/location/on/disk' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True
def test_tarball_install_and_bad_metadata(self): with make_temp_env("python flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(context.pkgs_dirs[0], flask_fname) # regression test for #2886 (part 1 of 2) # install tarball from package cache, default channel run_command(Commands.INSTALL, prefix, tar_old_path) assert_package_is_installed(prefix, 'flask-0.') # regression test for #2626 # install tarball with full path, outside channel tar_new_path = join(prefix, flask_fname) copyfile(tar_old_path, tar_new_path) run_command(Commands.INSTALL, prefix, tar_new_path) assert_package_is_installed(prefix, 'flask-0') # regression test for #2626 # install tarball with relative path, outside channel run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') tar_new_path = relpath(tar_new_path) run_command(Commands.INSTALL, prefix, tar_new_path) assert_package_is_installed(prefix, 'flask-0.') # Regression test for 2812 # install from local channel for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = {'info': {}, 'packages': {flask_fname: flask_data}} with make_temp_env() as channel: subchan = join(channel, context.subdir) channel = path_to_url(channel) os.makedirs(subchan) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps(repodata).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(sys.prefix, 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) tar_bld_path = join(conda_bld_sub, flask_fname) if os.path.exists(conda_bld): try: os.rename(tar_new_path, tar_bld_path) except OSError: pass else: os.makedirs(conda_bld) os.rename(subchan, conda_bld_sub) run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-') # regression test for #2886 (part 2 of 2) # install tarball from package cache, local channel run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') run_command(Commands.INSTALL, prefix, tar_old_path) # The last install was from the `local::` channel assert_package_is_installed(prefix, 'flask-') # regression test for #2599 linked_data_.clear() flask_metadata = glob(join(prefix, 'conda-meta', flask_fname[:-8] + '.json'))[-1] bad_metadata = join(prefix, 'conda-meta', 'flask.json') copyfile(flask_metadata, bad_metadata) assert not package_is_installed(prefix, 'flask', exact=True) assert_package_is_installed(prefix, 'flask-0.')
def test_tarball_install_and_bad_metadata(self): with make_temp_env("python flask=0.10.1") as prefix: assert_package_is_installed(prefix, 'flask-0.10.1') flask_data = [p for p in itervalues(linked_data(prefix)) if p['name'] == 'flask'][0] run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') assert_package_is_installed(prefix, 'python') flask_fname = flask_data['fn'] tar_old_path = join(context.pkgs_dirs[0], flask_fname) # regression test for #2886 (part 1 of 2) # install tarball from package cache, default channel run_command(Commands.INSTALL, prefix, tar_old_path) assert_package_is_installed(prefix, 'flask-0.') # regression test for #2626 # install tarball with full path, outside channel tar_new_path = join(prefix, flask_fname) copyfile(tar_old_path, tar_new_path) run_command(Commands.INSTALL, prefix, tar_new_path) assert_package_is_installed(prefix, 'flask-0') # regression test for #2626 # install tarball with relative path, outside channel run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0.10.1') tar_new_path = relpath(tar_new_path) run_command(Commands.INSTALL, prefix, tar_new_path) assert_package_is_installed(prefix, 'flask-0.') # Regression test for 2812 # install from local channel for field in ('url', 'channel', 'schannel'): del flask_data[field] repodata = {'info': {}, 'packages':{flask_fname: flask_data}} with make_temp_env() as channel: subchan = join(channel, context.subdir) channel = path_to_url(channel) os.makedirs(subchan) tar_new_path = join(subchan, flask_fname) copyfile(tar_old_path, tar_new_path) with bz2.BZ2File(join(subchan, 'repodata.json.bz2'), 'w') as f: f.write(json.dumps(repodata).encode('utf-8')) run_command(Commands.INSTALL, prefix, '-c', channel, 'flask') assert_package_is_installed(prefix, channel + '::' + 'flask-') run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') # Regression test for 2970 # install from build channel as a tarball conda_bld = join(sys.prefix, 'conda-bld') conda_bld_sub = join(conda_bld, context.subdir) tar_bld_path = join(conda_bld_sub, flask_fname) if os.path.exists(conda_bld): try: os.rename(tar_new_path, tar_bld_path) except OSError: pass else: os.makedirs(conda_bld) os.rename(subchan, conda_bld_sub) run_command(Commands.INSTALL, prefix, tar_bld_path) assert_package_is_installed(prefix, 'flask-') # regression test for #2886 (part 2 of 2) # install tarball from package cache, local channel run_command(Commands.REMOVE, prefix, 'flask') assert not package_is_installed(prefix, 'flask-0') run_command(Commands.INSTALL, prefix, tar_old_path) # The last install was from the `local::` channel assert_package_is_installed(prefix, 'flask-') # regression test for #2599 linked_data_.clear() flask_metadata = glob(join(prefix, 'conda-meta', flask_fname[:-8] + '.json'))[-1] bad_metadata = join(prefix, 'conda-meta', 'flask.json') copyfile(flask_metadata, bad_metadata) assert not package_is_installed(prefix, 'flask', exact=True) assert_package_is_installed(prefix, 'flask-0.')
def test_dist_with_channel_url(self): # standard named channel url = "https://repo.anaconda.com/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # standard url channel url = "https://not.real.continuum.io/pkgs/free/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'defaults' # because pkgs/anaconda is in defaults assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # another standard url channel url = "https://not.real.continuum.io/not/anaconda/win-64/spyder-app-2.3.8-py27_0.tar.bz2" d = Dist(url) assert d.channel == 'https://not.real.continuum.io/not/anaconda' assert d.name == 'spyder-app' assert d.version == '2.3.8' assert d.build_string == 'py27_0' assert d.to_url() == url assert d.is_channel is True # local file url that is a named channel conda_bld_path = join(gettempdir(), 'conda-bld') try: mkdir_p(conda_bld_path) with env_var('CONDA_BLD_PATH', conda_bld_path, stack_callback=conda_tests_ctxt_mgmt_def_pol): url = path_to_url(join_url(context.croot, 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2')) d = Dist(url) assert d.channel == 'local' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True finally: rm_rf(conda_bld_path) # local file url that is not a named channel url = join_url('file:///some/location/on/disk', 'osx-64', 'bcrypt-3.1.1-py35_2.tar.bz2') d = Dist(url) assert d.channel == 'file:///some/location/on/disk' assert d.name == 'bcrypt' assert d.version == '3.1.1' assert d.build_string == 'py35_2' assert d.to_url() == url assert d.is_channel is True