|
| 1 | +properties([ |
| 2 | + parameters([ |
| 3 | + string(defaultValue: '', description: 'The version from PyPI to build', name: 'BUILD_VERSION') |
| 4 | + ]), |
| 5 | + pipelineTriggers([]) |
| 6 | +]) |
| 7 | + |
| 8 | +def configs = [ |
| 9 | + [ |
| 10 | + label: 'windows', |
| 11 | + versions: ['py26', 'py27', 'py34', 'py35', 'py36'], |
| 12 | + ], |
| 13 | + [ |
| 14 | + label: 'windows64', |
| 15 | + versions: ['py26', 'py27', 'py34', 'py35', 'py36'], |
| 16 | + ], |
| 17 | + [ |
| 18 | + label: 'sierra', |
| 19 | + versions: ['py26', 'py27', 'py34', 'py35', 'py36'], |
| 20 | + ], |
| 21 | + [ |
| 22 | + label: 'docker', |
| 23 | + imageName: 'pyca/cryptography-manylinux1:i686', |
| 24 | + versions: [ |
| 25 | + 'cp26-cp26m', 'cp26-cp26mu', 'cp27-cp27m', |
| 26 | + 'cp27-cp27mu', 'cp34-cp34m', 'cp35-cp35m', |
| 27 | + 'cp36-cp36m' |
| 28 | + ], |
| 29 | + ], |
| 30 | + [ |
| 31 | + label: 'docker', |
| 32 | + imageName: 'pyca/cryptography-manylinux1:x86_64', |
| 33 | + versions: [ |
| 34 | + 'cp26-cp26m', 'cp26-cp26mu', 'cp27-cp27m', |
| 35 | + 'cp27-cp27mu', 'cp34-cp34m', 'cp35-cp35m', |
| 36 | + 'cp36-cp36m' |
| 37 | + ], |
| 38 | + ], |
| 39 | +] |
| 40 | + |
| 41 | + |
| 42 | +def build(version, label, imageName) { |
| 43 | + try { |
| 44 | + timeout(time: 30, unit: 'MINUTES') { |
| 45 | + if (label.contains("windows")) { |
| 46 | + def pythonPath = [ |
| 47 | + py26: "C:\\Python26\\python.exe", |
| 48 | + py27: "C:\\Python27\\python.exe", |
| 49 | + py34: "C:\\Python34\\python.exe", |
| 50 | + py35: "C:\\Python35\\python.exe", |
| 51 | + py36: "C:\\Python36\\python.exe" |
| 52 | + ] |
| 53 | + if (version == "py35" || version == "py36") { |
| 54 | + opensslPaths = [ |
| 55 | + "windows": [ |
| 56 | + "include": "C:\\OpenSSL-Win32-2015\\include", |
| 57 | + "lib": "C:\\OpenSSL-Win32-2015\\lib" |
| 58 | + ], |
| 59 | + "windows64": [ |
| 60 | + "include": "C:\\OpenSSL-Win64-2015\\include", |
| 61 | + "lib": "C:\\OpenSSL-Win64-2015\\lib" |
| 62 | + ] |
| 63 | + ] |
| 64 | + } else { |
| 65 | + opensslPaths = [ |
| 66 | + "windows": [ |
| 67 | + "include": "C:\\OpenSSL-Win32-2010\\include", |
| 68 | + "lib": "C:\\OpenSSL-Win32-2010\\lib" |
| 69 | + ], |
| 70 | + "windows64": [ |
| 71 | + "include": "C:\\OpenSSL-Win64-2010\\include", |
| 72 | + "lib": "C:\\OpenSSL-Win64-2010\\lib" |
| 73 | + ] |
| 74 | + ] |
| 75 | + } |
| 76 | + bat """ |
| 77 | + wmic qfe |
| 78 | + @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% |
| 79 | + @set PYTHON="${pythonPath[version]}" |
| 80 | + |
| 81 | + @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% |
| 82 | + @set LIB="${opensslPaths[label]['lib']}";%LIB% |
| 83 | + virtualenv -p %PYTHON% .release |
| 84 | + call .release\\Scripts\\activate |
| 85 | + pip install wheel virtualenv |
| 86 | + pip wheel cryptography==$BUILD_VERSION --wheel-dir=wheelhouse --no-binary cryptography |
| 87 | + pip install -f wheelhouse cryptography --no-index |
| 88 | + python -c "from cryptography.hazmat.backends.openssl.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))" |
| 89 | + """ |
| 90 | + } else if (label.contains("sierra")) { |
| 91 | + def pythonPath = [ |
| 92 | + py26: "python2.6", |
| 93 | + py27: "/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7", |
| 94 | + py34: "/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4", |
| 95 | + py35: "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5", |
| 96 | + py36: "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6", |
| 97 | + ] |
| 98 | + ansiColor { |
| 99 | + sh """#!/usr/bin/env bash |
| 100 | + set -xe |
| 101 | + # output the list of things we've installed as a point in time check of how up |
| 102 | + # to date the builder is |
| 103 | + /usr/sbin/system_profiler SPInstallHistoryDataType |
| 104 | + |
| 105 | + # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH |
| 106 | + export PATH="/usr/local/bin:\${PATH}" |
| 107 | + export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" |
| 108 | + |
| 109 | + printenv |
| 110 | + |
| 111 | + virtualenv .venv -p ${pythonPath[version]} |
| 112 | + source .venv/bin/activate |
| 113 | + pip install -U wheel # upgrade wheel to latest before we use it to build the wheel |
| 114 | + CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS="1" LDFLAGS="/usr/local/opt/ [email protected]/lib/libcrypto.a /usr/local/opt/ [email protected]/lib/libssl.a" CFLAGS="-I/usr/local/opt/ [email protected]/include -mmacosx-version-min=10.9" pip wheel cryptography==$BUILD_VERSION --wheel-dir=wheelhouse --no-binary cryptography |
| 115 | + pip install -f wheelhouse cryptography --no-index |
| 116 | + python -c "from cryptography.hazmat.backends.openssl.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))" |
| 117 | + otool -L `find .venv -name '_openssl*.so'` |
| 118 | + lipo -info `find .venv -name '*.so'` |
| 119 | + otool -L `find .venv -name '_openssl*.so'` | grep -vG "libcrypto\\|libssl" |
| 120 | + """ |
| 121 | + } |
| 122 | + } else if (label.contains("docker")) { |
| 123 | + linux32 = "" |
| 124 | + if (imageName.contains("i686")) { |
| 125 | + linux32 = "linux32" |
| 126 | + } |
| 127 | + sh """#!/usr/bin/env bash |
| 128 | + set -x -e |
| 129 | + # Because we are doing this as root in the container, but we write to a mounted dir that is outside the container |
| 130 | + # we need to make sure we set these files writable such that the jenkins user can delete them afterwards |
| 131 | + mkdir -p tmpwheelhouse |
| 132 | + mkdir -p wheelhouse |
| 133 | + chmod -R 777 tmpwheelhouse |
| 134 | + chmod -R 777 wheelhouse |
| 135 | + |
| 136 | + $linux32 /opt/python/$version/bin/pip install cffi six idna asn1crypto ipaddress enum34 |
| 137 | + LDFLAGS="-L/opt/pyca/cryptography/openssl/lib" \ |
| 138 | + CFLAGS="-I/opt/pyca/cryptography/openssl/include -Wl,--exclude-libs,ALL" \ |
| 139 | + $linux32 /opt/python/$version/bin/pip wheel cryptography==$BUILD_VERSION -w tmpwheelhouse/ --no-binary cryptography --no-deps |
| 140 | + $linux32 auditwheel repair tmpwheelhouse/cryptography*.whl -w wheelhouse/ |
| 141 | + $linux32 /opt/python/$version/bin/pip install cryptography==$BUILD_VERSION --no-index -f wheelhouse/ |
| 142 | + $linux32 /opt/python/$version/bin/python -c "from cryptography.hazmat.backends.openssl.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))" |
| 143 | + """ |
| 144 | + } |
| 145 | + archiveArtifacts artifacts: "wheelhouse/cryptography*.whl" |
| 146 | + } |
| 147 | + } finally { |
| 148 | + deleteDir() |
| 149 | + } |
| 150 | + |
| 151 | +} |
| 152 | + |
| 153 | +def builders = [:] |
| 154 | +for (config in configs) { |
| 155 | + def label = config["label"] |
| 156 | + def versions = config["versions"] |
| 157 | + |
| 158 | + for (_version in versions) { |
| 159 | + def version = _version |
| 160 | + |
| 161 | + if (label.contains("docker")) { |
| 162 | + def imageName = config["imageName"] |
| 163 | + def combinedName = "${imageName}-${version}" |
| 164 | + builders[combinedName] = { |
| 165 | + node(label) { |
| 166 | + stage(combinedName) { |
| 167 | + def buildImage = docker.image(imageName) |
| 168 | + buildImage.pull() |
| 169 | + buildImage.inside("-u root") { |
| 170 | + build(version, label, imageName) |
| 171 | + } |
| 172 | + } |
| 173 | + } |
| 174 | + } |
| 175 | + } else { |
| 176 | + def combinedName = "${label}-${version}" |
| 177 | + builders[combinedName] = { |
| 178 | + node(label) { |
| 179 | + stage(combinedName) { |
| 180 | + build(version, label, "") |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | +} |
| 187 | + |
| 188 | +parallel builders |
0 commit comments