Skip to content

Commit fc423af

Browse files
committed
python 3.10
1 parent ddadb6b commit fc423af

File tree

9 files changed

+211
-158
lines changed

9 files changed

+211
-158
lines changed

.github/scripts/build-linux.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
#!/bin/bash
22
set -e -x
33

4-
bash --version
5-
64
cd /io
75

86
source .github/scripts/retry.sh
97

108
# List python versions
119
ls /opt/python
1210

13-
if [ $PYTHON_VERSION == "3.5" ]; then
14-
PYBIN="/opt/python/cp35-cp35m/bin"
15-
elif [ $PYTHON_VERSION == "3.6" ]; then
11+
if [ $PYTHON_VERSION == "3.6" ]; then
1612
PYBIN="/opt/python/cp36-cp36m/bin"
1713
elif [ $PYTHON_VERSION == "3.7" ]; then
1814
PYBIN="/opt/python/cp37-cp37m/bin"
1915
elif [ $PYTHON_VERSION == "3.8" ]; then
2016
PYBIN="/opt/python/cp38-cp38/bin"
2117
elif [ $PYTHON_VERSION == "3.9" ]; then
2218
PYBIN="/opt/python/cp39-cp39/bin"
19+
elif [ $PYTHON_VERSION == "3.10" ]; then
20+
PYBIN="/opt/python/cp310-cp310/bin"
2321
else
2422
echo "Unsupported Python version $PYTHON_VERSION"
2523
exit 1
2624
fi
2725

28-
# Install build tools
29-
retry yum install -y cmake
30-
3126
# Install liblensfun
3227
pushd external/lensfun
3328
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off -DINSTALL_HELPER_SCRIPTS=off .
@@ -61,7 +56,7 @@ retry ${PYBIN}/pip install -r dev-requirements.txt
6156
retry ${PYBIN}/pip install -U numpy # scipy should trigger an update, but that doesn't happen
6257

6358
pushd $HOME
64-
${PYBIN}/nosetests --verbosity=3 --nocapture /io/test
59+
${PYBIN}/pytest --verbosity=3 -s /io/test
6560
popd
6661

6762
# Move wheel to dist/ folder for easier deployment

.github/scripts/build-macos.sh

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -e -x
33

44
source .github/scripts/retry.sh
55

6+
CHECK_SHA256=.github/scripts/check_sha256.sh
7+
68
brew install pkg-config meson
79

810
# General note:
@@ -16,17 +18,6 @@ export MACOSX_DEPLOYMENT_TARGET=$MACOS_MIN_VERSION
1618
# The Python variant to install, see exception below.
1719
export PYTHON_INSTALLER_MACOS_VERSION=$MACOS_MIN_VERSION
1820

19-
# Work-around issue building on newer XCode versions.
20-
# https://github.com/pandas-dev/pandas/issues/23424#issuecomment-446393981
21-
if [ $PYTHON_VERSION == "3.5" ]; then
22-
# No 10.9 installer available, use 10.6.
23-
# The resulting wheel platform tags still have 10.6 (=target of Python itself),
24-
# even though technically the wheel should only be run on 10.9 upwards.
25-
# This is fixed manually below by renaming the wheel.
26-
# See https://github.com/pypa/wheel/issues/312.
27-
export PYTHON_INSTALLER_MACOS_VERSION=10.6
28-
fi
29-
3021
# Install Python
3122
# Note: The GitHub Actions supplied Python versions are not used
3223
# as they are built without MACOSX_DEPLOYMENT_TARGET/-mmacosx-version-min
@@ -57,19 +48,24 @@ pip freeze
5748
# See https://discourse.brew.sh/t/it-is-possible-to-build-packages-that-are-compatible-with-older-macos-versions/4421
5849

5950
LIB_INSTALL_PREFIX=$(pwd)/external/libs
51+
export CMAKE_PREFIX_PATH=$LIB_INSTALL_PREFIX
6052
export PKG_CONFIG_PATH=$LIB_INSTALL_PREFIX/lib/pkgconfig
6153
export LIBRARY_PATH=$LIB_INSTALL_PREFIX/lib
6254
export PATH=$LIB_INSTALL_PREFIX/bin:$PATH
6355

6456
# Install libffi (glib dependency)
65-
curl -L --retry 3 https://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz | tar xz
57+
curl -L --retry 3 -o libffi.tar.gz https://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz
58+
$CHECK_SHA256 libffi.tar.gz d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37
59+
tar xzf libffi.tar.gz
6660
pushd libffi-3.2.1
6761
./configure --prefix=$LIB_INSTALL_PREFIX --disable-debug
6862
make install -j
6963
popd
7064

