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

Make lib work with Mac 14.1 sonoma, apple silicone #207

Open
kiryazovi-redis opened this issue Jul 9, 2024 · 6 comments
Open

Make lib work with Mac 14.1 sonoma, apple silicone #207

kiryazovi-redis opened this issue Jul 9, 2024 · 6 comments

Comments

@kiryazovi-redis
Copy link

Steps to repro:
use this lib in requirements.txt
set up any env (via pycharm/command line/w.e.)
try to install this lib.
I did it via poetry install, but also followed every option from: https://ssh2-python.readthedocs.io/en/latest/installation.html#installation-from-source


 CMake Warning (dev) at /opt/homebrew/Cellar/cmake/3.30.0/share/cmake/Modules/BundleUtilities.cmake:237 (message):
    Policy CMP0080 is not set: BundleUtilities cannot be included at configure
    time.  Run "cmake --help-policy CMP0080" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.
  
  Call Stack (most recent call first):
    /opt/homebrew/Cellar/cmake/3.30.0/share/cmake/Modules/BundleUtilities.cmake:246 (_warn_cmp0080)
    tests/CMakeLists.txt:39 (include)
  This warning is for project developers.  Use -Wno-dev to suppress it.
  
  -- Looking for include file sys/param.h
  -- Looking for include file sys/param.h - found
  -- The following features have been enabled:
  
   * Shared library, creating libssh2 as a shared library (.so/.dll)
   * Compression, using zlib for compression
   * "none" cipher
   * "none" MAC
   * diffie-hellman-group-exchange-sha1, "new" diffie-hellman-group-exchange-sha1 method
  
  -- The following REQUIRED packages have been found:
  
   * ZLIB
   * OpenSSL
  
  -- The following features have been disabled:
  
   * Logging, Logging of execution with debug trace
  
  -- Configuring done (4.7s)
  CMake Warning (dev):
    Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
    --help-policy CMP0042" for policy details.  Use the cmake_policy command to
    set the policy and suppress this warning.
  
    MACOSX_RPATH is not specified for the following targets:
  
     libssh2
  
  This warning is for project developers.  Use -Wno-dev to suppress it.
  
  -- Generating done (0.1s)
  -- Build files have been written to: /private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmppanhseo0/ssh2-python-1.0.0/build_dir
  [  1%] Building C object src/CMakeFiles/libssh2.dir/openssl.c.o
  /private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmppanhseo0/ssh2-python-1.0.0/libssh2/libssh2/src/openssl.c:130:12: warning: 'RSA_new' is deprecated [-Wdeprecated-declarations]
      *rsa = RSA_new();
             ^
  /opt/homebrew/Cellar/openssl@3/3.3.1/include/openssl/rsa.h:212:1: note: 'RSA_new' has been explicitly marked deprecated here
  OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
  ^
  /opt/homebrew/Cellar/openssl@3/3.3.1/include/openssl/macros.h:194:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
  #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                  ^
  /opt/homebrew/Cellar/openssl@3/3.3.1/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
  #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                     ^
  /private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmppanhseo0/ssh2-python-1.0.0/libssh2/libssh2/src/openssl.c:132:5: warning: 'RSA_set0_key' is deprecated [-Wdeprecated-declarations]
      RSA_set0_key(*rsa, n, e, d);
      ^
