ParallelSSH / ssh2-python

Python bindings for libssh2 C library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
228 stars 70 forks source link

Unable to install on python 3.10 macOS M1 #189

Open adithyabsk opened 1 year ago

adithyabsk commented 1 year ago

Bug reports

This may be related to this issue? #160 (Also tried to install using --use-pep517 and using older versions of pip.

# python --version
Python 3.10.9
# python -c 'import platform; print(platform.platform())'
macOS-12.6.1-arm64-arm-64bit
# python -m venv venv
# ./venv/bin/activate
# pip install ssh2-python
Looking in indexes: [REDACTED]
Collecting ssh2-python
  Using cached ssh2-python-1.0.0.tar.gz (2.6 MB)
  Preparing metadata (setup.py) ... done
Installing collected packages: ssh2-python
  DEPRECATION: ssh2-python is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for ssh2-python ... error
  error: subprocess-exited-with-error

  × Running setup.py install for ssh2-python did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      CMake Deprecation Warning at CMakeLists.txt:36 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      -- The C compiler identification is AppleClang 14.0.0.14000029
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      CMake Error at /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
        Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
        system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
        OPENSSL_INCLUDE_DIR)
      Call Stack (most recent call first):
        /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
        /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/FindOpenSSL.cmake:613 (find_package_handle_standard_args)
        src/CMakeLists.txt:63 (find_package)

      -- Configuring incomplete, errors occurred!
      See also "/private/var/folders/px/5fdwsz8x015gdxlstpyfp97w0000gq/T/pip-install-q49kr9xi/ssh2-python_ace8b6f6b48142388b3ef5694c822a2c/build_dir/CMakeFiles/CMakeOutput.log".
      See also "/private/var/folders/px/5fdwsz8x015gdxlstpyfp97w0000gq/T/pip-install-q49kr9xi/ssh2-python_ace8b6f6b48142388b3ef5694c822a2c/build_dir/CMakeFiles/CMakeError.log".
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/px/5fdwsz8x015gdxlstpyfp97w0000gq/T/pip-install-q49kr9xi/ssh2-python_ace8b6f6b48142388b3ef5694c822a2c/setup.py", line 32, in <module>
          build_ssh2()
        File "/private/var/folders/px/5fdwsz8x015gdxlstpyfp97w0000gq/T/pip-install-q49kr9xi/ssh2-python_ace8b6f6b48142388b3ef5694c822a2c/_setup_libssh2.py", line 35, in build_ssh2
          check_call('cmake ../libssh2/libssh2 -DBUILD_SHARED_LIBS=ON \
        File "/Users/adbalaji/.asdf/installs/python/3.10.9/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command 'cmake ../libssh2/libssh2 -DBUILD_SHARED_LIBS=ON     -DENABLE_ZLIB_COMPRESSION=ON -DENABLE_CRYPT_NONE=ON     -DENABLE_MAC_NONE=ON -DCRYPTO_BACKEND=OpenSSL' returned non-zero exit status 1.
      [end of output]

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

× Encountered error while trying to install package.
╰─> ssh2-python

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
adithyabsk commented 1 year ago

I dug into this issue a bit more and it seems that the CMakeLists.txt needs to be configured to be able to find OpenSSL. When I ran that following I was able to install the package:

OPENSSL_ROOT_DIR="/opt/homebrew/opt/openssl@3/" pip install ssh2-python

tkjaer commented 1 year ago

Thanks @adithyabsk!

This works for me as well on macOS-13.3-arm64-arm-64bit with Python 3.11.2.