Skip to content

Commit cc1f0a6

Browse files
author
Pan
committed
Added appveyor cfg for windows binary wheel builds.
Added libssh2 submodule.
1 parent 001d0be commit cc1f0a6

File tree

7 files changed

+927
-304
lines changed

7 files changed

+927
-304
lines changed

.appveyor.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
environment:
2+
global:
3+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
4+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
5+
# See: http://stackoverflow.com/a/13751649/163740
6+
CMD_IN_ENV: "cmd /E:ON /V:ON /C %APPVEYOR_BUILD_FOLDER%\\ci\\appveyor\\run_with_env.cmd"
7+
PYTHONUNBUFFERED: 1
8+
PYPI_USER:
9+
secure: 2m0jy6JD/R9RExIosOT6YA==
10+
PYPI_PASS:
11+
secure: x+dF0A8BZUf2IrPNRN1O0w==
12+
matrix:
13+
- PYTHON: "C:\\Python27"
14+
PYTHON_VERSION: "2.7"
15+
PYTHON_ARCH: "32"
16+
MSVC: "Visual Studio 9"
17+
18+
- PYTHON: "C:\\Python27-x64"
19+
PYTHON_VERSION: "2.7"
20+
PYTHON_ARCH: "64"
21+
MSVC: "Visual Studio 9"
22+
23+
- PYTHON: "C:\\Python34"
24+
PYTHON_VERSION: "3.4"
25+
PYTHON_ARCH: "32"
26+
MSVC: "Visual Studio 10"
27+
28+
- PYTHON: "C:\\Python34-x64"
29+
PYTHON_VERSION: "3.4"
30+
PYTHON_ARCH: "64"
31+
MSVC: "Visual Studio 10 Win64"
32+
33+
- PYTHON: "C:\\Python35"
34+
PYTHON_VERSION: "3.5"
35+
PYTHON_ARCH: "32"
36+
MSVC: "Visual Studio 14"
37+
38+
- PYTHON: "C:\\Python35-x64"
39+
PYTHON_VERSION: "3.5"
40+
PYTHON_ARCH: "64"
41+
MSVC: "Visual Studio 14 Win64"
42+
43+
- PYTHON: "C:\\Python36"
44+
PYTHON_VERSION: "3.6"
45+
PYTHON_ARCH: "32"
46+
MSVC: "Visual Studio 14"
47+
48+
- PYTHON: "C:\\Python36-x64"
49+
PYTHON_VERSION: "3.6"
50+
PYTHON_ARCH: "64"
51+
MSVC: "Visual Studio 14 Win64"
52+
53+
install:
54+
# If there is a newer build queued for the same PR, cancel this one.
55+
# The AppVeyor 'rollout builds' option is supposed to serve the same
56+
# purpose but it is problematic because it tends to cancel builds pushed
57+
# directly to master instead of just PR builds (or the converse).
58+
# credits: JuliaLang developers.
59+
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
60+
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
61+
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
62+
throw "There are newer queued builds for this pull request, failing early." }
63+
- ECHO "Installed SDKs:"
64+
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
65+
66+
# Prepend newly installed Python to the PATH of this build (this cannot be
67+
# done from inside the powershell script as it would require to restart
68+
# the parent CMD process).
69+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
70+
71+
# Check that we have the expected version and architecture for Python
72+
- "python --version"
73+
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
74+
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"
78+
79+
# Install the build dependencies of the project. If some dependencies contain
80+
# compiled extensions and are not provided as pre-built wheel packages,
81+
# pip will build them from source using the MSVC compiler matching the
82+
# target Python version and architecture
83+
- "%CMD_IN_ENV% pip install -r requirements_dev.txt"
84+
- "%CMD_IN_ENV% pip install -U wheel setuptools twine"
85+
- git submodule update --init --recursive
86+
87+
build_script:
88+
- "%CMD_IN_ENV% ci\\appveyor\\build_ssh2.bat"
89+
# Build the compiled extension
90+
- "%CMD_IN_ENV% python setup.py build_ext -i"
91+
92+
test_script:
93+
- python -c "import pssh.native.ssh2"
94+
95+
after_test:
96+
# If tests are successful, create binary packages for the project.
97+
- "%CMD_IN_ENV% python setup.py bdist_wheel"
98+
- mv dist/* .
99+
100+
artifacts:
101+
# Archive the generated packages in the ci.appveyor.com build report.
102+
- path: "*.whl"
103+
104+
deploy_script:
105+
- python ci/appveyor/pypi_upload.py *.whl

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libssh2"]
2+
path = libssh2
3+
url = https://github.com/libssh2/libssh2.git

ci/appveyor/build_ssh2.bat

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

ci/appveyor/pypi_upload.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from __future__ import print_function
2+
3+
import sys
4+
import subprocess
5+
import os
6+
7+
8+
def upload_pypi(files):
9+
_user, _pass = os.environ['PYPI_USER'], os.environ['PYPI_PASS']
10+
try:
11+
subprocess.check_call(['twine', 'upload', '-u', _user,
12+
'-p', _pass, files])
13+
except Exception:
14+
sys.stderr.write("Error uploading to PyPi" + os.linesep)
15+
16+
17+
if __name__ == "__main__":
18+
if not len(sys.argv) > 1:
19+
sys.stderr.write("Need files to upload argument" + os.linesep)
20+
sys.exit(1)
21+
upload_pypi(os.path.abspath(sys.argv[1]))

ci/appveyor/run_with_env.cmd

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
:: To build extensions for 64 bit Python 3.5 or later no special environment needs
2+
:: to be configured for the Python extension code alone, however, all dependent
3+
:: libraries also need to be compiled with the same SDK in order to be able to
4+
:: link them together.
5+
::
6+
:: This script sets SDK version and environment for all commands.
7+
::
8+
:: To build extensions for 64 bit Python 3.4 or earlier, we need to configure environment
9+
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
10+
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
11+
::
12+
:: To build extensions for 64 bit Python 2, we need to configure environment
13+
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
14+
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
15+
::
16+
:: 32 bit builds do not require specific environment configurations.
17+
::
18+
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
19+
:: cmd interpreter, at least for (SDK v7.0)
20+
::
21+
:: More details at:
22+
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
23+
:: https://stackoverflow.com/a/13751649/163740
24+
::
25+
:: Original Author: Olivier Grisel
26+
:: License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/
27+
:: This version based on updates for python 3.5 by Phil Elson at:
28+
:: https://github.com/pelson/Obvious-CI/tree/master/scripts
29+
:: Further updates to always correctly set SDK version and environment so
30+
:: that compiled library dependencies use same SDK as Python extension.
31+
32+
@ECHO OFF
33+
34+
SET COMMAND_TO_RUN=%*
35+
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
36+
37+
SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
38+
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
39+
IF %MAJOR_PYTHON_VERSION% == "2" (
40+
SET WINDOWS_SDK_VERSION="v7.0"
41+
SET SET_SDK_64=Y
42+
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
43+
SET WINDOWS_SDK_VERSION="v7.1"
44+
IF %MINOR_PYTHON_VERSION% LEQ 4 (
45+
SET SET_SDK_64=Y
46+
) ELSE (
47+
SET SET_SDK_64=N
48+
)
49+
) ELSE (
50+
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
51+
EXIT 1
52+
)
53+
54+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
55+
56+
IF "%PYTHON_ARCH%"=="64" (
57+
IF %SET_SDK_64% == Y (
58+
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
59+
SET DISTUTILS_USE_SDK=1
60+
SET MSSdk=1
61+
)
62+
ECHO Setting MSVC %WINDOWS_SDK_VERSION% build environment for 64 bit architecture
63+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
64+
ECHO Executing: %COMMAND_TO_RUN%
65+
call %COMMAND_TO_RUN% || EXIT 1
66+
) ELSE (
67+
ECHO Setting MSVC %WINDOWS_SDK_VERSION% build environment for 32 bit architecture
68+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x86 /release
69+
ECHO Executing: %COMMAND_TO_RUN%
70+
call %COMMAND_TO_RUN% || EXIT 1
71+
)

libssh2

Submodule libssh2 added at 30e9c13

0 commit comments

Comments
 (0)