…………………….. A LOT OF LINES OF ERRORS
                                                  ^
  /opt/homebrew/Cellar/openssl@3/3.3.1/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
  #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                     ^
  60 warnings generated.
  [  2%] Building C object src/CMakeFiles/libssh2.dir/agent.c.o
  [  3%] Building C object src/CMakeFiles/libssh2.dir/agent_win.c.o
  [  4%] Building C object src/CMakeFiles/libssh2.dir/bcrypt_pbkdf.c.o
  [  5%] Building C object src/CMakeFiles/libssh2.dir/blowfish.c.o
  [  6%] Building C object src/CMakeFiles/libssh2.dir/channel.c.o
  [  6%] Building C object src/CMakeFiles/libssh2.dir/comp.c.o
  [  7%] Building C object src/CMakeFiles/libssh2.dir/crypt.c.o
  /private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmppanhseo0/ssh2-python-1.0.0/libssh2/libssh2/src/crypt.c:62:5: error: incompatible function pointer types initializing 'int (*)(LIBSSH2_SESSION *, unsigned char *, size_t, void **)' (aka 'int (*)(struct _LIBSSH2_SESSION *, unsigned char *, unsigned long, void **)') with an expression of type 'int (LIBSSH2_SESSION *, unsigned char *, void **)' (aka 'int (struct _LIBSSH2_SESSION *, unsigned char *, void **)') [-Wincompatible-function-pointer-types]
      crypt_none_crypt,
      ^~~~~~~~~~~~~~~~
  1 error generated.
  make[2]: *** [src/CMakeFiles/libssh2.dir/crypt.c.o] Error 1
  make[1]: *** [src/CMakeFiles/libssh2.dir/all] Error 2
  make: *** [all] Error 2
  Traceback (most recent call last):
    File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module>
      main()
    File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
    File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 271, in build_wheel
      return _build_backend().build_wheel(
    File "/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmp0qxuqabd/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 415, in build_wheel
      return self._build_with_temp_dir(
    File "/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmp0qxuqabd/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
      self.run_setup()
    File "/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmp0qxuqabd/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 497, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmp0qxuqabd/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 313, in run_setup
      exec(code, locals())
    File "<string>", line 32, in <module>
    File "/private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/tmppanhseo0/ssh2-python-1.0.0/_setup_libssh2.py", line 39, in build_ssh2
      check_call('cmake --build . --config Release', shell=True, env=os.environ)
    File "/Users/REDACTED/.pyenv/versions/3.10.5/lib/python3.10/subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'cmake --build . --config Release' returned non-zero exit status 2.
  

  at .venv/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with ssh2-python (1.0.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "ssh2-python (==1.0.0)"'.

Then, did the wheel command, adn got same result.


                                                      ^
      /opt/homebrew/Cellar/openssl@3/3.3.1/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
      #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                         ^
      60 warnings generated.
      [  2%] Building C object src/CMakeFiles/libssh2.dir/agent.c.o
      [  3%] Building C object src/CMakeFiles/libssh2.dir/agent_win.c.o
      [  4%] Building C object src/CMakeFiles/libssh2.dir/bcrypt_pbkdf.c.o
      [  5%] Building C object src/CMakeFiles/libssh2.dir/blowfish.c.o
      [  6%] Building C object src/CMakeFiles/libssh2.dir/channel.c.o
      [  6%] Building C object src/CMakeFiles/libssh2.dir/comp.c.o
      [  7%] Building C object src/CMakeFiles/libssh2.dir/crypt.c.o
      /private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/pip-wheel-vok7r6ui/ssh2-python_c0e4b0aeb4a549ac9102f45734dfc14c/libssh2/libssh2/src/crypt.c:62:5: error: incompatible function pointer types initializing 'int (*)(LIBSSH2_SESSION *, unsigned char *, size_t, void **)' (aka 'int (*)(struct _LIBSSH2_SESSION *, unsigned char *, unsigned long, void **)') with an expression of type 'int (LIBSSH2_SESSION *, unsigned char *, void **)' (aka 'int (struct _LIBSSH2_SESSION *, unsigned char *, void **)') [-Wincompatible-function-pointer-types]
          crypt_none_crypt,
          ^~~~~~~~~~~~~~~~
      1 error generated.
      make[2]: *** [src/CMakeFiles/libssh2.dir/crypt.c.o] Error 1
      make[1]: *** [src/CMakeFiles/libssh2.dir/all] Error 2
      make: *** [all] Error 2
      Traceback (most recent call last):
        File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/REDACTED/PycharmProjects/REDACTED/.venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/pip-build-env-dm1jnrqc/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 368, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/pip-build-env-dm1jnrqc/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/pip-build-env-dm1jnrqc/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 32, in <module>
        File "/private/var/folders/g6/7nc4rk9j1lvd6mjl3q02sgwm0000gp/T/pip-wheel-vok7r6ui/ssh2-python_c0e4b0aeb4a549ac9102f45734dfc14c/_setup_libssh2.py", line 39, in build_ssh2
          check_call('cmake --build . --config Release', shell=True, env=os.environ)
        File "/Users/REDACTED/.pyenv/versions/3.10.5/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command 'cmake --build . --config Release' returned non-zero exit status 2.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

This is being hit on Mac Sonoma 14.1
Can replicate on more than one machine by teammates.
Also, tried many work arounds such as installing from source
Another thing I tried is changing the openssl version locally. 

I tried installing with different cmake flags, that didn't help.
Then noticed the last release of this lib was 2022, so that explains the rootcause, being possible openssl missmatch, that I wasn't sure how to fix.

also tried installing with python 3.11, 3.12, there hit another issue:
#193


Ultimately was not able to fix it at all, so had to deploy docker.
I’ve redacted some of the folder names, but that doesn’t matter.

@Kyungminkim31
Copy link

This is the same issue I've experienced.

@object626
Copy link

On which Apple Clang version does this issue reproduce?

Noticed that on Clang 14 "incompatible function pointer types initializing" produces a warning, while on Clang 15 - error

@omacchioni
Copy link

I have the same issue...

clang -v
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@object626
Copy link

object626 commented Aug 16, 2024

My very quick patch. Will create PR when will have time, but since project has problems with management - doubt it will be merged soon.

So this is a patch which solved the problem for me.

diff --git a/libssh2/libssh2/CMakeLists.txt b/libssh2/libssh2/CMakeLists.txt
index e6c95c8..9769a70 100644
--- a/libssh2/libssh2/CMakeLists.txt
+++ b/libssh2/libssh2/CMakeLists.txt
@@ -49,6 +49,7 @@ else()
   set (CMAKE_C_STANDARD 90)
 endif()
 
+set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-function-pointer-types -Wno-deprecated-declarations")
 option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
 
 # Parse version

To make it work you will need to manually clone this repo, apply the patch and install.

  git clone --depth 1 --branch 1.0.0 https://github.com/ParallelSSH/ssh2-python.git
  cd ssh2-python
  git apply ../compile_flag.patch
  pip3 install .

@vdeepti212
Copy link

I am trying to install this patch "compile_flag.patch" but as this is not available after cloning , its not installing this .
Is there any other way to download this patch ?

@object626
Copy link

I am trying to install this patch "compile_flag.patch" but as this is not available after cloning , its not installing this .

Is there any other way to download this patch ?

Patch provided in the text form in my comment above. Please save it to some file on your machine and use the path to this saved file with git apply instead of "../compile_flag.patch"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants