Skip to content

Commit

Permalink
Windows wheel fixes for bundled libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkittenis committed May 11, 2018
1 parent 8f7607e commit 11e3a63
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
16 changes: 15 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
CMD_IN_ENV: "cmd /E:ON /V:ON /C %APPVEYOR_BUILD_FOLDER%\\ci\\appveyor\\run_with_env.cmd"
PYTHONUNBUFFERED: 1
EMBEDDED_LIB: 1
OPENSSL_VER: 1.0.2l
PYPI_USER:
secure: 2m0jy6JD/R9RExIosOT6YA==
PYPI_PASS:
Expand All @@ -15,41 +16,49 @@ environment:
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "32"
MSVC: "Visual Studio 9"
ARCH: i386

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "64"
MSVC: "Visual Studio 9"
ARCH: x64_86

- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4"
PYTHON_ARCH: "32"
MSVC: "Visual Studio 10"
ARCH: i386

- PYTHON: "C:\\Python34-x64"
PYTHON_VERSION: "3.4"
PYTHON_ARCH: "64"
MSVC: "Visual Studio 10 Win64"
ARCH: x64_86

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "32"
MSVC: "Visual Studio 14"
ARCH: i386

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "64"
MSVC: "Visual Studio 14 Win64"
ARCH: x64_86

- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "32"
MSVC: "Visual Studio 14"
ARCH: i386

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
MSVC: "Visual Studio 14 Win64"
ARCH: x64_86

install:
# If there is a newer build queued for the same PR, cancel this one.
Expand Down Expand Up @@ -91,6 +100,11 @@ install:
# do not cause a version change.
- python ci/appveyor/fix_version.py .
- mv -f .git .git.bak
- appveyor DownloadFile https://indy.fulgan.com/SSL/openssl-%OPENSSL_VER%-%ARCH%-win%PYTHON_ARCH%.zip
- 7z x openssl-%OPENSSL_VER%-%ARCH%-win%PYTHON_ARCH%.zip
- cp ssleay32.dll ssh2\
- cp libeay32.dll ssh2\
- ps: ls ssh2

build_script:
# Build the compiled extension
Expand All @@ -112,4 +126,4 @@ artifacts:
- path: "*.whl"

deploy_script:
- python ci/appveyor/pypi_upload.py *.whl
- IF "%APPVEYOR_REPO_TAG%" == "true"( python ci/appveyor/pypi_upload.py *.whl )
31 changes: 20 additions & 11 deletions ci/appveyor/build_ssh2.bat
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
mkdir src && cd src

IF "%PYTHON_ARCH%" == "32" (
set OPENSSL_DIR="C:\OpenSSL-Win32"
) ELSE (
set OPENSSL_DIR="C:\OpenSSL-Win64"
)

ls %OPENSSL_DIR%\lib
ls %OPENSSL_DIR%\lib\VC
ls %OPENSSL_DIR%\lib\VC\static

IF "%MSVC%" == "Visual Studio 9" (
ECHO "Building without platform set"
cmake ..\libssh2 -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCRYPTO_BACKEND=OpenSSL ^
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=OFF ^
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR%
REM -DOPENSSL_MSVC_STATIC_RT=TRUE
REM -DOPENSSL_USE_STATIC_LIBS=TRUE
) ELSE (
ECHO "Building with platform %MSVC%"
cmake ..\libssh2 -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCRYPTO_BACKEND=OpenSSL ^
-G"%MSVC%" ^
-DBUILD_SHARED_LIBS=OFF
)

IF "%PYTHON_ARCH%" == "32" (
set OPENSSL_DIR="C:\OpenSSL-Win32"
) ELSE (
set OPENSSL_DIR="C:\OpenSSL-Win64"
-DBUILD_SHARED_LIBS=OFF ^
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR%
REM -DOPENSSL_MSVC_STATIC_RT=TRUE
REM -DOPENSSL_USE_STATIC_LIBS=TRUE
)

cp %OPENSSL_DIR%\lib\VC\libeay32MD.lib %APPVEYOR_BUILD_FOLDER%
cp %OPENSSL_DIR%\lib\VC\ssleay32MD.lib %APPVEYOR_BUILD_FOLDER%
cp %OPENSSL_DIR%\libeay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\
cp %OPENSSL_DIR%\ssleay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\
REM cp %OPENSSL_DIR%\libeay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\
REM cp %OPENSSL_DIR%\ssleay32.dll %APPVEYOR_BUILD_FOLDER%\ssh2\

cmake --build . --config Release
cd ..
ls %OPENSSL_DIR%\
ls
ls ssh2
ls src/src
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
if ON_WINDOWS:
# For libssh2 OpenSSL backend on Windows.
_libs = ['Ws2_32', 'libssh2', 'user32',
'libeay32MD', 'ssleay32MD']
'libeay32MD', 'ssleay32MD',
]
else:
_libs = ['ssh2']

# _comp_args = ["-ggdb"]
_comp_args = ["-O3"] if platform.system() != 'Windows' else None
_comp_args = ["-O3"] if not ON_WINDOWS else None
_embedded_lib = bool(os.environ.get('EMBEDDED_LIB', 1))
cython_directives = {'embedsignature': True,
'boundscheck': False,
Expand All @@ -57,7 +58,9 @@
package_data = {'ssh2': ['*.pxd']}

if ON_WINDOWS:
package_data['ssh2'].extend(['libeay32.dll', 'ssleay32.dll'])
package_data['ssh2'].extend([
'libeay32.dll', 'ssleay32.dll',
])

print("Using package data %s" % package_data)

Expand Down

0 comments on commit 11e3a63

Please sign in to comment.