From 133f9a5ccb3a6a197f40075cb0f677aaa268b70f Mon Sep 17 00:00:00 2001 From: boltgolt Date: Thu, 3 Jan 2019 15:05:53 +0100 Subject: [PATCH] Reverting dlib install change because it did very little to speed up tests This reverts commit 1714579e6e8856a93d78ab71c01789d25ce10564. --- .travis.yml | 4 -- debian/postinst | 131 +++++++++++++++++++++++------------------------- 2 files changed, 63 insertions(+), 72 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6863f86..6f7d486 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,6 @@ language: python python: "3.6" script: - - pip3 install --upgrade pip - - pip3 install dlib - # Build the binary (.deb) - debuild -i -us -uc -b # Install the binary, running the debian scripts in the process @@ -35,4 +32,3 @@ addons: - devscripts - fakeroot - pamtester - - python3-pip diff --git a/debian/postinst b/debian/postinst index 7843543..31066b2 100755 --- a/debian/postinst +++ b/debian/postinst @@ -104,48 +104,44 @@ handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/lib/security/ho log("Downloading dlib") +dlib_archive = "/tmp/v19.16.tar.gz" +loader = which("wget") +LOADER_CMD = None -if "HOWDY_SKIP_DLIB" in os.environ: - print(col(2) + "SKIPPING DLIB INSTALLATION BECAUSE OF HOWDY_SKIP_DLIB FLAG" + col(0)) +# If wget is installed, use that as the downloader +if loader: + LOADER_CMD = [loader, "--tries", "5", "--output-document"] +# Otherwise, fall back on curl else: - dlib_archive = "/tmp/v19.16.tar.gz" - loader = which("wget") - LOADER_CMD = None + loader = which("curl") + LOADER_CMD = [loader, "--retry", "5", "--location", "--output"] - # If wget is installed, use that as the downloader - if loader: - LOADER_CMD = [loader, "--tries", "5", "--output-document"] - # Otherwise, fall back on curl - else: - loader = which("curl") - LOADER_CMD = [loader, "--retry", "5", "--location", "--output"] +# Assemble and execute the download command +cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"] +handleStatus(sc(cmd)) - # Assemble and execute the download command - cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"] - handleStatus(sc(cmd)) +# The folder containing the dlib source +DLIB_DIR = None +# A regex of all files to ignore while unpacking the archive +excludes = re.compile( + "davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|" + "(docs|examples|python_examples)|" + "tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))" +) - # The folder containing the dlib source - DLIB_DIR = None - # A regex of all files to ignore while unpacking the archive - excludes = re.compile( - "davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|" - "(docs|examples|python_examples)|" - "tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))" - ) +# Open the archive +with tarfile.open(dlib_archive) as tf: + for item in tf: + # Set the destenation dir if unset + if not DLIB_DIR: + DLIB_DIR = "/tmp/" + item.name - # Open the archive - with tarfile.open(dlib_archive) as tf: - for item in tf: - # Set the destenation dir if unset - if not DLIB_DIR: - DLIB_DIR = "/tmp/" + item.name + # extract only files sufficient for building + if not excludes.match(item.name): + tf.extract(item, "/tmp") - # extract only files sufficient for building - if not excludes.match(item.name): - tf.extract(item, "/tmp") - - # Delete the downloaded archive - os.unlink(dlib_archive) +# Delete the downloaded archive +os.unlink(dlib_archive) log("Building dlib") @@ -153,47 +149,46 @@ cmd = ["sudo", "python3", "setup.py", "install"] cuda_used = False flags = "" -if "HOWDY_SKIP_DLIB" not in os.environ: - # Get the CPU details - with open("/proc/cpuinfo") as info: - for line in info: - if "flags" in line: - flags = line - break +# Get the CPU details +with open("/proc/cpuinfo") as info: + for line in info: + if "flags" in line: + flags = line + break - # Use the most efficient instruction set the CPU supports - if "avx" in flags: - cmd += ["--yes", "USE_AVX_INSTRUCTIONS"] - elif "sse4" in flags: - cmd += ["--yes", "USE_SSE4_INSTRUCTIONS"] - elif "sse3" in flags: - cmd += ["--yes", "USE_SSE3_INSTRUCTIONS"] - elif "sse2" in flags: - cmd += ["--yes", "USE_SSE2_INSTRUCTIONS"] +# Use the most efficient instruction set the CPU supports +if "avx" in flags: + cmd += ["--yes", "USE_AVX_INSTRUCTIONS"] +elif "sse4" in flags: + cmd += ["--yes", "USE_SSE4_INSTRUCTIONS"] +elif "sse3" in flags: + cmd += ["--yes", "USE_SSE3_INSTRUCTIONS"] +elif "sse2" in flags: + cmd += ["--yes", "USE_SSE2_INSTRUCTIONS"] - # Compile and link dlib - try: - sp = subprocess.Popen(cmd, cwd=DLIB_DIR, stdout=subprocess.PIPE) - except subprocess.CalledProcessError: - print("Error while building dlib") - raise +# Compile and link dlib +try: + sp = subprocess.Popen(cmd, cwd=DLIB_DIR, stdout=subprocess.PIPE) +except subprocess.CalledProcessError: + print("Error while building dlib") + raise - # Go through each line from stdout - while sp.poll() is None: - line = sp.stdout.readline().decode("utf-8") +# Go through each line from stdout +while sp.poll() is None: + line = sp.stdout.readline().decode("utf-8") - if "DLIB WILL USE CUDA" in line: - cuda_used = True + if "DLIB WILL USE CUDA" in line: + cuda_used = True - print(line, end="") + print(line, end="") - log("Cleaning up dlib") +log("Cleaning up dlib") - # Remove the no longer needed git clone - del sp - rmtree(DLIB_DIR) +# Remove the no longer needed git clone +del sp +rmtree(DLIB_DIR) - print("Temporary dlib files removed") +print("Temporary dlib files removed") log("Installing OpenCV")