7165
# Install gettext (glib dependency)
72-
curl -L --retry 3 https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.xz | tar xz
66+
curl -L --retry 3 -o gettext.tar.xz https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.xz
67+
$CHECK_SHA256 gettext.tar.xz 53f02fbbec9e798b0faaf7c73272f83608e835c6288dd58be6c9bb54624a3800
68+
tar xzf gettext.tar.xz
7369
pushd gettext-0.20.1
7470
./configure --prefix=$LIB_INSTALL_PREFIX \
7571
--disable-debug \
@@ -80,12 +76,13 @@ make install
8076
popd
8177

8278
# Install glib (lensfun dependency)
83-
curl -L --retry 3 https://download.gnome.org/sources/glib/2.69/glib-2.69.2.tar.xz | tar xz
79+
curl -L --retry 3 -o glib.tar.xz https://download.gnome.org/sources/glib/2.69/glib-2.69.2.tar.xz
80+
$CHECK_SHA256 glib.tar.xz a62249e35a8635175a697b3215f1df2b89e0fbb4adb520dcbe21a3ae1ebb8882
81+
tar xzf glib.tar.xz
8482
pushd glib-2.69.2
8583
mkdir build
8684
cd build
8785
meson --prefix=$LIB_INSTALL_PREFIX \
88-
-Dinternal_pcre=true \
8986
-Dselinux=disabled \
9087
-Ddtrace=false \
9188
-Dman=false \
@@ -105,15 +102,8 @@ export LDFLAGS=$CFLAGS
105102
export ARCHFLAGS=$CFLAGS
106103

107104
# Build wheel
108-
export CMAKE_PREFIX_PATH=$LIB_INSTALL_PREFIX
109105
python setup.py bdist_wheel
110106

