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

131
debian/postinst vendored
View file

@ -104,48 +104,44 @@ 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:
LOADER_CMD = [loader, "--tries", "5", "--output-document"]
# Otherwise, fall back on curl
else: else:
dlib_archive = "/tmp/v19.16.tar.gz" loader = which("curl")
loader = which("wget") LOADER_CMD = [loader, "--retry", "5", "--location", "--output"]
LOADER_CMD = None
# If wget is installed, use that as the downloader # Assemble and execute the download command
if loader: cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"]
LOADER_CMD = [loader, "--tries", "5", "--output-document"] handleStatus(sc(cmd))
# Otherwise, fall back on curl
else:
loader = which("curl")
LOADER_CMD = [loader, "--retry", "5", "--location", "--output"]
# Assemble and execute the download command # The folder containing the dlib source
cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"] DLIB_DIR = None
handleStatus(sc(cmd)) # 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 # Open the archive
DLIB_DIR = None with tarfile.open(dlib_archive) as tf:
# A regex of all files to ignore while unpacking the archive for item in tf:
excludes = re.compile( # Set the destenation dir if unset
"davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|" if not DLIB_DIR:
"(docs|examples|python_examples)|" DLIB_DIR = "/tmp/" + item.name
"tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))"
)
# Open the archive # extract only files sufficient for building
with tarfile.open(dlib_archive) as tf: if not excludes.match(item.name):
for item in tf: tf.extract(item, "/tmp")
# Set the destenation dir if unset
if not DLIB_DIR:
DLIB_DIR = "/tmp/" + item.name
# extract only files sufficient for building # Delete the downloaded archive
if not excludes.match(item.name): os.unlink(dlib_archive)
tf.extract(item, "/tmp")
# Delete the downloaded archive
os.unlink(dlib_archive)
log("Building dlib") log("Building dlib")
@ -153,47 +149,46 @@ 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:
cuda_used = True cuda_used = True
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")