Commit 82c5897d authored by André Anjos's avatar André Anjos 💬
Browse files

[scripts/mirror] Use own self-destructing temporary directory

parent 3f197507
Pipeline #34660 passed with stages
in 5 minutes and 55 seconds
......@@ -4,6 +4,7 @@
import os
import click
import tempfile
import conda_build.api
......@@ -64,6 +65,13 @@ Examples:
"(combine with the verbosity flags - e.g. ``-vvv``) to enable "
"printing to help you understand what will be done",
type=click.Path(exists=True, dir_okay=True, file_okay=False,
readable=True, writable=True, resolve_path=True),
help="A directory where to store temporary files",
def mirror(
......@@ -72,6 +80,7 @@ def mirror(
"""Mirrors a conda channel to a particular local destination
......@@ -82,12 +91,17 @@ def mirror(
available on the channel, and only downloading the missing files.
# creates a self destructing temporary directory that will act as temporary
# directory for the rest of this program
tmpdir2 = tempfile.TemporaryDirectory(prefix='bdt-mirror-tmp', dir=tmpdir)
os.environ['TMPDIR'] ='Setting $TMPDIR to %s',
# if we are in a dry-run mode, let's let it be known
if dry_run:
logger.warn("!!!! DRY RUN MODE !!!!")
logger.warn("Nothing will be really mirrored")
DEFAULT_SUBDIRS = ['noarch', 'linux-64', 'osx-64']
noarch = os.path.join(dest_dir, 'noarch')
......@@ -96,8 +110,7 @@ def mirror("Creating conda channel at %s...", dest_dir)
if not dry_run:
conda_build.api.update_index([dest_dir], subdir=DEFAULT_SUBDIRS,
progress=False, verbose=False)
for arch in DEFAULT_SUBDIRS:
......@@ -147,5 +160,7 @@ def mirror(
# re-indexes the channel to produce a conda-compatible setup
echo_info("Re-indexing %s..." % dest_dir)
if not dry_run:
from conda_build.index import MAX_THREADS_DEFAULT
conda_build.api.update_index([dest_dir], check_md5=check_md5,
progress=True, verbose=False, subdir=DEFAULT_SUBDIRS,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment