Skip to content

Commit

Permalink
Add HoloViz build infrastructure (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Aug 15, 2020
1 parent 06667b8 commit 8f573fb
Show file tree
Hide file tree
Showing 35 changed files with 326 additions and 119 deletions.
123 changes: 104 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,105 @@
# TODO:
#
# * restore previous sections
language: python
python:
# We don't actually use the Travis Python, but this keeps it organized.
- "3.6"
- "3.7"
install:
- sudo apt-get update
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda create -q -n test-environment -c conda-forge python=$TRAVIS_PYTHON_VERSION pandas dask numba numpy pyarrow pytest hypothesis scipy shapely geopandas param hilbertcurve
- conda activate test-environment
- python setup.py install

script:
- pytest tests/

sudo: false
os:
- linux

dist: xenial

env:
global:
- CHANS_DEV="-c pyviz/label/dev"
- CHANS_REL="-c pyviz"
- LABELS_DEV="--label dev"
- LABELS_REL="--label dev --label main"
- PKG_TEST_PYTHON="--test-python=py36"
# conda build fills up travis /tmp (tmpfs)
- TMPDIR=$HOME/tmp
- PYPI="https://upload.pypi.org/legacy/"
- PYTHON_VERSION=3.6
- OPTS="-o tests -o examples"

# quick hack to determine what tag is (improvements welcomed)
# release: ^v(\d+|\.)*[^a-z]\d*$
# dev release: ^v(\d+|\.)*[a-z]\d*$

stages:
- test
- name: conda_dev_package
if: tag =~ ^v(\d+|\.)+([a-z]|rc)\d+$
- name: pip_dev_package
if: tag =~ ^v(\d+|\.)+([a-z]|rc)\d+$
- name: conda_package
if: tag =~ ^v(\d+|\.)+[^a-z]\d+$
- name: pip_package
if: tag =~ ^v(\d+|\.)+[^a-z]\d+$

jobs:
include:

########## DEVELOPER INSTALL ##########

- &default
stage: test
env: DESC="dev test_all"
before_install:
# install doit/pyctdev and use to install miniconda...
- pip install pyctdev && doit miniconda_install && pip uninstall -y doit pyctdev
- export PATH="$HOME/miniconda/bin:$PATH" && hash -r
- conda config --set always_yes True
# ...and now install doit/pyctdev into miniconda
- conda install -c pyviz "pyctdev>=0.5" && doit ecosystem_setup
install:
- doit env_create $CHANS_DEV --python=$PYTHON_VERSION --name=$PYTHON_VERSION
- source activate $PYTHON_VERSION
- doit develop_install $CHANS_DEV $OPTS
- pip install hilbertcurve
- doit env_capture
script:
- doit test_all
after_success: codecov

# test using python 3.7
- <<: *default
env: PYTHON_VERSION=3.7
script:
- doit test_all

########## END-USER PACKAGES ##########

## dev packages

- &pip_pkg
<<: *default
stage: pip_dev_package
env: PYPI=testpypi PYPIUSER=$TPPU PYPIPASS=$TPPP TRAVIS_NOCACHE=$TRAVIS_JOB_ID
install:
- doit env_create $CHANS_DEV --python=$PYTHON_VERSION
- source activate test-environment
- doit develop_install $CHANS_DEV -o tests
- doit pip_on_conda
- doit ecosystem=pip package_build --test-python=py36 --test-group=unit
script: doit ecosystem=pip package_upload -u $PYPIUSER -p $PYPIPASS --pypi ${PYPI}

- &conda_pkg
<<: *default
stage: conda_dev_package
env: DESC="" LABELS=$LABELS_DEV CHANS=$CHANS_DEV TRAVIS_NOCACHE=$TRAVIS_JOB_ID
install: doit package_build $CHANS $PKG_TEST_PYTHON --test-group=all
script: doit package_upload --token=$CONDA_UPLOAD_TOKEN $LABELS

## release packages

- <<: *pip_pkg
env: PYPI=pypi PYPIUSER=$PPU PYPIPASS=$PPP TRAVIS_NOCACHE=$TRAVIS_JOB_ID
stage: pip_package

- <<: *conda_pkg
stage: conda_package
env: DESC="" LABELS=$LABELS_REL CHANS=$CHANS_REL TRAVIS_NOCACHE=$TRAVIS_JOB_ID

notifications:
email: false
14 changes: 14 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
if "PYCTDEV_ECOSYSTEM" not in os.environ:
os.environ["PYCTDEV_ECOSYSTEM"] = "conda"

from pyctdev import * # noqa: api

def task_pip_on_conda():
"""Experimental: provide pip build env via conda"""
return {'actions':[
# some ecosystem=pip build tools must be installed with conda when using conda...
'conda install -y pip twine wheel',
# ..and some are only available via conda-forge
'conda install -y -c conda-forge tox virtualenv',
]}
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"param >=1.7.0",
"pyct >=0.4.4",
"setuptools >=30.3.0"
]
87 changes: 47 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,55 @@
import param

