Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
returncode = 1
Toolbox.set_git_repository_config_to_rebase(
os.path.join(destination, ".git", "config")
)
if returncode:
return returncode # no point trying to continue on error
# Show the hash for the checked out commit for debugging purposes, ignore any failures.
ShellCommand(
command=["git", "rev-parse", "HEAD"], workdir=destination
).run()
return returncode
filename = "%s-%s" % (module, urlparse(source_candidate)[2].split("/")[-1])
filename = os.path.join(destpath, filename)
if verbose:
print("===== Downloading %s: " % source_candidate, end=" ")
Toolbox.download_to_file(source_candidate, filename)
Toolbox.unzip(filename, destination, trim_directory=1, verbose=verbose)
return
error = (
"Cannot satisfy git dependency for module %s: None of the sources are available."
% module
)
if not git_available:
print(error)
error = "A git installation has not been found."
raise Exception(error)
"""Download and install Miniconda3"""
os_names = {"Darwin": "MacOSX", "Linux": "Linux", "Windows": "Windows"}
filename = "Miniconda3-latest-{platform}-x86_64".format(
platform=os_names[self.system]
)
if self.system == "Windows":
filename += ".exe"
else:
filename += ".sh"
url_base = "https://repo.anaconda.com/miniconda/"
url = url_base + filename
filename = os.path.join(location, filename)
print("Downloading {url}:".format(url=url), end=" ")
result = Toolbox.download_to_file(url, filename)
if result in (0, -1):
sys.exit("Miniconda download failed")
# run the installer
if self.system == "Windows":
command = [
filename,
"/InstallationType=JustMe",
"/RegisterPython=0",
"/AddToPath=0",
"/S",
"/D=" + location,
]
else:
command = ["/bin/sh", filename, "-b", "-u", "-p", location]
def _download():
for _url in url:
for retry in (3, 3, 0):
print("===== Downloading %s: " % _url, end=" ")
try:
Toolbox().download_to_file(_url, to_file)
return
except Exception as e:
print("Download failed with", e)
if retry:
print("Retrying in %d seconds" % retry)
time.sleep(retry)
raise RuntimeError("Could not download " + to_file)
print(
"Completed {text}:\n {prefix}".format(text=text_messages[1], prefix=prefix)
)
with open(os.path.join(prefix, ".condarc"), "w") as fh:
fh.write(
"""
channels:
- conda-forge
"""
)
# on Windows, also download the Visual C++ 2008 Redistributable
# use the same version as conda-forge
# https://github.com/conda-forge/vs2008_runtime-feedstock
if self.system == "Windows":
Toolbox.download_to_file(
"https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe",
os.path.join(prefix, "vcredist_x64.exe"),
)
# check that environment file is updated
self.environments = self.update_environments()
if prefix not in self.environments:
raise RuntimeError(
"""
The newly installed environment cannot be found in