111-
# Fix wheel platform tag, see above for details.
112-
if [ $PYTHON_VERSION == "3.5" ]; then
113-
filename=$(ls dist/*.whl)
114-
mv -v "$filename" "${filename/macosx_10_6_intel/macosx_10_9_x86_64}"
115-
fi
116-
117107
# List direct and indirect library dependencies
118108
mkdir tmp_wheel
119109
pushd tmp_wheel
@@ -155,5 +145,5 @@ retry pip install -r dev-requirements.txt
155145
rm -rf $LIB_INSTALL_PREFIX
156146
mkdir tmp_for_test
157147
pushd tmp_for_test
158-
nosetests --verbosity=3 --nocapture ../test
148+
pytest --verbosity=3 -s ../test
159149
popd

.github/scripts/build-windows.ps1

Lines changed: 96 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
$ErrorActionPreference = 'Stop'
22

3-
function not-exist { -not (Test-Path $args) }
4-
Set-Alias !exists not-exist -Option "Constant, AllScope"
5-
Set-Alias exists Test-Path -Option "Constant, AllScope"
6-
73
function exec {
84
[CmdletBinding()]
95
param([Parameter(Position=0,Mandatory=1)][scriptblock]$cmd)
@@ -17,52 +13,84 @@ function exec {
1713
}
1814
}
1915

20-
function Init-VS {
16+
function Initialize-Python {
17+
if ($env:USE_CONDA -eq 1) {
18+
$env:CONDA_ROOT = $pwd.Path + "\external\miniconda_$env:PYTHON_ARCH"
19+
& .\.github\scripts\install-miniconda.ps1
20+
& $env:CONDA_ROOT\shell\condabin\conda-hook.ps1
21+
exec { conda update --yes -n base -c defaults conda }
22+
}
23+
# Check Python version/arch
24+
exec { python -c "import platform; assert platform.python_version().startswith('$env:PYTHON_VERSION')" }
25+
exec { python -c "import struct; assert struct.calcsize('P') * 8 == $env:PYTHON_ARCH" }
26+
}
27+
28+
function Create-VEnv {
29+
[CmdletBinding()]
30+
param([Parameter(Position=0,Mandatory=1)][string]$name)
31+
if ($env:USE_CONDA -eq 1) {
32+
exec { conda create --yes --name $name -c defaults --strict-channel-priority python=$env:PYTHON_VERSION --force }
33+
} else {
34+
exec { python -m venv env\$name }
35+
}
36+
}
37+
38+
function Enter-VEnv {
39+
[CmdletBinding()]
40+
param([Parameter(Position=0,Mandatory=1)][string]$name)
41+
if ($env:USE_CONDA -eq 1) {
42+
conda activate $name
43+
} else {
44+
& .\env\$name\scripts\activate
45+
}
46+
}
47+
48+
function Create-And-Enter-VEnv {
49+
[CmdletBinding()]
50+
param([Parameter(Position=0,Mandatory=1)][string]$name)
51+
Create-VEnv $name
52+
Enter-VEnv $name
53+
}
54+
55+
function Exit-VEnv {
56+
if ($env:USE_CONDA -eq 1) {
57+
conda deactivate
58+
} else {
59+
deactivate
60+
}
61+
}
62+
63+
function Initialize-VS {
2164
# https://wiki.python.org/moin/WindowsCompilers
2265
# setuptools automatically selects the right compiler for building
2366
# the extension module. The following is mostly for building any
24-
# dependencies like liblensfun.
67+
# native dependencies, here via CMake.
2568
# https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line
2669
# https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017
2770

28-
$VS2017_ROOT = "C:\Program Files (x86)\Microsoft Visual Studio\2017"
29-
$VS2019_ROOT = "C:\Program Files (x86)\Microsoft Visual Studio\2019"
71+
$VS_ROOT = "C:\Program Files (x86)\Microsoft Visual Studio"
72+
$VS_VERSIONS = @("2017", "2019")
73+
$VS_EDITIONS = @("Enterprise", "Professional", "Community")
74+
$VS_INIT_CMD_SUFFIX = "Common7\Tools\vsdevcmd.bat"
3075

3176
$VS_ARCH = if ($env:PYTHON_ARCH -eq '32') { 'x86' } else { 'x64' }
32-
33-
$PYTHON_VERSION_TUPLE = $env:PYTHON_VERSION.split('.')
34-
$PYTHON_VERSION_MAJOR = $PYTHON_VERSION_TUPLE[0]
35-
$PYTHON_VERSION_MINOR = $PYTHON_VERSION_TUPLE[1]
36-
37-
if ($PYTHON_VERSION_MAJOR -eq '3') {
38-
if ($PYTHON_VERSION_MINOR -le '4') {
39-
throw ("Python <= 3.4 unsupported: $env:PYTHON_VERSION")
40-
}
41-
if (exists $VS2017_ROOT) {
42-
$VS_VERSION = "2017"
43-
if (exists "$VS2017_ROOT\Enterprise") {
44-
$VS_ROOT = "$VS2017_ROOT\Enterprise"
45-
} else {
46-
$VS_ROOT = "$VS2017_ROOT\Community"
77+
$VS_INIT_ARGS = "-arch=$VS_ARCH -no_logo"
78+
79+
$found = $false
80+
:outer foreach ($version in $VS_VERSIONS) {
81+
foreach ($edition in $VS_EDITIONS) {
82+
$VS_INIT_CMD = "$VS_ROOT\$version\$edition\$VS_INIT_CMD_SUFFIX"
83+
if (Test-Path $VS_INIT_CMD) {
84+
$found = $true
85+
break outer
4786
}
48-
$VS_INIT_CMD = "$VS_ROOT\Common7\Tools\vsdevcmd.bat"
49-
$VS_INIT_ARGS = "-arch=$VS_ARCH -no_logo"
50-
} elseif (exists $VS2019_ROOT) {
51-
$VS_VERSION = "2019"
52-
if (exists "$VS2019_ROOT\Enterprise") {
53-
$VS_ROOT = "$VS2019_ROOT\Enterprise"
54-
} else {
55-
$VS_ROOT = "$VS2019_ROOT\Community"
56-
}
57-
$VS_INIT_CMD = "$VS_ROOT\Common7\Tools\vsdevcmd.bat"
58-
$VS_INIT_ARGS = "-arch=$VS_ARCH -no_logo"
59-
} else {
60-
throw ("No suitable Visual Studio installation found")
6187
}
62-
} else {
63-
throw ("Unsupported Python version: $PYTHON_VERSION_MAJOR")
6488
}
65-
Write-Host "Configuring VS$VS_VERSION for Python $env:PYTHON_VERSION on a $env:PYTHON_ARCH bit architecture"
89+
90+
if (!$found) {
91+
throw ("No suitable Visual Studio installation found")
92+
}
93+
6694
Write-Host "Executing: $VS_INIT_CMD $VS_INIT_ARGS"
6795

6896
# https://github.com/Microsoft/vswhere/wiki/Start-Developer-Command-Prompt
@@ -85,66 +113,44 @@ if (!$env:NUMPY_VERSION) {
85113
throw "NUMPY_VERSION env var missing"
86114
}
87115

88-
Init-VS
116+
Initialize-VS
117+
Initialize-Python
89118

90119
Get-ChildItem env:
91120

92-
$env:CONDA_ROOT = $pwd.Path + "\external\miniconda_$env:PYTHON_ARCH"
93-
& .\.github\scripts\install-miniconda.ps1
94-
95-
& $env:CONDA_ROOT\shell\condabin\conda-hook.ps1
96-
97-
exec { conda update --yes -n base -c defaults conda }
98121

99-
exec { conda create --yes --name pyenv_build python=$env:PYTHON_VERSION numpy=$env:NUMPY_VERSION cython --force }
100-
exec { conda activate pyenv_build }
101-
102-
# Check that we have the expected version and architecture for Python
103-
exec { python --version }
104-
exec { python -c "import struct; assert struct.calcsize('P') * 8 == $env:PYTHON_ARCH" }
105-
exec { python -c "import sys; print(sys.prefix)" }
106-
107-
# output what's installed
108-
exec { python -m pip freeze }
109-
110-
# Build the compiled extension.
111-
# -u disables output buffering which caused intermixing of lines
112-
# when the external tools were started
122+
# Build the wheel.
123+
Create-And-Enter-VEnv build
124+
exec { python -m pip install --upgrade pip wheel setuptools }
125+
exec { python -m pip install --only-binary :all: numpy==$env:NUMPY_VERSION cython }
113126
exec { python -u setup.py bdist_wheel }
127+
Exit-VEnv
114128

115-
# Necessary to avoid bug when switching to test env.
116-
exec { conda deactivate }
117-
118-
# Import test on a minimal environment
119-
# (to catch DLL issues)
120-
exec { conda create --yes --name pyenv_minimal python=$env:PYTHON_VERSION --force }
121-
exec { conda activate pyenv_minimal }
122-
123-
# Avoid using in-source package
124-
New-Item -Force -ItemType directory tmp_for_test | out-null
125-
cd tmp_for_test
126-
129+
# Install and import in an empty environment.
130+
# This is to catch DLL issues that may be hidden with dependencies.
131+
Create-And-Enter-VEnv import-test
127132
python -m pip uninstall -y lensfunpy
128-
ls ..\dist\*.whl | % { exec { python -m pip install $_ } }
129-
exec { python -c "import lensfunpy" }
133+
ls dist\*.whl | % { exec { python -m pip install $_ } }
130134

131-
# Necessary to avoid bug when switching to test env.
132-
exec { conda deactivate }
135+
# Avoid using in-source package during tests
136+
mkdir -f tmp_for_test | out-null
137+
pushd tmp_for_test
138+
exec { python -c "import lensfunpy" }
139+
popd
133140

134-
# Test
135-
exec { conda create --yes --name pyenv_test python=$env:PYTHON_VERSION numpy scipy --force }
136-
exec { conda activate pyenv_test }
141+
Exit-VEnv
137142

138-
# Check that we have the expected version and architecture for Python
139-
exec { python --version }
140-
exec { python -c "import struct; assert struct.calcsize('P') * 8 == $env:PYTHON_ARCH" }
141-
exec { python -c "import sys; print(sys.prefix)" }
143+
# Run test suite with all required and optional dependencies
144+
Create-And-Enter-VEnv testsuite
145+
exec { python -m pip install --only-binary :all: numpy scipy }
146+
python -m pip uninstall -y lensfunpy
147+
ls dist\*.whl | % { exec { python -m pip install $_ } }
148+
exec { python -m pip install -r dev-requirements.txt }
142149

143-
# output what's installed
144-
exec { python -m pip freeze }
150+
# Avoid using in-source package during tests
151+
mkdir -f tmp_for_test | out-null
152+
pushd tmp_for_test
153+
exec { pytest --verbosity=3 -s ../test }
154+
popd
145155

146-
python -m pip uninstall -y lensfunpy
147-
ls ..\dist\*.whl | % { exec { python -m pip install $_ } }
148-
exec { python -m pip install -r ..\dev-requirements.txt }
149-
exec { nosetests --verbosity=3 --nocapture ../test }
150-
cd ..
156+
Exit-VEnv

.github/scripts/check_sha256.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
path=$1
5+
expected=$2
6+
7+
if [ "$(uname)" == "Darwin" ]; then
8+
actual=$(shasum -a 256 "$path" | cut -d ' ' -f 1)
9+
elif [ "$(uname)" == "Linux" ]; then
10+
actual=$(sha256sum "$path" | cut -d ' ' -f 1)
11+
else
12+
echo "Unknown system: $(uname)"
13+
exit 1
14+
fi
15+
16+
if [ "$expected" != "$actual" ]; then
17+
echo "CHECKSUM MISMATCH: $path"
18+
echo "Expected: $expected"
19+
echo "Actual: $actual"
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)