Skip to content

Commit

Permalink
Build script: Don't use wget or curl, just urlretrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Jun 30, 2019
1 parent c29cc87 commit 51cf52c
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions nix/build-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,9 @@ def v(dep):
raise ValueError("Required tool '%s' not installed or not added to PATH" % (cmd,))

# identifiers for the download tool (could be less memory consuming as ints, but are more verbose as strings)
download_tool_curl="curl"
download_tool_wget="wget"
download_tool_default = download_tool_py = "py"
download_tool_git = "git"

if which(wget) != None:
download_tool_default = download_tool_wget
elif which(curl) != None:
download_tool_default = download_tool_curl
else:
raise ValueError("No download application found, tried: curl, wget")

CURL = ["curl", "-sL"]
WGET= ["wget", "-q", "--no-check-certificate"]

# Create log directory and file

log_dir = os.path.join(DEPS_DIR, "logs")
Expand Down Expand Up @@ -362,25 +351,18 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
build_dir = os.path.join(DEPS_DIR, "build")
if not os.path.exists(build_dir):
os.makedirs(build_dir)

logger.info("\rFetching %s... " % (name,))

if download_tool == download_tool_curl or download_tool == download_tool_wget:
if download_tool == download_tool_py:
if no_append_name:
url = download_url
else:
url = os.path.join(download_url, download_name)

if download_tool == download_tool_curl:
download_path = os.path.join(build_dir, download_name)
if not os.path.exists(download_path):
logger.info("\rDownloading %s... " % (name,))
run(CURL + ["-o", download_name, url], cwd=build_dir)
else:
logger.info("Download '%s' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping" % (download_path,))
elif download_tool == download_tool_wget:

download_path = os.path.join(build_dir, download_name)
if not os.path.exists(download_path):
logger.info("\rDownloading %s... " % (name,))
run(WGET + ["-O", download_name, url], cwd=build_dir)
urlretrieve(url, os.path.join(build_dir, download_path))
else:
logger.info("Download '%s' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping" % (download_path,))
elif download_tool == download_tool_git:
Expand Down

0 comments on commit 51cf52c

Please sign in to comment.