Skip to content

Commit

Permalink
Clean up unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
beeankha committed May 28, 2024
1 parent 2f64593 commit b36e934
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions conda_build/index.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import json
import logging
import os
import time
from functools import partial
from os.path import dirname

Expand All @@ -15,7 +13,6 @@

from . import utils
from .utils import (
JSONDecodeError,
get_logger,
)

Expand Down Expand Up @@ -55,8 +52,6 @@ def get_build_index(
global cached_channels
mtime = 0

_channel_data = {}

channel_urls = list(utils.ensure_list(channel_urls))

if not output_folder:
Expand Down Expand Up @@ -129,55 +124,11 @@ def get_build_index(
platform=subdir,
)

expanded_channels = {rec.channel for rec in cached_index}

superchannel = {}
# we need channeldata.json too, as it is a more reliable source of run_exports data
for channel in expanded_channels:
if channel.scheme == "file":
location = channel.location
if utils.on_win:
location = location.lstrip("/")
elif not os.path.isabs(channel.location) and os.path.exists(
os.path.join(os.path.sep, channel.location)
):
location = os.path.join(os.path.sep, channel.location)
channeldata_file = os.path.join(
location, channel.name, "channeldata.json"
)
retry = 0
max_retries = 1
if os.path.isfile(channeldata_file):
while retry < max_retries:
try:
with open(channeldata_file, "r+") as f:
_channel_data[channel.name] = json.load(f)
break
except (OSError, JSONDecodeError):
time.sleep(0.2)
retry += 1
else:
# download channeldata.json for url
if not context.offline:
try:
_channel_data[channel.name] = utils.download_channeldata(
channel.base_url + "/channeldata.json"
)
except CondaHTTPError:
continue
# collapse defaults metachannel back into one superchannel, merging channeldata
if channel.base_url in context.default_channels and _channel_data.get(
channel.name
):
packages = superchannel.get("packages", {})
packages.update(_channel_data[channel.name])
superchannel["packages"] = packages
_channel_data["defaults"] = superchannel
local_index_timestamp = os.path.getmtime(index_file)
local_subdir = subdir
local_output_folder = output_folder
cached_channels = channel_urls
return cached_index, local_index_timestamp, _channel_data
return cached_index, local_index_timestamp, None


def _ensure_valid_channel(local_folder, subdir):
Expand Down

0 comments on commit b36e934

Please sign in to comment.