Skip to content

Commit a1af6f4

Browse files
author
Pan
committed
Fixed system package build scripts and docker files - resolves #25.
Re-enabled system package releases. Updated documentation. Added ubuntu 18.04 package build. Removed redhat 6 and debian 7 builds.
1 parent a7e8d65 commit a1af6f4

File tree

17 files changed

+140
-61
lines changed

17 files changed

+140
-61
lines changed

.travis.yml

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ script:
3232
- cd doc; make html; cd ..
3333
jobs:
3434
include:
35-
- stage: OSX wheel build
35+
- stage: build packages
3636
os: osx
37-
if: tag IS present
3837
before_install:
3938
- brew update
4039
install:
@@ -60,10 +59,10 @@ jobs:
6059
fi
6160
language: generic
6261
python: skip
63-
- stage: OSX wheel build
62+
63+
- stage: build packages
6464
os: osx
6565
osx_image: xcode8
66-
if: tag IS present
6766
before_install:
6867
- brew update
6968
install:
@@ -90,10 +89,10 @@ jobs:
9089
fi
9190
language: generic
9291
python: skip
93-
- stage: OSX wheel build
92+
93+
- stage: build packages
9494
os: osx
9595
osx_image: xcode6.4
96-
if: tag IS present
9796
before_install:
9897
- brew update
9998
install:
@@ -123,29 +122,63 @@ jobs:
123122
fi
124123
language: generic
125124
python: skip
126-
# - stage: build_packages
127-
# if: tag IS present
128-
# os: linux
129-
# python: 3.6
130-
# install: skip
131-
# script: skip
132-
# before_deploy:
133-
# - docker --version
134-
# - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
135-
# - ./ci/docker/build-packages.sh
136-
# deploy:
137-
# - provider: releases
138-
# skip_cleanup: true
139-
# api_key:
140-
# secure: i1Dr0k393wXBsCKST5ckeTPdZT+hjkikHCGgMSEkJxw+Q8m/Sgq9bbBalkJZDZDc8t0a/nE4ioEXoYO+PT9wRSpjLbjDVwRoWde5PVHaR3JviiwxULEynFLbvdJ1S2O/zRM37YMVgIIXN/2SWSXvQcQznrrvjtBoV+nZfYHX2WZQruq1nQXcPvTJPeZtCBsWaA3TwbVobnOJdb3TFxnHybN3N4gCTOkurek0V7OSMpjd1qgSzNMDIhjXKf/ZB9bcuusXo2QSnzUDJo3S6QE4FBxKohVom7z4AQ8+iRVPkkrWezBo089vzPzfZN/C5+8xQAUfZ6bVNdS6DfI80+55s6Xj7BFEKQW9Kh3Em0GpipHxdxiBf176xktY9EROkDkwDHlsbE7JRRQUmfmJe+0yCo+gg9uAsz5XHNrQgU5BxKhVzggMA/VU+clJ51WfbYGJAvVs/NjHQb/A9CzYKdBamUvy3YY2dxLbdohR7TZMM0JWYmZcmSiaOiZxrCT3ThlQ/J9o9r6TFWvkVjvt+ozABsx0OvtNrdkp7VvFbSQGvmTzGnPM2O5xqzWrM73Z7g8Ahw1g08FDN0JAO8n/Y0tb/xpVAFBmkQTJpQk7f4kQAHWlZKEYN2wEnX+hptjXfDjMYGX9Tc5vdDQJ3oTxnCt+y7Vl9IplT0a5GTTE0l8Pyc4=
141-
# file_glob: true
142-
# file: '*.{deb,rpm}'
143-
# on:
144-
# repo: ParallelSSH/ssh2-python
145-
# tags: true
146-
- stage: build wheels
125+
126+
- stage: build packages
127+
os: osx
128+
osx_image: xcode9.3
129+
before_install:
130+
- brew update
131+
install:
132+
- brew upgrade openssl
133+
- sudo ci/install-ssh2.sh
134+
- sudo -H pip2 install -U delocate twine wheel pip setuptools
135+
- cp /usr/local/lib/libssh2* .
136+
- ls -lh
137+
- pip2 wheel .
138+
script:
139+
- delocate-listdeps --all *.whl
140+
- delocate-wheel -v *.whl
141+
- delocate-listdeps --all *.whl
142+
- ls -l *.whl
143+
- rm -f *.dylib
144+
- pip2 install --user -v *.whl
145+
- pwd; mkdir temp; cd temp; pwd
146+
- python -c "from ssh2.session import Session; Session()"
147+
- cd ..; pwd
148+
after_success:
149+
- if [[ ! -z "$TRAVIS_TAG" ]]; then
150+
twine upload -u $PYPI_U -p $PYPI_P *.whl;
151+
fi
152+
language: generic
153+
python: skip
154+
155+
- stage: build packages
156+
env:
157+
- SYSTEM_PACKAGES=1
158+
os: linux
159+
language: generic
160+
python: skip
161+
install: skip
162+
script:
163+
- docker --version
164+
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
165+
- ./ci/docker/build-packages.sh
166+
deploy:
167+
- provider: releases
168+
skip_cleanup: true
169+
api_key:
170+
secure: i1Dr0k393wXBsCKST5ckeTPdZT+hjkikHCGgMSEkJxw+Q8m/Sgq9bbBalkJZDZDc8t0a/nE4ioEXoYO+PT9wRSpjLbjDVwRoWde5PVHaR3JviiwxULEynFLbvdJ1S2O/zRM37YMVgIIXN/2SWSXvQcQznrrvjtBoV+nZfYHX2WZQruq1nQXcPvTJPeZtCBsWaA3TwbVobnOJdb3TFxnHybN3N4gCTOkurek0V7OSMpjd1qgSzNMDIhjXKf/ZB9bcuusXo2QSnzUDJo3S6QE4FBxKohVom7z4AQ8+iRVPkkrWezBo089vzPzfZN/C5+8xQAUfZ6bVNdS6DfI80+55s6Xj7BFEKQW9Kh3Em0GpipHxdxiBf176xktY9EROkDkwDHlsbE7JRRQUmfmJe+0yCo+gg9uAsz5XHNrQgU5BxKhVzggMA/VU+clJ51WfbYGJAvVs/NjHQb/A9CzYKdBamUvy3YY2dxLbdohR7TZMM0JWYmZcmSiaOiZxrCT3ThlQ/J9o9r6TFWvkVjvt+ozABsx0OvtNrdkp7VvFbSQGvmTzGnPM2O5xqzWrM73Z7g8Ahw1g08FDN0JAO8n/Y0tb/xpVAFBmkQTJpQk7f4kQAHWlZKEYN2wEnX+hptjXfDjMYGX9Tc5vdDQJ3oTxnCt+y7Vl9IplT0a5GTTE0l8Pyc4=
171+
file_glob: true
172+
file: '*.{deb,rpm}'
173+
on:
174+
repo: ParallelSSH/ssh2-python
175+
tags: true
176+
177+
- stage: build packages
147178
os: linux
148179
python: 3.6
180+
env:
181+
- WHEELS=1
149182
install:
150183
- pip install twine
151184
script:

