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

Remove use of Environment Python #904

Open
wants to merge 5 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
2 changes: 1 addition & 1 deletion howdy-gtk/bin/howdy-gtk.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

env python3 "@script_path@" "$@"
@python_path@ "@script_path@" "$@"
2 changes: 1 addition & 1 deletion howdy-gtk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface_files = files(
install_data(interface_files, install_dir: datadir)

cli_path = join_paths(pysourcesinstalldir, 'init.py')
conf_data = configuration_data({ 'script_path': cli_path })
conf_data = configuration_data({ 'script_path': cli_path, 'python_path': py.full_path() })

bin_name = 'howdy-gtk'
bin = configure_file(
Expand Down
1 change: 0 additions & 1 deletion howdy-gtk/src/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Opens auth ui if requested, otherwise starts normal ui
import sys

Expand Down
2 changes: 1 addition & 1 deletion howdy/src/bin/howdy.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

env python3 "@script_path@" "$@"
@python_path@ "@script_path@" "$@"
1 change: 0 additions & 1 deletion howdy/src/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# CLI directly called by running the howdy command

# Import required modules
Expand Down
1 change: 0 additions & 1 deletion howdy/src/compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Compare incoming video with known faces
# Running in a local python instance to get around PATH issues

Expand Down
7 changes: 4 additions & 3 deletions howdy/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ if meson.is_subproject()
project('howdy', 'cpp', license: 'MIT', version: 'beta', meson_version: '>= 0.64.0')
endif

py = import('python').find_installation()
py.dependency()

datadir = get_option('prefix') / get_option('datadir') / 'howdy'
py_conf = configuration_data(paths_dict)
py_conf.set('data_dir', datadir)

py = import('python').find_installation(paths_dict.get('python_path'))
Copy link
Collaborator

@saidsay-so saidsay-so Aug 11, 2024

Choose a reason for hiding this comment

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

Not sure about this, python_path could be another path that the packager would like to set?

py.dependency()

py_paths = configure_file(
input: 'paths.py.in',
output: 'paths.py',
Expand Down Expand Up @@ -153,7 +154,7 @@ install_man('../howdy.1')
# endif

cli_path = join_paths(pysourcesinstalldir, 'cli.py')
conf_data = configuration_data({ 'script_path': cli_path })
conf_data = configuration_data({ 'script_path': cli_path, 'python_path': py.full_path() })

bin_name = 'howdy'
bin = configure_file(
Expand Down
5 changes: 2 additions & 3 deletions howdy/src/pam/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
const auto DEFAULT_TIMEOUT =
std::chrono::duration<int, std::chrono::milliseconds::period>(100);
const auto MAX_RETRIES = 5;
const auto PYTHON_EXECUTABLE = "python3";

#define S(msg) gettext(msg)

Expand Down Expand Up @@ -268,12 +267,12 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv,
}
}

const char *const args[] = {PYTHON_EXECUTABLE, // NOLINT
const char *const args[] = {PYTHON_EXECUTABLE_PATH, // NOLINT
COMPARE_PROCESS_PATH, username, nullptr};
pid_t child_pid;

// Start the python subprocess
if (posix_spawnp(&child_pid, PYTHON_EXECUTABLE, nullptr, nullptr,
if (posix_spawnp(&child_pid, PYTHON_EXECUTABLE_PATH, nullptr, nullptr,
const_cast<char *const *>(args), nullptr) != 0) {
syslog(LOG_ERR, "Can't spawn the howdy process: %s (%d)", strerror(errno),
errno);
Expand Down
3 changes: 2 additions & 1 deletion howdy/src/pam/paths.hh.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const auto COMPARE_PROCESS_PATH = "@compare_script_path@";
const auto CONFIG_FILE_PATH = "@config_file_path@";
const auto USER_MODELS_DIR = "@user_models_dir@";
const auto USER_MODELS_DIR = "@user_models_dir@";
const auto PYTHON_EXECUTABLE_PATH = "@python_path@";
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dlibdatadir = get_option('dlib_data_dir') != '' ? get_option('dlib_data_dir') :
confdir = get_option('config_dir') != '' ? get_option('config_dir') : join_paths(get_option('prefix'), get_option('sysconfdir'), 'howdy')
usermodelsdir = get_option('user_models_dir') != '' ? get_option('user_models_dir') : join_paths(confdir, 'models')
logpath = get_option('log_path')
pythonpath = get_option('python_path')

config_path = join_paths(confdir, 'config.ini')

Expand All @@ -12,6 +13,7 @@ paths_dict = {
'dlib_data_dir': dlibdatadir,
'user_models_dir': usermodelsdir,
'log_path': logpath,
'python_path': pythonpath
}

# We need to keep this order beause howdy-gtk defines the gtk script path which is used later in howdy
Expand Down
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ option('user_models_dir', type: 'string', value: '', description: 'Set the user
option('log_path', type: 'string', value: '/var/log/howdy', description: 'Set the log file path')
option('install_in_site_packages', type: 'boolean', value: false, description: 'Install howdy python files in site packages')
option('py_sources_dir', type: 'string', value: '', description: 'Set the python sources directory')
option('python_path', type: 'string', value: '/usr/bin/python', description: 'Set the path to the python executable')
option('install_pam_config', type: 'boolean', value: false, description: 'Install pam config file (for Debian/Ubuntu)')