Skip to content

add geos and shapely #131

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
shell: bash -l {0}
run: |
micromamba activate ci-env
python -m pip install git+https://github.com/emscripten-forge/empack@main --no-deps --ignore-installed
python -m pip install git+https://github.com/wolfv/empack@packso --no-deps --ignore-installed
python -m pip install git+https://github.com/DerThorsten/boa.git@postcb --no-deps --ignore-installed
python -m pip install git+https://github.com/DerThorsten/bitfurnace.git@emscripten_new --no-deps --ignore-installed

Expand Down
2 changes: 1 addition & 1 deletion conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ gst_plugins_base:
gdal:
- '3.4'
geos:
- 3.10.2
- 3.11.0
geotiff:
- '1.7'
gfal2:
Expand Down
13 changes: 13 additions & 0 deletions recipes/recipes_emscripten/geos/0001-compile-cpp-lib-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e758b5dc8..4d7f5150a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -254,7 +254,7 @@ check_library_exists(m pow "" HAVE_LIBM)
#-----------------------------------------------------------------------------
# Target geos: C++ API library
#-----------------------------------------------------------------------------
-add_library(geos "")
+add_library(geos STATIC "")
add_library(GEOS::geos ALIAS geos)
target_link_libraries(geos PUBLIC geos_cxx_flags PRIVATE $<BUILD_INTERFACE:ryu>)
# ryu is an object library, nothing is actually being linked here. The BUILD_INTERFACE
34 changes: 34 additions & 0 deletions recipes/recipes_emscripten/geos/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

mkdir -p build && cd build

# Force support for shared libraries
echo "set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)" > ${SRC_DIR}/SupportSharedLib.cmake

export LDFLAGS="$LDFLAGS -s SIDE_MODULE=1"

emcmake cmake ${CMAKE_ARGS} -GNinja \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=${PREFIX} \
-D CMAKE_INSTALL_LIBDIR=lib \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_TESTING=OFF \
-D BUILD_BENCHMARKS=OFF \
-D BUILD_DOCUMENTATION=OFF \
-D CMAKE_PROJECT_INCLUDE=SupportSharedLib.cmake \
${SRC_DIR}

ninja

if [[ "${CONDA_BUILD_CROSS_COMPILATION}" != "1" ]]; then
ctest --output-on-failure
fi

ninja install -j${CPU_COUNT}

# remove links
cp $(readlink -f $PREFIX/lib/libgeos_c.so) $PREFIX/lib/libgeos_c_tmp.so
mv $PREFIX/lib/libgeos_c_tmp.so $PREFIX/lib/libgeos_c.so

cp $(readlink -f $PREFIX/lib/libgeos.so) $PREFIX/lib/libgeos_tmp.so
mv $PREFIX/lib/libgeos_tmp.so $PREFIX/lib/libgeos.so
47 changes: 47 additions & 0 deletions recipes/recipes_emscripten/geos/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
context:
version: "3.11.0"

package:
name: geos
version: "{{ version }}"

source:
url: https://download.osgeo.org/geos/geos-{{ version }}.tar.bz2
sha256: 79ab8cabf4aa8604d161557b52e3e4d84575acdc0d08cb09ab3f7aaefa4d858a
patches:
- 0001-compile-cpp-lib-static.patch

build:
number: 0
run_exports:
# pretty poor backcompat. SO name changes each release.
# https://abi-laboratory.pro/tracker/timeline/geos/
- "{{ pin_subpackage('geos', max_pin='x.x.x') }}"

requirements:
build:
- cmake
- ninja
- "{{ compiler('c') }}"
- "{{ compiler('cxx') }}"

# test:
# commands:
# - geos-config --version # [not win]

about:
home: https://libgeos.org/
license: LGPL-2.1-only
license_file: COPYING
summary: Geometry Engine, Open Source
description: |
GEOS is a C++ library for performing operations on two-dimensional vector
geometries. It is primarily a port of the JTS Topology Suite Java library.
It provides many of the algorithms used by PostGIS, the Shapely package
for Python, the sf package for R, and others.
doc_url: https://libgeos.org/
dev_url: https://github.com/libgeos/geos

extra:
recipe-maintainers:
- wolfv
11 changes: 11 additions & 0 deletions recipes/recipes_emscripten/shapely/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

rm -rf shapely/speedups/_speedups.c
rm -rf shapely/vectorized/_vectorized.c

python -m cython shapely/speedups/_speedups.pyx
python -m cython shapely/vectorized/_vectorized.pyx

export GEOS_DIR=${PREFIX}

${PYTHON} -m pip install --no-deps --ignore-installed .
58 changes: 58 additions & 0 deletions recipes/recipes_emscripten/shapely/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
context:
version: "1.8.2"

package:
name: shapely
version: "{{ version.split('.post')[0] }}"

source:
url: https://pypi.io/packages/source/S/Shapely/Shapely-{{ version }}.tar.gz
sha256: 572af9d5006fd5e3213e37ee548912b0341fb26724d6dc8a4e3950c10197ebb6

build:
number: 0

requirements:
build:
- sel(build_platform != target_platform): python
- sel(build_platform != target_platform): cross-python_{{ target_platform }}
- sel(build_platform != target_platform): cython
- sel(build_platform != target_platform): numpy
- sel(build_platform != target_platform): geos
- "{{ compiler('c') }}"
host:
- python
- pip
# - cython
- numpy
- geos
run:
- python
- numpy
# - "{{ pin_compatible('numpy') }}"

# test:
# source_files:
# - tests
# requires:
# - pytest
# imports:
# - shapely
# - shapely.geometry
# - shapely.algorithms
# - shapely.examples
# - shapely.geos

about:
home: https://github.com/shapely/shapely
license: BSD-3-Clause
license_file: LICENSE.txt
summary: Python package for manipulation and analysis of geometric objects in the Cartesian plane

extra:
recipe-maintainers:
- wolfv
emscripten_tests:
python:
pytest_files:
- test_shapely.py
14 changes: 14 additions & 0 deletions recipes/recipes_emscripten/shapely/test_shapely.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def test_shapely():
from shapely.geometry import MultiLineString

coords = [((0, 0), (1, 1)), ((-1, 0), (1, 0))]
lines = MultiLineString(coords)
assert lines.area == 0.0
assert round(lines.length, 2) == 3.41


def test_shapely_geos():
import shapely.geos

assert shapely.geos.geos_version
assert shapely.geos.geos_version_string