ansible / pylibssh

Python bindings specific to Ansible use case for libssh https://www.libssh.org/
https://ansible-pylibssh.rtfd.io
GNU Lesser General Public License v2.1
59 stars 30 forks source link

ansible-pylibssh does not build on OpenBSD 7.3 #499

Closed quistian closed 10 months ago

quistian commented 1 year ago
SUMMARY

I tried to install ansible-pylibssh as part of the aruba AOS CX ansible collection and the compile fails.

ISSUE TYPE
PYLISSH and LIBSSH VERSION
libssh-0.10.4       C library implementing server and client side SSH
libssh2-1.10.0p0    library implementing the SSH2 protocol
OS / ENVIRONMENT

OpenBSD 7.3

STEPS TO REPRODUCE

`` $ pip install ansible-pylibssh Collecting ansible-pylibssh Using cached ansible-pylibssh-1.1.0.tar.gz (106 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: ansible-pylibssh Building wheel for ansible-pylibssh (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for ansible-pylibssh (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [6 lines of output] [1/1] Cythonizing /tmp/pip-install-836t2rjb/ansible-pylibssh_75ed29d204f042ddbebe84563accbcc3/src/pylibsshext/_libssh_version.pyx /tmp/pip-install-836t2rjb/ansible-pylibssh_75ed29d204f042ddbebe84563accbcc3/src/pylibsshext/_libssh_version.c:757:10: fatal error: 'libssh/libssh.h' file not found

include "libssh/libssh.h"

           ^~~~~~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/cc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

EXPECTED RESULTS
ACTUAL RESULTS
webknjaz commented 1 year ago

https://github.com/ansible/pylibssh/pull/477 suggested adding a built-in extension of the library search path that gcc consumes, but I'm not so sure if it's such a great idea to build it into our scripts.

@quistian try running CFLAGS=-I/usr/local/include pip install ansible-pylibssh — hopefully, this will solve your issue. You may need to adjust the actual include path, I'm not familiar with where your OS installs C-headers.

cc @donnerhacke

quistian commented 1 year ago

Perfect!!!! Worked. Many thanks!

webknjaz commented 1 year ago

@quistian great news! Out of curiosity, do you know why your shell doesn't set CFLAGS to point to places where you install your libraries? I would've expected it to be solved on an OS-global level..

webknjaz commented 1 year ago

Meanwhile, I'm not closing this but marking as a possible documentation improvement possibility.

quistian commented 1 year ago

I can't see that any of my login shells (bash/zsh/ksh) set CFLAGS by default.

comete-geek commented 5 months ago

Hello, 1.2.0 doesn't build on OpenBSD 7.5 either even with CFLAGS set.

# CFLAGS=-I/usr/local/include pip install ansible-pylibssh       
Collecting ansible-pylibssh
  Using cached ansible-pylibssh-1.2.0.post4.tar.gz (133 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ansible-pylibssh
  Building wheel for ansible-pylibssh (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for ansible-pylibssh (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      [1/1] Cythonizing /tmp/.tmp-ansible-pylibssh-pep517-_rfatkno/src/src/pylibsshext/_libssh_version.pyx
      /tmp/.tmp-ansible-pylibssh-pep517-_rfatkno/src/src/pylibsshext/_libssh_version.c:1236:10: fatal error: 'libssh/libssh.h' file not found
      #include "libssh/libssh.h"
               ^~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/cc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ansible-pylibssh
Failed to build ansible-pylibssh
ERROR: Could not build wheels for ansible-pylibssh, which is required to install pyproject.toml-based projects
# ls -l /usr/local/include
drwxr-xr-x     - root 12 Jun 09:13  curl
drwxr-xr-x     - root 28 May 08:27  git2
drwxr-xr-x     - root 27 May 16:07  lzma
drwxr-xr-x     - root 12 Jun 09:12  nghttp2
drwxr-xr-x     - root 12 Jun 09:12  nghttp3
drwxr-xr-x     - root 12 Jun 09:12  ngtcp2
drwxr-xr-x     - root 27 May 16:08  python3.10
drwxr-xr-x     - root 27 May 16:07  sodium
.rw-r--r--  2.4k root 15 Mar 15:29  autosprintf.h
.rw-r--r--  6.2k root 15 Mar 15:16  bzlib.h
.rw-r--r--   14k root 15 Mar 15:32  ffi.h
.rw-r--r--  4.9k root 15 Mar 15:32  ffitarget.h
.rw-r--r--  1.9k root 16 Mar 18:06  git2.h
.rwxr-xr-x   19k root 16 Mar 18:05  http_parser.h
.rw-r--r--  9.2k root 15 Mar 15:16  iconv.h
.rw-r--r--  1.5k root 15 Mar 15:16  libcharset.h
.rw-r--r--   24k root 15 Mar 15:29  libintl.h
.rw-r--r--   59k root 15 Mar 15:16  libssh2.h
.rw-r--r--  4.9k root 15 Mar 15:16  libssh2_publickey.h
.rw-r--r--   17k root 15 Mar 15:16  libssh2_sftp.h
.rw-r--r--  6.3k root 15 Mar 15:16  localcharset.h
.rw-r--r-- 10.0k root 15 Mar 15:16  lzma.h
.rw-r--r--   32k root 15 Mar 15:18  pcre.h
.rw-r--r--  6.6k root 15 Mar 15:18  pcre_scanner.h
.rw-r--r--  6.3k root 15 Mar 15:18  pcre_stringpiece.h
.rw-r--r--   27k root 15 Mar 15:18  pcrecpp.h
.rw-r--r--  6.8k root 15 Mar 15:18  pcrecpparg.h
.rw-r--r--  5.5k root 15 Mar 15:18  pcreposix.h
.rw-r--r--  2.8k root 15 Mar 15:23  sodium.h
.rw-r--r--  638k root 15 Mar 15:18  sqlite3.h
.rw-r--r--   38k root 15 Mar 15:18  sqlite3ext.h

Thanks for your help !

webknjaz commented 2 months ago

@comete-geek you have to install libssh, not libssh2 which is an entirely different project.