extras_require = {
'tests': [
'pytest',
'hypothesis',
'scipy',
'shapely',
'geopandas',
'hilbertcurve'
],
'examples': [
'geopandas',
'matplotlib',
'descartes',
'datashader',
'holoviews',
]
'tests': [
'pytest',
'pytest-cov',
'flake8',
'hypothesis',
'scipy',
'shapely',
'geopandas',
],
'examples': [
'geopandas',
'matplotlib',
'descartes',
'datashader',
'holoviews',
]
}

install_requires = [
'pandas>=0.25',
'dask>=2.0',
'numba',
'numpy',
'pyarrow>=0.15',
'param',
'fsspec',
'retrying',
'pandas>=0.25',
'dask[complete] >=2.0',
'numba',
'numpy',
'pyarrow>=0.15',
'param',
'fsspec',
'retrying',
]

setup(name='spatialpandas',
version=param.version.get_setup_version(
__file__, "spatialpandas", archive_commit="$Format:%h$"
),
description='Pandas extension arrays for spatial/geometric operations',
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url='https://github.com/holoviz/spatialpandas',
maintainer='Datashader developers',
maintainer_email='dev@datashader.org',
python_requires='>=3.6',
install_requires=install_requires,
extras_require=extras_require,
tests_require=extras_require['tests'],
license='BSD-2-Clause',
packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True)
setup_args = dict(
name='spatialpandas',
version=param.version.get_setup_version(
__file__, "spatialpandas", archive_commit="$Format:%h$"
),
description='Pandas extension arrays for spatial/geometric operations',
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url='https://github.com/holoviz/spatialpandas',
maintainer='Datashader developers',
maintainer_email='dev@datashader.org',
python_requires='>=3.6',
install_requires=install_requires,
extras_require=extras_require,
tests_require=extras_require['tests'],
license='BSD-2-Clause',
packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True
)

if __name__ == '__main__':
setup(**setup_args)

12 changes: 6 additions & 6 deletions spatialpandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import geometry, spatialindex, tools
from .geoseries import GeoSeries
from .geodataframe import GeoDataFrame
from .tools.sjoin import sjoin
from . import geometry, spatialindex, tools # noqa
from .geoseries import GeoSeries # noqa
from .geodataframe import GeoDataFrame # noqa
from .tools.sjoin import sjoin # noqa
import param as _param

