Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Travis and attempt to set up Appveyor #13

Merged
merged 28 commits into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 27 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
dist: xenial
language: python
python:
- "3.5"
- "3.6"
- "3.7"
language: minimal

addons:
apt:
packages:
- libgeos-dev
matrix:
include:
- os: linux # 2015
env: DEPS="python=3.5 numpy=1.10 geos=3.5"
- os: linux # 2017
env: DEPS="python=3.6 numpy=1.13 geos=3.6"
- os: linux # now
env: DEPS="python=3.7 numpy geos"
- os: osx
env: DEPS="python=3.7 numpy geos"

before_install:
- pip install numpy
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
fi;

install:
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda:$HOME/miniconda/bin:$PATH"
- source $HOME/miniconda/etc/profile.d/conda.sh
- hash -r;
- conda update --yes conda;
- conda config --set changeps1 no --set restore_free_channel true;
- conda create -n testenv --yes pytest $DEPS;
- conda activate testenv;
- conda --version ; python --version ; pip --version;
- python setup.py build_ext --inplace
- pip install .[test]
- pip install . --no-deps

script: pytest --black
script: pytest
15 changes: 13 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
======
PyGEOS
======
[![build status](https://travis-ci.org/caspervdw/pygeos.svg?branch=master)](https://travis-ci.org/caspervdw/pygeos)

.. Travis CI status — https://travis-ci.org

.. image:: https://travis-ci.org/caspervdw/pygeos.svg?branch=master
:alt: Travis CI status
:target: https://travis-ci.org/caspervdw/pygeos

.. Appveyor CI status — https://ci.appveyor.com

.. image:: https://ci.appveyor.com/api/projects/status/yx6nmovs0wq8eg9n?svg=true
:alt: Appveyor CI status
:target: https://ci.appveyor.com/project/caspervdw/pygeos

This is a C/Python library that wraps geometry functions in GEOS in numpy ufuncs.
This project is still in a mock-up phase: the API will most likely change.
Expand Down Expand Up @@ -82,7 +93,7 @@ Compute the area of all possible intersections of two lists of polygons:
Installation
------------

Pygeos uses shapely's installing scripts. If you have libgeos at a standard
Pygeos uses shapely's installing scripts. If you have libgeos >= 3.5 at a standard
location, the following should work::

$ pip install pygeos
Expand Down
39 changes: 39 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
environment:
matrix:
- PYTHON: "C:\\Miniconda3"
DEPS: "numpy geos"

- PYTHON: "C:\\Miniconda3-x64"
DEPS: "numpy geos"

init:
- "ECHO %PYTHON% %PYTHON_VERSION%"

install:
# If there is a newer build queued for the same PR, cancel this one.
# The AppVeyor 'rollout builds' option is supposed to serve the same
# purpose but it is problematic because it tends to cancel builds pushed
# directly to master instead of just PR builds (or the converse).
# credits: JuliaLang developers.
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }

# Prepend to the PATH of this build
- "set PATH=%PYTHON%;%PYTHON%\\Scripts;%CONDA_ROOT%\\Library\\bin;%PATH%"

# Install dependencies
- conda update --yes conda
- conda create -n testenv --yes %DEPS% pytest
- activate testenv


build: false

before_test:
- "set GEOS_LIBRARY_PATH=%CONDA_PREFIX%\\Library\\bin\\geos_c.dll"
- "%CMD_IN_ENV% python setup.py build_ext --inplace"

test_script:
- "%CMD_IN_ENV% pytest"
7 changes: 7 additions & 0 deletions geosconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ def _geos_version():
geos_version = tuple(int(x) for x in res[0])
capi_version = tuple(int(x) for x in res[1])

if geos_version[0] < 3 or geos_version[1] < 5:
raise ValueError(
"PyGEOS requires GEOS version 3.5 or later, {} was found".format(
geos_version_string
)
)

return geos_version_string, geos_version, capi_version


Expand Down
3 changes: 2 additions & 1 deletion pygeos/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def box(x1, y1, x2, y2):
"""
x1, y1, x2, y2 = np.broadcast_arrays(x1, y1, x2, y2)
rings = np.array(((x2, y1), (x2, y2), (x1, y2), (x1, y1)))
rings = np.moveaxis(rings, (0, 1), (-2, -1))
# bring first two axes to the last two positions
rings = rings.transpose(list(range(2, rings.ndim)) + [0, 1])
return polygons(rings)


Expand Down
21 changes: 17 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import os
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
import geosconfig
import numpy

# https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py/21621689#21621689
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy

self.include_dirs.append(numpy.get_include())


module_ufuncs = Extension(
"pygeos.ufuncs",
sources=["src/ufuncs.c"],
include_dirs=geosconfig.include_dirs + [numpy.get_include()],
include_dirs=geosconfig.include_dirs,
library_dirs=geosconfig.library_dirs,
libraries=geosconfig.libraries,
extra_link_args=geosconfig.extra_link_args,
Expand All @@ -27,8 +38,9 @@
author="Casper van der Wel",
license="BSD 3-Clause",
packages=["pygeos"],
install_requires=["numpy"],
extras_require={"test": ["pytest", "pytest-black"]},
setup_requires=["numpy"],
install_requires=["numpy>=1.10"],
extras_require={"test": ["pytest"]},
python_requires=">=3",
include_package_data=True,
ext_modules=[module_ufuncs],
Expand All @@ -39,4 +51,5 @@
"Topic :: Scientific/Engineering :: GIS",
"Operating System :: Unix",
],
cmdclass={"build_ext": build_ext},
)