Skip to content

Commit ca6af52

Browse files
authored
Osx builds using embedded libssh2 (#236)
* Make OSX wheel builds use embedded libssh2 * Re-add changes for libssh2 1.11.0
1 parent 9371bad commit ca6af52

File tree

15 files changed

+2074
-1698
lines changed

15 files changed

+2074
-1698
lines changed

Changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Changes
1515
was called on a `SFTPHandle` or not.
1616
* Added `ssh2.channel.Channel.signal` function for sending signals over SSH to an open channel - #221
1717
* Added `ssh2.session.Session.direct_streamlocal_ex` for creating `Channel` objects tunneling a local UNIX socket
18-
via the remote host to a third party.
18+
via the remote host to a third party - #40
1919
* Added new `libssh2` error codes under `ssh2.error_codes`, equivalent Python exceptions under `ssh2.exceptions`
2020
and updated error code handling for all functions.
2121
* Removed deprecated `libssh2` `ssh2.channel.Channel` functions `receive_window_adjust`, `handle_extended_data`
@@ -27,6 +27,7 @@ Packaging
2727
----------
2828

2929
* Removed Windows Python 3.7 wheel builds.
30+
* OSX binary wheels now use embedded `libssh2` rather than brew package.
3031

3132

3233
1.1.2

_setup_libssh2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323

2424
def build_ssh2():
25-
if bool(os.environ.get('SYSTEM_LIBSSH', False)):
26-
stderr.write("Using system libssh2..%s" % (os.sep))
25+
if bool(os.environ.get('SYSTEM_LIbBSSH2', False)):
26+
stderr.write("Using system libssh2..%s" % (os.sep,))
2727
return
2828
if os.path.exists('/usr/local/opt/openssl'):
2929
os.environ['OPENSSL_ROOT_DIR'] = '/usr/local/opt/openssl'

ci/osx-wheel.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,44 @@
1414
# You should have received a copy of the GNU Lesser General Public
1515
# License along with this library; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17-
LIBSSH2_DIR="/opt/homebrew/opt/libssh2/lib"
17+
SYSTEM_LIBSSH2_DIR="/opt/homebrew/opt/libssh2/lib"
18+
MY_LIBSSH2_DIR="build_dir/src/"
1819
LIBSSH2_INCLUDE_DIR="/opt/homebrew/opt/libssh2/include"
19-
export LDFLAGS="-L${LIBSSH2_DIR}"
20+
set +x
21+
2022
export CPPFLAGS="-I${LIBSSH2_INCLUDE_DIR}"
23+
sudo cp -a libssh2/include/* /opt/homebrew/opt/libssh2/include/
2124

2225
pip3 install -U virtualenv
2326
python3 -m virtualenv -p "$(which python3)" venv
2427

25-
set +x
2628
source venv/bin/activate
27-
set -x
2829

2930
python -V
3031
pip3 install -U setuptools pip
3132
pip3 install -U delocate wheel
32-
SYSTEM_LIBSSH2=1 python3 setup.py bdist_wheel
33-
ls -lhtr ${LIBSSH2_DIR}
33+
unset SYSTEM_LIBSSH2
34+
35+
python3 setup.py bdist_wheel
36+
37+
sudo cp -a ${MY_LIBSSH2_DIR}/libssh2* ${SYSTEM_LIBSSH2_DIR}/
38+
ls -lhtr ${SYSTEM_LIBSSH2_DIR}
39+
3440
delocate-listdeps dist/*.whl
3541
delocate-wheel -v -w wheels dist/*.whl
3642
delocate-listdeps wheels/*.whl
3743

3844
ls -l wheels/*.whl
39-
rm -f ${LIBSSH2_DIR}/libssh2*
45+
rm -f ${SYSTEM_LIBSSH2_DIR}/libssh2*
46+
rm -rf build_dir
47+
ls -lhtr ${SYSTEM_LIBSSH2_DIR}
48+
4049
pip3 install -v wheels/*.whl
50+
4151
pwd; mkdir -p temp; cd temp; pwd
4252
python3 -c "from ssh2.session import Session; Session()" && echo "Import successful"
4353
cd ..; pwd
44-
set +x
54+
4555
deactivate
56+
4657
set -x

ssh2/c_ssh2.pxd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ cdef extern from "libssh2.h" nogil:
5454
# Session flags
5555
LIBSSH2_FLAG_SIGPIPE
5656
LIBSSH2_FLAG_COMPRESS
57+
# Path flags
58+
LIBSSH2_FLAG_QUOTE_PATHS
59+
# Flags for SK authentication
60+
LIBSSH2_SK_PRESENCE_REQUIRED
61+
LIBSSH2_SK_VERIFICATION_REQUIRED
5762

5863

5964
ctypedef struct_stat libssh2_struct_stat

ssh2/error_codes.c

Lines changed: 84 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/error_codes.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,8 @@ cdef extern from "libssh2.h" nogil:
8080
_LIBSSH2_ERROR_RANDGEN "LIBSSH2_ERROR_RANDGEN"
8181
_LIBSSH2_ERROR_MISSING_USERAUTH_BANNER "LIBSSH2_ERROR_MISSING_USERAUTH_BANNER"
8282
_LIBSSH2_ERROR_ALGO_UNSUPPORTED "LIBSSH2_ERROR_ALGO_UNSUPPORTED"
83+
_LIBSSH2_ERROR_MAC_FAILURE "LIBSSH2_ERROR_MAC_FAILURE"
84+
_LIBSSH2_ERROR_HASH_INIT "LIBSSH2_ERROR_HASH_INIT"
85+
_LIBSSH2_ERROR_HASH_CALC "LIBSSH2_ERROR_HASH_CALC"
8386

8487
_LIBSSH2CHANNEL_EAGAIN "LIBSSH2_ERROR_EAGAIN"

ssh2/error_codes.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ LIBSSH2_ERROR_KEYFILE_AUTH_FAILED = \
8484
LIBSSH2_ERROR_RANDGEN = error_codes._LIBSSH2_ERROR_RANDGEN
8585
LIBSSH2_ERROR_MISSING_USERAUTH_BANNER = error_codes._LIBSSH2_ERROR_MISSING_USERAUTH_BANNER
8686
LIBSSH2_ERROR_ALGO_UNSUPPORTED = error_codes._LIBSSH2_ERROR_ALGO_UNSUPPORTED
87+
LIBSSH2_ERROR_MAC_FAILURE = error_codes._LIBSSH2_ERROR_MAC_FAILURE
88+
LIBSSH2_ERROR_HASH_INIT = error_codes._LIBSSH2_ERROR_HASH_INIT
89+
LIBSSH2_ERROR_HASH_CALC = error_codes._LIBSSH2_ERROR_HASH_CALC

0 commit comments

Comments
 (0)