try:
import dask.dataframe
import dask.dataframe # noqa
# Import to trigger registration of types with Dask
import spatialpandas.dask
import spatialpandas.dask # noqa
except ImportError:
# Dask dataframe not available
pass
Expand Down
1 change: 0 additions & 1 deletion spatialpandas/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def pack_partitions_to_parquet(
"""
from .io import read_parquet, read_parquet_dask
from .io.utils import validate_coerce_filesystem
from .io.parquet import _maybe_prepend_protocol

# Get fsspec filesystem object
filesystem = validate_coerce_filesystem(path, filesystem)
Expand Down
24 changes: 16 additions & 8 deletions spatialpandas/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from .polygon import Polygon, PolygonArray, PolygonDtype
from .multipolygon import MultiPolygon, MultiPolygonArray, MultiPolygonDtype
from .line import Line, LineArray, LineDtype
from .multiline import MultiLine, MultiLineArray, MultiLineDtype
from .multipoint import MultiPoint, MultiPointArray, MultiPointDtype
from .ring import Ring, RingArray, RingDtype
from .point import Point, PointArray, PointDtype
from .base import Geometry, GeometryArray, GeometryDtype, to_geometry_array
from .polygon import Polygon, PolygonArray, PolygonDtype # noqa
from .multipolygon import ( # noqa
MultiPolygon, MultiPolygonArray, MultiPolygonDtype
)
from .line import Line, LineArray, LineDtype # noqa
from .multiline import ( # noqa
MultiLine, MultiLineArray, MultiLineDtype
)
from .multipoint import ( # noqa
MultiPoint, MultiPointArray, MultiPointDtype
)
from .ring import Ring, RingArray, RingDtype # noqa
from .point import Point, PointArray, PointDtype # noqa
from .base import ( # noqa
Geometry, GeometryArray, GeometryDtype, to_geometry_array
)
1 change: 0 additions & 1 deletion spatialpandas/geometry/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ def take(self, indices, allow_fill=False, fill_value=None):
"Invalid index value for {typ} with allow_fill=True: "
"{idx}".format(
typ=self.__class__.__name__,
n=len(self),
idx=indices[invalid_mask][0]
)
)
Expand Down
4 changes: 3 additions & 1 deletion spatialpandas/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .parquet import read_parquet, read_parquet_dask, to_parquet, to_parquet_dask
from .parquet import ( # noqa
read_parquet, read_parquet_dask, to_parquet, to_parquet_dask
)
3 changes: 1 addition & 2 deletions spatialpandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

import pandas as pd
from dask import delayed
from dask.dataframe import (
from dask.dataframe import ( # noqa
to_parquet as dd_to_parquet, read_parquet as dd_read_parquet,
from_delayed, from_pandas,
)
from dask.dataframe.utils import make_meta, clear_known_categories
from dask.utils import natural_sort_key

from pandas.io.parquet import (
Expand Down
2 changes: 1 addition & 1 deletion spatialpandas/spatialindex/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .rtree import HilbertRtree
from .rtree import HilbertRtree # noqa
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import numpy as np

from hypothesis import given, example
from shapely import geometry as sg

from spatialpandas.geometry import (
Polygon, MultiPointArray, LineArray,
MultiLineArray, PolygonArray, MultiPolygonArray,
PointArray)
Polygon, MultiPointArray, LineArray, MultiLineArray, PolygonArray,
MultiPolygonArray, PointArray
)
from spatialpandas.geometry._algorithms.intersection import (
segments_intersect, point_intersects_polygon,
segment_intersects_point)
from tests.geometry.strategies import (
st_polygon, st_multipoint_array, st_bounds, st_line_array, st_multiline_array,
st_polygon_array, st_multipolygon_array, hyp_settings, coord, st_points,
st_point_array)
segment_intersects_point
)

from ..strategies import (
st_polygon, st_multipoint_array, st_bounds, st_line_array,
st_multiline_array, st_polygon_array, st_multipolygon_array,
hyp_settings, coord, st_points, st_point_array
)


@given(coord, coord, coord, coord, coord, coord)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy as np

from hypothesis import given
from spatialpandas.geometry import MultiPolygonArray, PolygonArray
from tests.geometry.strategies import (

from ..strategies import (
st_multipolygon_array, hyp_settings, st_polygon_array
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from shapely import geometry as sg

from spatialpandas.geometry._algorithms.orientation import triangle_orientation
from tests.geometry.strategies import hyp_settings, coord

from ..strategies import hyp_settings, coord


@given(coord, coord, coord, coord, coord, coord)
Expand Down
File renamed without changes.
Loading

0 comments on commit 8f573fb

Please sign in to comment.