Reverting dlib install change because it did very little to speed up tests

This reverts commit 1714579e6e.
This commit is contained in:
boltgolt 2019-01-03 15:05:53 +01:00
parent 1714579e6e
commit 133f9a5ccb
No known key found for this signature in database
GPG key ID: BECEC9937E1AAE26
2 changed files with 63 additions and 72 deletions

View file

@ -3,9 +3,6 @@ language: python
python: "3.6" python: "3.6"
script: script:
- pip3 install --upgrade pip
- pip3 install dlib
# Build the binary (.deb) # Build the binary (.deb)
- debuild -i -us -uc -b - debuild -i -us -uc -b
# Install the binary, running the debian scripts in the process # Install the binary, running the debian scripts in the process
@ -35,4 +32,3 @@ addons:
- devscripts - devscripts
- fakeroot - fakeroot
- pamtester - pamtester
- python3-pip

77
debian/postinst vendored
View file

@ -104,37 +104,33 @@ handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/lib/security/ho
log("Downloading dlib") log("Downloading dlib")
dlib_archive = "/tmp/v19.16.tar.gz"
loader = which("wget")
LOADER_CMD = None
if "HOWDY_SKIP_DLIB" in os.environ: # If wget is installed, use that as the downloader
print(col(2) + "SKIPPING DLIB INSTALLATION BECAUSE OF HOWDY_SKIP_DLIB FLAG" + col(0)) if loader:
else:
dlib_archive = "/tmp/v19.16.tar.gz"
loader = which("wget")
LOADER_CMD = None
# If wget is installed, use that as the downloader
if loader:
LOADER_CMD = [loader, "--tries", "5", "--output-document"] LOADER_CMD = [loader, "--tries", "5", "--output-document"]
# Otherwise, fall back on curl # Otherwise, fall back on curl
else: else:
loader = which("curl") loader = which("curl")
LOADER_CMD = [loader, "--retry", "5", "--location", "--output"] LOADER_CMD = [loader, "--retry", "5", "--location", "--output"]
# Assemble and execute the download command # Assemble and execute the download command
cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"] cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"]
handleStatus(sc(cmd)) handleStatus(sc(cmd))
# The folder containing the dlib source # The folder containing the dlib source
DLIB_DIR = None DLIB_DIR = None
# A regex of all files to ignore while unpacking the archive # A regex of all files to ignore while unpacking the archive
excludes = re.compile( excludes = re.compile(
"davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|" "davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|"
"(docs|examples|python_examples)|" "(docs|examples|python_examples)|"
"tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))" "tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))"
) )
# Open the archive # Open the archive
with tarfile.open(dlib_archive) as tf: with tarfile.open(dlib_archive) as tf:
for item in tf: for item in tf:
# Set the destenation dir if unset # Set the destenation dir if unset
if not DLIB_DIR: if not DLIB_DIR:
@ -144,8 +140,8 @@ else:
if not excludes.match(item.name): if not excludes.match(item.name):
tf.extract(item, "/tmp") tf.extract(item, "/tmp")
# Delete the downloaded archive # Delete the downloaded archive
os.unlink(dlib_archive) os.unlink(dlib_archive)
log("Building dlib") log("Building dlib")
@ -153,33 +149,32 @@ cmd = ["sudo", "python3", "setup.py", "install"]
cuda_used = False cuda_used = False
flags = "" flags = ""
if "HOWDY_SKIP_DLIB" not in os.environ: # Get the CPU details
# Get the CPU details with open("/proc/cpuinfo") as info:
with open("/proc/cpuinfo") as info:
for line in info: for line in info:
if "flags" in line: if "flags" in line:
flags = line flags = line
break break
# Use the most efficient instruction set the CPU supports # Use the most efficient instruction set the CPU supports
if "avx" in flags: if "avx" in flags:
cmd += ["--yes", "USE_AVX_INSTRUCTIONS"] cmd += ["--yes", "USE_AVX_INSTRUCTIONS"]
elif "sse4" in flags: elif "sse4" in flags:
cmd += ["--yes", "USE_SSE4_INSTRUCTIONS"] cmd += ["--yes", "USE_SSE4_INSTRUCTIONS"]
elif "sse3" in flags: elif "sse3" in flags:
cmd += ["--yes", "USE_SSE3_INSTRUCTIONS"] cmd += ["--yes", "USE_SSE3_INSTRUCTIONS"]
elif "sse2" in flags: elif "sse2" in flags:
cmd += ["--yes", "USE_SSE2_INSTRUCTIONS"] cmd += ["--yes", "USE_SSE2_INSTRUCTIONS"]
# Compile and link dlib # Compile and link dlib
try: try:
sp = subprocess.Popen(cmd, cwd=DLIB_DIR, stdout=subprocess.PIPE) sp = subprocess.Popen(cmd, cwd=DLIB_DIR, stdout=subprocess.PIPE)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Error while building dlib") print("Error while building dlib")
raise raise
# Go through each line from stdout # Go through each line from stdout
while sp.poll() is None: while sp.poll() is None:
line = sp.stdout.readline().decode("utf-8") line = sp.stdout.readline().decode("utf-8")
if "DLIB WILL USE CUDA" in line: if "DLIB WILL USE CUDA" in line:
@ -187,13 +182,13 @@ if "HOWDY_SKIP_DLIB" not in os.environ:
print(line, end="") print(line, end="")
log("Cleaning up dlib") log("Cleaning up dlib")
# Remove the no longer needed git clone # Remove the no longer needed git clone
del sp del sp
rmtree(DLIB_DIR) rmtree(DLIB_DIR)
print("Temporary dlib files removed") print("Temporary dlib files removed")
log("Installing OpenCV") log("Installing OpenCV")