Skip to content

Commit

Permalink
Revise AppVeyor setup for Windows (#819)
Browse files Browse the repository at this point in the history
* Revise AppVeyor setup for Windows

* Build GEOS version 3.8.0 using CMake/Ninja/Visual C++
* Build wheels for 8 combinations of x86/x64 and Py35/Py36/Py37/Py38
* Don't build wheels for Py27, as it's too difficult and a low priority
* Remove unused scripts from previous setup

* Arrange README.rst badges

* Align them horizontally
* Add AppVeyor build status
  • Loading branch information
mwtoews authored and sgillies committed Jan 20, 2020
1 parent 10d6ea9 commit 72e11ed
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 426 deletions.
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
Shapely
=======

.. image:: https://travis-ci.org/Toblerity/Shapely.svg?branch=master
|travis| |appveyor| |coveralls|

.. |travis| image:: https://travis-ci.org/Toblerity/Shapely.svg?branch=master
:target: https://travis-ci.org/Toblerity/Shapely

.. image:: https://coveralls.io/repos/github/Toblerity/Shapely/badge.svg?branch=master
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/Toblerity/Shapely?branch=master&svg=true
:target: https://ci.appveyor.com/project/frsci/shapely?branch=master

.. |coveralls| image:: https://coveralls.io/repos/github/Toblerity/Shapely/badge.svg?branch=master
:target: https://coveralls.io/github/Toblerity/Shapely?branch=master

Manipulation and analysis of geometric objects in the Cartesian plane.
Expand Down
199 changes: 92 additions & 107 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,122 +1,107 @@
# Based on appveyor.yml from https://github.com/PDAL/PDAL and https://github.com/ogrisel/python-appveyor-demo
#

image: Visual Studio 2017
platform: x64


environment:
global:
GEOSVERSION: "3.8.0"

matrix:
# - PYTHON: "C:\\Python27"
# ARCH: x86
# COMPILER: msvc90
# GEOSVERSION: "3.5.2"
# image: Visual Studio 2015
# - PYTHON: "C:\\Python27-x64"
# ARCH: x64
# COMPILER: msvc90
# GEOSVERSION: "3.5.2"
# image: Visual Studio 2015
- PYTHON: "C:\\Python35"
ARCH: x86
COMPILER: msvc2017
- PYTHON: "C:\\Python35-x64"
ARCH: x64
COMPILER: msvc2017
- PYTHON: "C:\\Python36"
ARCH: x86
COMPILER: msvc2017
- PYTHON: "C:\\Python36-x64"
ARCH: x64
COMPILER: msvc2017
- PYTHON: "C:\\Python37"
ARCH: x86
COMPILER: msvc2017
- PYTHON: "C:\\Python37-x64"
ARCH: x64
COMPILER: msvc2017
- PYTHON: "C:\\Python38"
ARCH: x86
COMPILER: msvc2017
- PYTHON: "C:\\Python38-x64"
ARCH: x64
COMPILER: msvc2017

global:
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
# /E:ON and /V:ON options are not enabled in the batch script interpreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\appveyor\\run_with_env.cmd"
GDAL_HOME: "C:\\gdal"

matrix:
- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.14"
PYTHON_ARCH: "64"
GDAL_VERSION: "2.3.0"
GIS_INTERNALS: "release-1911-x64-gdal-mapserver.zip"
GIS_INTERNALS_LIBS: "release-1911-x64-gdal-mapserver-libs.zip"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6.4"
PYTHON_ARCH: "64"
GDAL_VERSION: "2.3.0"
GIS_INTERNALS: "release-1911-x64-gdal-mapserver.zip"
GIS_INTERNALS_LIBS: "release-1911-x64-gdal-mapserver-libs.zip"

install:

- ECHO "Filesystem root:"
- ps: "ls \"C:/\""
build_script:
- set _INITPATH=%PATH%

- ECHO "Installed SDKs:"
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
- ps: 'Write-Host "Configuring PATH with $env:PYTHON" -ForegroundColor Magenta'
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%

# Install Python (from the official .msi of http://python.org) and pip when
# not already installed.
# - ps: if (-not(Test-Path($env:PYTHON))) { & ci\appveyor\install.ps1 }
- ps: 'Write-Host "Configuring MSVC compiler $env:COMPILER" -ForegroundColor Magenta'
- if %COMPILER%==msvc90 ( call "C:\Users\appveyor\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat" %ARCH% )
- if %COMPILER%==msvc2017 ( call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %ARCH% )

# Prepend newly installed Python to the PATH of this build (this cannot be
# done from inside the powershell script as it would require to restart
# the parent CMD process).
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "SET PYTHONPATH=%PYTHON%\\Lib\\site-packages;%PYTHONPATH%"
- ps: 'Write-Host "Cached dependency folder" -ForegroundColor Magenta'
- if not exist C:\projects\deps mkdir C:\projects\deps
- dir C:\projects\deps

# Check that we have the expected version and architecture for Python
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
- set GEOSINSTALL=C:\projects\deps\geos-%GEOSVERSION%-%COMPILER%-%ARCH%
- set CYTHONPF=C:\\projects\\deps\\geos-%GEOSVERSION%-%COMPILER%-%ARCH%
- ps: 'Write-Host "Checking GEOS build $env:GEOSINSTALL" -ForegroundColor Magenta'
- call c:\projects\shapely\ci\appveyor\build_geos.cmd

- ps: mkdir C:\build | out-null
- ps: mkdir C:\gdal | out-null

- curl http://download.gisinternals.com/sdk/downloads/%GIS_INTERNALS% --output gdalbin.zip
- 7z x gdalbin.zip -oC:\gdal
- curl http://download.gisinternals.com/sdk/downloads/%GIS_INTERNALS_LIBS% --output gdallibs.zip
- 7z x gdallibs.zip -oC:\gdal
- "SET PATH=C:\\gdal;C:\\gdal\\bin;C:\\gdal\\data;C:\\gdal\\bin\\gdal\\apps;%PATH%"
- "SET GDAL_DATA=C:\\gdal\\bin\\gdal-data"
- "SET PACKAGE_DATA=1"
# - ps: 'Push-AppveyorArtifact $env:GEOSINSTALL\bin\geos.dll'
# - ps: 'Push-AppveyorArtifact $env:GEOSINSTALL\bin\geos_c.dll'

- ECHO "Filesystem C:/GDAL:"
- ps: "ls \"C:/GDAL\""


- ps: 'Write-Host "Copying and checking geos_c.dll" -ForegroundColor Magenta'
- cd C:\projects\shapely
- dir
# Upgrade to the latest version of pip to avoid it displaying warnings
# about it being out of date.
# - "python -m pip install --disable-pip-version-check --user --upgrade pip"

- pip --version

# Install the build dependencies of the project. If some dependencies contain
# compiled extensions and are not provided as pre-built wheel packages,
# pip will build them from source using the MSVC compiler matching the
# target Python version and architecture
- "%CMD_IN_ENV% pip install -r requirements-dev.txt"


build_script:
# Build the compiled extension
- cmd: echo %PATH%

- cmd: echo %PYTHONPATH%

# copy gisinternal gdal librarys into .libs
- cmd: xcopy C:\gdal\bin\geos.dll shapely\DLLs\
- cmd: xcopy C:\gdal\bin\geos_c.dll shapely\DLLs\
- cmd: xcopy C:\gdal\bin\msvcp140.dll shapely\DLLs\
- cmd: xcopy C:\gdal\bin\vcruntime140.dll shapely\DLLs\
- cmd: xcopy C:\gdal\*.rtf shapely\DLLs\licenses\
- cmd: dir shapely\DLLs

# build shapely and create a wheel
- "%CMD_IN_ENV% python setup.py build_ext -IC:\\gdal\\include -lgeos_c -LC:\\gdal\\lib bdist_wheel"

# install the wheel
- ps: python -m pip install --upgrade pip
- ps: pip install --force-reinstall --ignore-installed (gci dist\*.whl | % { "$_" })

# ensure we are testing the wheel and packaged binaries
- ps: move shapely shapely.build
- ps: rm -r -fo C:\GDAL


test_script:
# Run the project tests
- cmd: SET

- ps: python -c "import shapely"

- "%CMD_IN_ENV% python -m pytest --cov shapely --cov-report term-missing"

matrix:
allow_failures:
- GDAL_VERSION: 2.4.0
- if %ARCH%==x86 ( set CPDIR=DLLs_x86_VC9 )
- if %ARCH%==x64 ( set CPDIR=DLLs_AMD64_VC9 )
- xcopy %GEOSINSTALL%\bin\geos*.dll %CPDIR%
- cd %CPDIR%
- dir
- dumpbin /dependents geos_c.dll
- dumpbin /dependents %PYTHON%\python.exe
- python -c "import sys; print('Python ' + sys.version)"
- python -c "import ctypes; print(ctypes.CDLL('./geos_c.dll'))"
- cd ..

- ps: 'Write-Host "Building wheel" -ForegroundColor Magenta'
- pip install -r requirements-dev.txt
- set GEOS_LIBRARY_PATH=%GEOSINSTALL%\bin\geos_c.dll
- set PATH=%GEOSINSTALL%\bin;%PATH%
- python setup.py build_ext -I%CYTHONPF%\\include -lgeos_c -L%CYTHONPF%\\lib bdist_wheel

- ps: 'Write-Host "Checking pip install in a new environment" -ForegroundColor Magenta'
- set PATH=%_INITPATH%
- set GEOS_LIBRARY_PATH=
- '%PYTHON%\python.exe -m venv C:\projects\test'
- call C:\projects\test\Scripts\activate.bat
- pip install -r requirements-dev.txt
- cd dist
- pip install --no-index --find-links . --no-cache-dir shapely
- python -c "import shapely; print(shapely.__version__)"
- python -c "from shapely.geos import geos_version_string; print(geos_version_string)"
- python -c "from shapely import speedups; assert speedups.enabled"

- ps: 'Write-Host "Running pytest" -ForegroundColor Magenta'
- xcopy ..\tests tests\
- pytest


cache:
- C:\projects\deps

artifacts:
- path: dist\*.whl
Expand Down
26 changes: 26 additions & 0 deletions ci/appveyor/build_geos.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
REM This script is called from appveyor.yml

if exist %GEOSINSTALL% (
echo Using cached %GEOSINSTALL%
) else (
echo Building %GEOSINSTALL%

cd C:\projects

curl -fsSO http://download.osgeo.org/geos/geos-%GEOSVERSION%.tar.bz2
7z x geos-%GEOSVERSION%.tar.bz2
7z x geos-%GEOSVERSION%.tar
cd geos-%GEOSVERSION%

pip install ninja
cmake --version

mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=%GEOSINSTALL% ..
cmake --build . --config Release -j 2
ctest . --config Release
cmake --install . --config Release
cd ..
)

Loading

0 comments on commit 72e11ed

Please sign in to comment.