Skip to content

Commit feb094e

Browse files
author
Pan
committed
Migrated windows wheels to openssl backend.
Broken pip fix for appveyor. Added zlib and enabled compression for windows wheels. Enabled no MAC and no encryption options for windows wheels.
1 parent d39a71c commit feb094e

File tree

4 files changed

+97
-19
lines changed

4 files changed

+97
-19
lines changed

.appveyor.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ environment:
55
# See: http://stackoverflow.com/a/13751649/163740
66
CMD_IN_ENV: "cmd /E:ON /V:ON /C %APPVEYOR_BUILD_FOLDER%\\ci\\appveyor\\run_with_env.cmd"
77
PYTHONUNBUFFERED: 1
8+
OPENSSL_VER: 1.0.2l
89
PYPI_USER:
910
secure: 2m0jy6JD/R9RExIosOT6YA==
1011
PYPI_PASS:
@@ -14,41 +15,49 @@ environment:
1415
PYTHON_VERSION: "2.7"
1516
PYTHON_ARCH: "32"
1617
MSVC: "Visual Studio 9"
18+
ARCH: i386
1719

1820
- PYTHON: "C:\\Python27-x64"
1921
PYTHON_VERSION: "2.7"
2022
PYTHON_ARCH: "64"
2123
MSVC: "Visual Studio 9"
24+
ARCH: x64_86
2225

2326
- PYTHON: "C:\\Python34"
2427
PYTHON_VERSION: "3.4"
2528
PYTHON_ARCH: "32"
2629
MSVC: "Visual Studio 10"
30+
ARCH: i386
2731

2832
- PYTHON: "C:\\Python34-x64"
2933
PYTHON_VERSION: "3.4"
3034
PYTHON_ARCH: "64"
3135
MSVC: "Visual Studio 10 Win64"
36+
ARCH: x64_86
3237

3338
- PYTHON: "C:\\Python35"
3439
PYTHON_VERSION: "3.5"
3540
PYTHON_ARCH: "32"
3641
MSVC: "Visual Studio 14"
42+
ARCH: i386
3743

3844
- PYTHON: "C:\\Python35-x64"
3945
PYTHON_VERSION: "3.5"
4046
PYTHON_ARCH: "64"
4147
MSVC: "Visual Studio 14 Win64"
48+
ARCH: x64_86
4249

4350
- PYTHON: "C:\\Python36"
4451
PYTHON_VERSION: "3.6"
4552
PYTHON_ARCH: "32"
4653
MSVC: "Visual Studio 14"
54+
ARCH: i386
4755

4856
- PYTHON: "C:\\Python36-x64"
4957
PYTHON_VERSION: "3.6"
5058
PYTHON_ARCH: "64"
5159
MSVC: "Visual Studio 14 Win64"
60+
ARCH: x64_86
5261

5362
install:
5463
# If there is a newer build queued for the same PR, cancel this one.
@@ -72,25 +81,26 @@ install:
7281
- "python --version"
7382
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
7483

75-
# Upgrade to the latest version of pip to avoid it displaying warnings
76-
# about it being out of date.
77-
- "pip install --disable-pip-version-check --user --upgrade pip"
84+
# - "pip install --disable-pip-version-check --user --upgrade pip"
7885

7986
- git submodule update --init --recursive
80-
- "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat"
81-
# Install the build dependencies of the project. If some dependencies contain
82-
# compiled extensions and are not provided as pre-built wheel packages,
83-
# pip will build them from source using the MSVC compiler matching the
84-
# target Python version and architecture
87+
- appveyor DownloadFile http://zlib.net/zlib1211.zip
88+
- 7z x zlib1211.zip
89+
- appveyor DownloadFile https://indy.fulgan.com/SSL/openssl-%OPENSSL_VER%-%ARCH%-win%PYTHON_ARCH%.zip
90+
- 7z x openssl-%OPENSSL_VER%-%ARCH%-win%PYTHON_ARCH%.zip
91+
- cp ssleay32.dll pssh\native\
92+
- cp libeay32.dll pssh\native\
93+
- ps: ls pssh\native
8594
- "%CMD_IN_ENV% pip install -r requirements.txt"
8695
- "%CMD_IN_ENV% pip install -U wheel setuptools twine"
8796

8897
build_script:
89-
# Build the compiled extension
98+
- "%CMD_IN_ENV% ci\\appveyor\\build_zlib.bat"
99+
- "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat"
90100
- "%CMD_IN_ENV% python setup.py build_ext -i"
91101

92102
test_script:
93-
- python -c "import pssh.pssh2_client"
103+
- python -c "import pssh.clients"
94104

95105
after_test:
96106
# If tests are successful, create binary packages for the project.
@@ -102,4 +112,4 @@ artifacts:
102112
- path: "*.whl"
103113

104114
deploy_script:
105-
- python ci/appveyor/pypi_upload.py *.whl
115+
- IF "%APPVEYOR_REPO_TAG%" == "true"( python ci/appveyor/pypi_upload.py *.whl )

ci/appveyor/build_ssh2.bat

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,56 @@
1-
mkdir src && cd src
1+
mkdir src
2+
cd src
3+
4+
IF "%PYTHON_ARCH%" == "32" (
5+
set OPENSSL_DIR="C:\OpenSSL-Win32"
6+
) ELSE (
7+
set OPENSSL_DIR="C:\OpenSSL-Win64"
8+
)
9+
10+
ls %OPENSSL_DIR%\lib
11+
ls %OPENSSL_DIR%\lib\VC
12+
ls %OPENSSL_DIR%\lib\VC\static
213

