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_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_dist_get_paths(): content = 'foo/bar,sha256=1,"45"\nfoo/spam,,\n' temp_path, fpaths = _create_test_files((('', 'SOURCES.txt', content), )) sp_dir = get_python_site_packages_short_path("2.7") dist = PythonEggInfoDistribution(temp_path, "2.7", None) output = dist.get_paths() expected_output = [(join_url(sp_dir, "foo", "bar"), '1', 45), (join_url(sp_dir, "foo", "spam"), None, None)] _print_output(output, expected_output) assert output == expected_output
def test_bare_channel(self): url = "http://conda-01" channel = Channel(url) assert channel.scheme == "http" assert channel.location == "conda-01" assert channel.platform is None assert channel.canonical_name == url assert channel.name is None assert channel.base_url == url assert channel.url() == join_url(url, context.subdir) assert channel.urls() == [ join_url(url, context.subdir), join_url(url, 'noarch'), ]
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 to_package_record_from_subjson(entry, pkg, jsn_string): channel_url = entry["url"] info = json.loads(jsn_string) info["fn"] = pkg info["channel"] = to_conda_channel(entry["channel"], entry["platform"]) info["url"] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
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 to_package_record_from_subjson(subdir, pkg, jsn_string): channel = subdir.channel channel_url = subdir.url_w_credentials info = json.loads(jsn_string) info['fn'] = pkg info['channel'] = channel info['url'] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
def to_package_record_from_subjson(channel, pkg, jsn_string): channel = channel channel_url = channel.url(with_credentials=True) info = json.loads(jsn_string) info["fn"] = pkg info["channel"] = channel info["url"] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
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_channel(self): d = Dist.from_string("conda-forge::spyder-app-2.3.8-py27_0.tar.bz2") assert d.channel == 'conda-forge' assert d.quad[0] == "spyder-app" assert d.dist_name == "spyder-app-2.3.8-py27_0" d = Dist.from_string("s3://some/bucket/name::spyder-app-2.3.8-py27_0.tar.bz2") assert d.channel == 's3://some/bucket/name' assert d.quad[0] == "spyder-app" assert d.dist_name == "spyder-app-2.3.8-py27_0" assert d.to_url() == join_url("s3://some/bucket/name", context.subdir, "spyder-app-2.3.8-py27_0.tar.bz2")
def test_channel(fmt): d = Dist.from_string("conda-forge::spyder-app-2.3.8-py27_0{}".format(fmt)) assert d.channel == 'conda-forge' assert d.quad[0] == "spyder-app" assert d.dist_name == "spyder-app-2.3.8-py27_0" assert d.fmt == fmt d = Dist.from_string("s3://some/bucket/name::spyder-app-2.3.8-py27_0{}".format(fmt)) assert d.channel == 's3://some/bucket/name' assert d.quad[0] == "spyder-app" assert d.dist_name == "spyder-app-2.3.8-py27_0" assert d.to_url() == join_url("s3://some/bucket/name", context.subdir, "spyder-app-2.3.8-py27_0{}".format(fmt))
def _channel_urls(channels=None): for channel in channels or DEFAULT_CHANNELS_UNIX: channel = Channel(channel) for subdir in subdirs: yield join_url(channel.base_url, subdir)
def _channel_urls(channels=None): for channel in channels or DEFAULT_CHANNELS: channel = Channel(channel) for subdir in subdirs: yield join_url(channel.base_url, subdir)
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_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