Changelog.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Changes
1414
Fixes
1515
------
1616

17-
* Removed duplicate definitions in ``c_ssh2.pxd``.
17+
* Removed duplicate libssh2 definitions.
18+
* Re-enabled system package releases.
19+
* System package builds would not work correctly - #25.
1820

1921

2022
0.13.0
@@ -24,7 +26,7 @@ Changes
2426
---------
2527

2628
* Upgrade embedded ``libssh2`` in binary wheels to latest version plus enhancements.
27-
* Adds support for ECDSA host keys.
29+
* Adds support for ECDSA host and client keys.
2830
* Adds support for SHA-256 host key fingerprints.
2931
* Added SSH agent forwarding implementation.
3032
* Windows wheels switched to OpenSSL back end.

ci/appveyor/fix_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def get_describe_tag():
88
return subprocess.check_output(['git', 'describe', '--tags']).strip().decode('utf-8')
99

1010
def make_version_file(basedir):
11-
# import ipdb; ipdb.set_trace()
12-
rev = os.environ['APPVEYOR_REPO_COMMIT']
11+
rev = os.environ.get('APPVEYOR_REPO_COMMIT',
12+
subprocess.check_output(['git', 'rev-list', '--max-count=1', 'HEAD']).strip().decode('utf-8'))
1313
basedir = os.path.abspath(basedir)
1414
git_desc = get_describe_tag()
1515
version_json = {'date': datetime.now().isoformat(),

ci/docker/build-packages.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ for x in `ls -1d ci/docker/{fedora,centos}*`; do
1212
docker pull $docker_tag || echo
1313
docker build --cache-from $docker_tag $x -t $name
1414
docker tag $name $docker_tag
15-
docker push $docker_tag
15+
# docker push $docker_tag
1616
sudo rm -rf build dist
17-
docker run -v "$(pwd):/src/" "$name" --rpm-dist $dist -s python -t rpm -d libssh2 -d python setup.py
17+
# Fix version used by versioneer to current git tag so the generated .c files
18+
# do not cause a version change.
19+
python ci/appveyor/fix_version.py .
20+
# C files need re-generating
21+
sudo rm -f ssh2/*.c
22+
docker run -v "$(pwd):/src/" "$name" fpm --rpm-dist $dist -s python -t rpm -d libssh2 -d python setup.py
1823
done
1924

2025
for x in `ls -1d ci/docker/{debian,ubuntu}*`; do
@@ -23,9 +28,14 @@ for x in `ls -1d ci/docker/{debian,ubuntu}*`; do
2328
docker pull $docker_tag || echo
2429
docker build --cache-from $docker_tag $x -t $name
2530
docker tag $name $docker_tag
26-
docker push $docker_tag
31+
# docker push $docker_tag
2732
sudo rm -rf build dist
28-
docker run -v "$(pwd):/src/" "$name" --iteration $name -s python -t deb -d libssh2-1 -d python setup.py
33+
# Fix version used by versioneer to current git tag so the generated .c files
34+
# do not cause a version change.
35+
python ci/appveyor/fix_version.py .
36+
# C files need re-generating
37+
sudo rm -f ssh2/*.c
38+
docker run -v "$(pwd):/src/" "$name" fpm --iteration $name -s python -t deb -d libssh2-1 -d python setup.py
2939
done
3040

3141
sudo chown -R ${USER} *
@@ -41,3 +51,5 @@ for x in *.deb; do
4151
echo "Package: $x"
4252
dpkg-deb -c $x
4353
done
54+
55+
echo "Modified files should be reset now -- run 'git checkout -- .' to do so for all files in the repository."

ci/docker/centos6/Dockerfile

Lines changed: 0 additions & 4 deletions
This file was deleted.

ci/docker/centos7/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
FROM cdrx/fpm-centos:7
22

33
RUN yum -y install libssh2-devel python-devel python-setuptools git
4-
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel
4+
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel && pip install cython
5+
6+
ENV EMBEDDED_LIB 0
7+
ENV HAVE_AGENT_FWD 0

ci/docker/debian8/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ RUN apt-get -y update
44
RUN apt-get -y install python-setuptools python-dev libssh2-1-dev python-pip git
55
RUN pip install -U setuptools
66
RUN pip install -U pip wheel
7+
8+
ENV EMBEDDED_LIB 1
9+
ENV HAVE_AGENT_FWD 0

ci/docker/fedora22/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
FROM cdrx/fpm-fedora:22
22

33
RUN yum -y install libssh2-devel python-devel python-setuptools git
4-
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel
4+
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel && pip install cython
5+
6+
ENV EMBEDDED_LIB 0
7+
ENV HAVE_AGENT_FWD 0

ci/docker/fedora23/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
FROM cdrx/fpm-fedora:23
22

33
RUN yum -y install libssh2-devel python-devel python-setuptools git
4-
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel
4+
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel && pip install cython
5+
6+
ENV EMBEDDED_LIB 0
7+
ENV HAVE_AGENT_FWD 0

ci/docker/fedora24/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
FROM cdrx/fpm-fedora:24
22

33
RUN yum -y install libssh2-devel python-devel python-setuptools git
4-
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel
4+
RUN curl -sLO https://bootstrap.pypa.io/get-pip.py && python get-pip.py && rm -f get-pip.py && pip install -U setuptools wheel && pip install cython
5+
6+
ENV EMBEDDED_LIB 1
7+
ENV HAVE_AGENT_FWD 0

ci/docker/ubuntu14.04/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ RUN apt-get -y update
44
RUN apt-get -y install python-setuptools python-dev libssh2-1-dev python-pip git
55
RUN pip install -U setuptools
66
RUN pip install -U pip wheel
7+
RUN pip install cython
8+
9+
ENV EMBEDDED_LIB 0
10+
ENV HAVE_AGENT_FWD 0

ci/docker/ubuntu16.04/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ RUN apt-get -y update
44
RUN apt-get -y install python-setuptools python-dev libssh2-1-dev python-pip git
55
RUN pip install -U setuptools
66
RUN pip install -U pip wheel
7+
8+
ENV EMBEDDED_LIB 0
9+
ENV HAVE_AGENT_FWD 0
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
FROM cdrx/fpm-debian:7
1+
FROM cdrx/fpm-ubuntu:18.04
22

33
RUN apt-get -y update
44
RUN apt-get -y install python-setuptools python-dev libssh2-1-dev python-pip git
55
RUN pip install -U setuptools
66
RUN pip install -U pip wheel
7+
8+
ENV EMBEDDED_LIB 1
9+
ENV HAVE_AGENT_FWD 0

doc/installation.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Installation
22
*************
33

4+
The recommended installation method is ``pip``.
5+
46
Pip Binary Packages
57
====================
68

7-
Binary wheel packages are provided for Linux, OSX and Windows, all Python versions, with ``libssh2`` and its required libraries included.
9+
Binary wheel packages are provided for Linux, OSX and Windows, all Python versions, with ``libssh2`` and its dependencies included.
810

911
Wheel packages have **no dependencies**.
1012

@@ -18,14 +20,14 @@ Wheel packages have **no dependencies**.
1820
1921
.. note::
2022

21-
Latest version of OpenSSL is included in Linux and OSX binary wheel packages. On Windows, the native WinCNG back-end is used instead.
23+
Latest available version of OpenSSL at the time the package is built is included in binary wheel packages.
2224

2325
To control which version of OpenSSL is used for the installation either use system packages which use system libraries, the conda package, or install from source.
2426

2527
System Binary Packages
2628
=======================
2729

28-
System packages can be built for Centos/RedHat 6/7, Ubuntu 14.04/16.04, Debian 7/8 and Fedora 22/23/24 by running `ci/docker/build-packages.sh <https://github.com/ParallelSSH/ssh2-python/blob/master/ci/docker/build-packages.sh>`_ script in the repository's directory, based on Docker.
30+
System packages can be built for Centos/RedHat 7, Ubuntu 14.04/16.04/18.04, Debian 8 and Fedora 22/23/24 by running `ci/docker/build-packages.sh <https://github.com/ParallelSSH/ssh2-python/blob/master/ci/docker/build-packages.sh>`_ script in the repository's directory, based on Docker.
2931

3032
To use the built packages, install via the system's package manager, for example for Centos/RedHat based systems:
3133

@@ -35,9 +37,9 @@ To use the built packages, install via the system's package manager, for example
3537
3638
.. note::
3739

38-
System packages use the system provided ``libssh2`` which may need to be updated to be compatible with ``ssh2-python``. ``libssh2`` versions ``>= 1.6.0`` are compatible.
40+
System packages as built by the above script use system provided ``libssh2`` and do not have all features enabled as most distributions do not have a new enough version. In addition, there are known issues with older versions of ``libssh2`` like what is provided by distributions.
3941

40-
To build an ``ssh2-python`` that is compatible with versions lower than ``1.6.0``, run the build with the ``EMBEDDED_LIB=0`` environment variable set. This will disable features that require ``libssh2`` >= ``1.6.0``.
42+
For best compatibility, it is recommended to install binary packages with ``pip``.
4143

4244
Conda package
4345
===============
@@ -76,16 +78,17 @@ If there are multiple development headers and/or libraries for ``libssh2`` on th
7678
7779
git clone --recurse-submodules [email protected]:ParallelSSH/ssh2-python.git
7880
sudo ./ci/install-ssh2.sh
81+
virtualenv my_env
7982
source my_env/bin/activate
80-
python setup.py build_ext -I /usr/local/include -R /usr/local/lib -L /usr/local/lib
83+
python setup.py build_ext -I /usr/local/include -R /usr/local/lib/x86_64-linux-gnu -L /usr/local/lib/x86_64-linux-gnu
8184
python setup.py install
8285
8386
System library build
8487
---------------------
8588

86-
Building against system provided ``libssh2`` is another option which may be preferred.
89+
Building against system provided ``libssh2`` is another option which may be preferred.
8790

88-
If the ``libssh2`` version provided by the system is not compatible, run the build with the ``EMBEDDED_LIB=0`` environment variable set. This will disable features that require ``libssh2`` >= ``1.6.0``.
91+
If the ``libssh2`` version provided by the system is not compatible, run the build with the ``EMBEDDED_LIB=0`` and ``HAVE_AGENT_FWD=0`` environment variables set. This will disable features that require ``libssh2`` >= ``1.6.0`` as well as agent forwarding implementation which is only present in the ``libssh2`` submodule of this repository.
8992

9093
Clone the repository, install dependencies and run install in a new virtualenv from the repository's root directory.
9194

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@
3232

3333
# _comp_args = ["-ggdb"]
3434
_comp_args = ["-O3"] if not ON_WINDOWS else None
35-
_embedded_lib = bool(os.environ.get('EMBEDDED_LIB', 1))
35+
_embedded_lib = bool(int(os.environ.get('EMBEDDED_LIB', 1)))
36+
_have_agent_fwd = bool(int(os.environ.get('HAVE_AGENT_FWD', 1)))
3637
cython_directives = {'embedsignature': True,
3738
'boundscheck': False,
3839
'optimize.use_switch': True,
3940
'wraparound': False,
4041
}
4142
cython_args = {
4243
'cython_directives': cython_directives,
43-
'cython_compile_time_env': {'EMBEDDED_LIB': _embedded_lib}} \
44+
'cython_compile_time_env': {
45+
'EMBEDDED_LIB': _embedded_lib,
46+
'HAVE_AGENT_FWD': _have_agent_fwd,
47+
}} \
4448
if USING_CYTHON else {}
4549

50+
if USING_CYTHON:
51+
sys.stdout.write("Cython arguments: %s%s" % (cython_args, os.linesep))
52+
4653
extensions = [
4754
Extension(sources[i].split('.')[0].replace(os.path.sep, '.'),
4855
sources=[sources[i]],

ssh2/c_ssh2.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,5 @@ cdef extern from "libssh2.h" nogil:
441441
int libssh2_trace_sethandler(LIBSSH2_SESSION *session,
442442
void* context,
443443
libssh2_trace_handler_func callback)
444-
IF EMBEDDED_LIB:
444+
IF HAVE_AGENT_FWD:
445445
int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel)

ssh2/channel.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,10 @@ cdef class Channel:
466466
c_ssh2.libssh2_channel_handle_extended_data(
467467
self._channel, ignore_mode)
468468

469-
def request_auth_agent(self):
470-
"""Request SSH agent authentication forwarding on channel."""
471-
cdef int rc
472-
with nogil:
473-
rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel)
474-
return handle_error_codes(rc)
469+
IF HAVE_AGENT_FWD:
470+
def request_auth_agent(self):
471+
"""Request SSH agent authentication forwarding on channel."""
472+
cdef int rc
473+
with nogil:
474+
rc = c_ssh2.libssh2_channel_request_auth_agent(self._channel)
475+
return handle_error_codes(rc)

0 commit comments

Comments
 (0)