314
IF "%MSVC%" == "Visual Studio 9" (
415
ECHO "Building without platform set"
516
cmake ..\libssh2 -G "NMake Makefiles" ^
617
-DCMAKE_BUILD_TYPE=Release ^
7-
-DCRYPTO_BACKEND=WinCNG ^
8-
-DBUILD_SHARED_LIBS=OFF
18+
-DCRYPTO_BACKEND=OpenSSL ^
19+
-DBUILD_SHARED_LIBS=OFF ^
20+
-DENABLE_ZLIB_COMPRESSION=ON ^
21+
-DENABLE_CRYPT_NONE=ON ^
22+
-DENABLE_MAC_NONE=ON ^
23+
-DZLIB_LIBRARY=C:/zlib/lib/zlib.lib ^
24+
-DZLIB_INCLUDE_DIR=C:/zlib/include ^
25+
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR%
26+
REM -DOPENSSL_MSVC_STATIC_RT=TRUE
27+
REM -DOPENSSL_USE_STATIC_LIBS=TRUE
928
) ELSE (
1029
ECHO "Building with platform %MSVC%"
1130
cmake ..\libssh2 -G "NMake Makefiles" ^
1231
-DCMAKE_BUILD_TYPE=Release ^
13-
-DCRYPTO_BACKEND=WinCNG ^
32+
-DCRYPTO_BACKEND=OpenSSL ^
1433
-G"%MSVC%" ^
15-
-DBUILD_SHARED_LIBS=OFF
34+
-DBUILD_SHARED_LIBS=OFF ^
35+
-DENABLE_ZLIB_COMPRESSION=ON ^
36+
-DENABLE_CRYPT_NONE=ON ^
37+
-DENABLE_MAC_NONE=ON ^
38+
-DZLIB_LIBRARY=C:/zlib/lib/zlib.lib ^
39+
-DZLIB_INCLUDE_DIR=C:/zlib/include ^
40+
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR%
41+
REM -DOPENSSL_MSVC_STATIC_RT=TRUE
42+
REM -DOPENSSL_USE_STATIC_LIBS=TRUE
1643
)
1744

45+
cp %OPENSSL_DIR%\lib\VC\libeay32MD.lib %APPVEYOR_BUILD_FOLDER%
46+
cp %OPENSSL_DIR%\lib\VC\ssleay32MD.lib %APPVEYOR_BUILD_FOLDER%
47+
REM cp %OPENSSL_DIR%\libeay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\
48+
REM cp %OPENSSL_DIR%\ssleay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\
49+
1850
cmake --build . --config Release
1951
cd ..
52+
ls
53+
ls pssh
2054
ls src/src
2155
cp src/src/libssh2.lib %PYTHON%/libs/ || cp src/src/Release/libssh2.lib %PYTHON%/libs/
2256
ls %PYTHON%/libs/

ci/appveyor/build_zlib.bat

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
mkdir zlib_build && cd zlib_build
2+
3+
IF "%MSVC%" == "Visual Studio 9" (
4+
ECHO "Building without platform set"
5+
cmake ..\zlib-1.2.11 -G "NMake Makefiles" ^
6+
-DCMAKE_INSTALL_PREFIX="C:\zlib" ^
7+
-DCMAKE_BUILD_TYPE=Release ^
8+
-DBUILD_SHARED_LIBS=OFF
9+
) ELSE (
10+
ECHO "Building with platform %MSVC%"
11+
cmake ..\zlib-1.2.11 ^
12+
-G"%MSVC%" ^
13+
-DCMAKE_INSTALL_PREFIX="C:\zlib" ^
14+
-DCMAKE_BUILD_TYPE=Release ^
15+
-DBUILD_SHARED_LIBS=OFF
16+
)
17+
18+
cmake --build . --config Release --target install
19+
cp C:/zlib/lib/zlibstatic.lib %PYTHON%/libs/
20+
cd ..
21+
ls %PYTHON%/libs/

setup.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
else:
3030
USING_CYTHON = True
3131

32+
ON_WINDOWS = platform.system() == 'Windows'
3233

3334
gevent_req = 'gevent<=1.1' if python_version() < '2.7' else 'gevent>=1.1'
3435

@@ -43,15 +44,18 @@
4344
'cython_compile_time_env': {'EMBEDDED_LIB': _embedded_lib},
4445
} if USING_CYTHON else {}
4546

46-
_libs = ['ssh2'] if platform.system() != 'Windows' else [
47+
_libs = ['ssh2'] if not ON_WINDOWS else [
4748
# For libssh2 OpenSSL backend on Windows.
4849
# Windows native WinCNG is used by default.
4950
# 'libeay32', 'ssleay32',
50-
'Ws2_32', 'libssh2', 'user32']
51+
'Ws2_32', 'libssh2', 'user32',
52+
'libeay32MD', 'ssleay32MD',
53+
'zlibstatic',
54+
]
5155

5256

5357
ext = 'pyx' if USING_CYTHON else 'c'
54-
_comp_args = ["-O3"] if platform.system() != 'Windows' else None
58+
_comp_args = ["-O3"] if not ON_WINDOWS else None
5559

5660
extensions = [
5761
Extension('pssh.native._ssh2',
@@ -62,6 +66,14 @@
6266
**cython_args
6367
)]
6468

69+
70+
package_data = {}
71+
72+
if ON_WINDOWS:
73+
package_data['pssh.native'] = [
74+
'libeay32.dll', 'ssleay32.dll',
75+
]
76+
6577
cmdclass = versioneer.get_cmdclass()
6678
if USING_CYTHON:
6779
cmdclass['build_ext'] = build_ext
@@ -96,4 +108,5 @@
96108
'Operating System :: Microsoft :: Windows',
97109
],
98110
ext_modules=extensions,
111+
package_data=package_data,
99112
)

0 commit comments

Comments
 (0)