Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: provide a seperate python3-dlib dependency package on debian #814

Open
wants to merge 4 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions howdy/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Vcs-Git: https://github.com/boltgolt/howdy
Package: howdy
Homepage: https://github.com/boltgolt/howdy
Architecture: amd64
Depends: ${misc:Depends}, libc6, libgcc-s1, libpam0g, libstdc++6, curl | wget, python3, python3-pip, python3-dev, python3-setuptools, python3-numpy, python-opencv | python3-opencv, libopencv-dev, cmake, libinih-dev
PreDepends: python3:any | python3-minimal:any
Depends: ${misc:Depends}, libc6, libgcc-s1, libpam0g, libstdc++6, curl | wget, python3, python3-pip, python3-dev, python3-setuptools, python3-numpy, python-opencv | python3-opencv, libopencv-dev, cmake, libinih-dev, python3-dlib
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that python3-dlib was not used because it crashed a LOT for a ton of people in the early days. Is it stable now?

Recommends: libatlas-base-dev | libopenblas-dev | liblapack-dev, howdy-gtk
Suggests: nvidia-cuda-dev (>= 7.5)
Description: Howdy: Windows Hello style authentication for Linux.
Use your built-in IR emitters and camera in combination with face recognition
to prove who you are.
1 change: 0 additions & 1 deletion howdy/debian/install
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
src/cli/. lib/security/howdy/cli
src/locales/. lib/security/howdy/locales
src/recorders/. lib/security/howdy/recorders
src/rubberstamps/. lib/security/howdy/rubberstamps
src/cli.py lib/security/howdy
Expand Down
79 changes: 2 additions & 77 deletions howdy/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -106,83 +106,6 @@ if "upgrade" in sys.argv:

sys.exit(0)

log("Downloading dlib")

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"]
# 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))

# 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

# extract only files sufficient for building
if not excludes.match(item.name):
tf.extract(item, "/tmp")

# Delete the downloaded archive
os.unlink(dlib_archive)

log("Building dlib")

cmd = ["sudo", "python3", "setup.py", "install"]
cuda_used = False

# 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")

if "DLIB WILL USE CUDA" in line:
cuda_used = True

print(line, end="")

log("Cleaning up dlib")

# Remove the no longer needed git clone
del sp
rmtree(DLIB_DIR)

print("Temporary dlib files removed")

log("Configuring howdy")

# Manually change the camera id to the one picked
for line in fileinput.input(["/etc/howdy/config.ini"], inplace=1):
line = line.replace("use_cnn = false", "use_cnn = " + str(cuda_used).lower())
print(line, end="")

Comment on lines -179 to -185
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these lines?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CNN depends on CUDA, and nvidia-cuda-dev is only a suggested package i guess. Could negatively impact performance by not enabling it automatically like this

print("Camera ID saved")

# Secure the howdy folder
Expand All @@ -196,6 +119,8 @@ handleStatus(sc(["chmod 755 -R /lib/security/howdy/cli"], shell=True))
print("Permissions set")

# Make the CLI executable as howdy
if os.path.exists("/usr/local/bin/howdy"):
os.unlink("/usr/local/bin/howdy")
os.symlink("/lib/security/howdy/cli.py", "/usr/local/bin/howdy")
os.chmod("/usr/local/bin/howdy", 0o755)
print("Howdy command installed")
Expand Down
1 change: 1 addition & 0 deletions howdy/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Used to check cameras before committing to install
# Executed before primary apt install of files

import os
import subprocess
import sys

Expand Down
3 changes: 0 additions & 3 deletions howdy/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,3 @@ try:
except Exception:
# This error is normal
pass

# Remove dlib
subprocess.call(["pip3", "uninstall", "dlib", "-y", "--no-cache-dir"])