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

Initial take on postgis module #1

Merged
merged 10 commits into from
Sep 19, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Tests

on:
push:
branches:
- main
- ci*
pull_request:
workflow_dispatch:
inputs: {}

jobs:
test:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
edgedb-version: [nightly]
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
submodules: true

- name: Install EdgeDB
uses: edgedb/setup-edgedb@v1
with:
server-version: ${{ matrix.edgedb-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Find the edgedb directory
run: |
echo EDBDIR=$(dirname $(which edgedb-server)) >> $GITHUB_ENV

- name: Register deb-src repositories
run: |
sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
sudo apt-get update

# There is some sort of weird github postgres installed that is
# causing problems with doing the build-dep installation, so blow
# it away first.
- name: Remove initially installed Postgres
run: |
sudo apt-get remove $(dpkg --get-selections | grep postgres | cut -f1)

- name: Install PostGIS build deps
run: |
sudo apt-get build-dep --ignore-missing postgis

- name: Install Postgres
run: |
sudo apt-get install postgresql-16 postgresql-server-dev-16

- name: Query pg_config sigh
run: |
/usr/bin/pg_config

- name: Build extension package
run: |
make -j8 PYTHON=$EDBDIR/python3 EDBFLAGS=--no-devmode PG_CONFIG=/usr/bin/pg_config
unzip -l postgis--3.4.2.zip

- name: Install extension package
run: |
$EDBDIR/edgedb-load-ext postgis--*.zip
# XXX: HACK: work around a bug in load-ext and copy the files
# to the right directory
# mv $($EDBDIR/pg_config --libdir)/{postgis*.so,address_standardizer-3.so} $($EDBDIR/pg_config --pkglibdir)

- name: Test
run: |
EDGEDB_DEBUG_SERVER=1 $EDBDIR/python3 -m edb.tools --no-devmode test -v -j1 tests/test_edgeql_postgis.py
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
build
postgis--*.zip
*.pyc
__pycache__
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "postgis"]
path = postgis
url = https://github.com/postgis/postgis.git
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions LICENSE-postgis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
PostGIS Licensing
==================

This file attempts to include all licenses that apply within the PostGIS
source tree, in particular any that are supposed to be exposed to the end
user for credit requirements for instance.

PostGIS General
----------------

In general PostGIS may be distributed and/or modified under the conditions
of the GNU General Public License, either version 2 or (at your option) any
later version. Please refer to the COPYING file for details.

PostGIS has dependencies on other libraries which are not under GPL and
that are commonly distributed with PostGIS core libraries. In general
these are dynamically linked libraries. Libraries are as follows:

Proj4 - https://proj.org -- X/MIT License
GEOS - https://libgeos.org -- LGPL License
LibXML - https://xmlsoft.org/ -- X/MIT License
GDAL - https://gdal.org/ -- X/MIT Style License
SFCGAL -- https://oslandia.gitlab.io/SFCGAL/ -- GPL/V2+
SFCGAL relies on CGAL https://www.cgal.org/ -- GPL and LGPLV3

Source files included with PostGIS not under GPL
------------------------------------------------

-- The following loader/dumper files are derivative works or direct ports
of ShapeLib which is under an X/MIT License: loader/dbfopen, safileio.*,
shapefil.h, shpopen.c (copyrighted by Frank Warmerdam and Even Rouault).

-- loader/getopt.* are under AT&T public domain (Copyright (c) 1984, 1985 AT&T).

-- Doc/xsl files
These are under a BSD-3-Clause license - refer to doc/xsl/LICENSE file

-- liblwgeom/lookup3.c is released under Public Domain by Bob Jenkins, May 2006.

-- deps/ryu (see LICENSE in folder) is released under the Apache 2.0 license;
alternatively, in can be used under the Boost 1.0 license. Copyrighted by Ulf
Adams and contributors.

-- deps/uthash (see LICENSE in folder) is released under a simplified BSD
license. Copyright (c) 2005-2018, Troy D. Hanson.

-- deps/wagyu (see LICENSE.README in folder) includes code released under the
ISC license (copyrighted by Mapbox) and the Boost Software License (copyrighted
by Angus Johnson and Mapbox). Copyright for "almost_equal.hpp" file is held by
Google Inc and its license is listed at the top of that file.

The documentation for PostGIS is under a creative commons share-alike
3.0 license. http://creativecommons.org/licenses/by-sa/3.0/

Data used in documentation falls in one of the following categories
- Many of the examples in the topology and tiger geocoder section utilize
data from US Census Tiger data 2010
https://www.census.gov/geo/www/tiger/tgrshp2010/tgrshp2010.html
- data or snapshots generated by community
- many images autogenerated by PostGIS documentation generator (which
utilizes ImageMagick) as described
http://trac.osgeo.org/postgis/wiki/DevWikiDocNewFeature
- PostGIS raster output functions such as the ST_AsPNG etc.
- raster/vector data from MassGIS: http://www.mass.gov/mgis/laylist.htm
4 changes: 4 additions & 0 deletions MANIFEST.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "postgis"
version = "3.4.2"
files = ["postgis.edgeql"]
postgres_files = "pg"
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Configurable parts
SQL_MODULE := postgis
EXTRA_FILES := LICENSE LICENSE-postgis.txt NOTICE

CUSTOM_SQL_BUILD := 1

### Boilerplate
PYTHON := python3
EDB := $(PYTHON) -m edb.tools $(EDBFLAGS)
MKS := $(shell $(EDB) config --make-include)
MKS := exts.mk
include $(MKS)
### End Boilerplate

$(SQL_STAMP): MANIFEST.toml postgis/NEWS Makefile
cd postgis && sh autogen.sh
cd postgis && ./configure "--with-pgconfig=$(PG_CONFIG)" --without-raster
$(MAKE) -C postgis
$(MAKE) -C postgis comments
$(MAKE) -C postgis DESTDIR=$(PWD)/build/out PG_CONFIG=$(PG_DIR)/bin/pg_config install
touch $(SQL_STAMP)
6 changes: 6 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
edgedb-postgis is Copyright 2023-present EdgeDB Inc.
It is licensed under the GNU General Public License, version 2.0

PostGIS is also licensed GNU General Public License, version 2.0.
More information about its license and its dependencies are available
in LICENSE-postgis.txt.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# edgedb-postgis
# edgedb-postgis

Currently ``make`` and the ``gen_ext_postgis.py`` script should be run
from inside an edgedb development venv.

To build, install, and test into a dev env:
- ``make``
- ``edb load-ext postgis--3.4.2.zip``
- ``edb test tests/test_edgeql_postgis.py``
47 changes: 47 additions & 0 deletions exts.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
EXT_NAME := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["name"])')
EXT_VERSION := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["version"])')
EDGEQL_SRCS := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(" ".join(f["files"]))')
SQL_DIR := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["postgres_files"])')

#

EXT_FNAME := $(EXT_NAME)--$(EXT_VERSION)

PG_CONFIG := $(shell $(EDB) config --pg-config)
PG_DIR := $(shell dirname $(shell dirname $(PG_CONFIG)))

rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
SQL_DEPS := $(call rwildcard,$(SQL_MODULE),*.c *.h *.sql *.control Makefile)

SQL_STAMP := build/out/.sql_stamp

ifneq ($(strip $(CUSTOM_SQL_BUILD)),1)

$(SQL_STAMP): MANIFEST.toml $(SQL_DEPS) $(EXTRA_DEPS) Makefile
$(MAKE) -C $(SQL_MODULE) DESTDIR=$(PWD)/build/out PG_CONFIG=$(PG_DIR)/bin/pg_config install
touch $(SQL_STAMP)
endif


$(EXT_FNAME).zip: MANIFEST.toml $(EDGEQL_SRCS) $(EXTRA_FILES) $(SQL_STAMP) Makefile
rm -rf build/$(EXT_FNAME)
mkdir build/$(EXT_FNAME)

rm -rf build/$(SQL_DIR)
mkdir build/$(SQL_DIR)

cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --pkglibdir) build/$(SQL_DIR)/lib
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --sharedir) build/$(SQL_DIR)/share

cp -r build/$(SQL_DIR) build/$(EXT_FNAME)/$(SQL_DIR)
cp $(EDGEQL_SRCS) build/$(EXT_FNAME)
if [ -n "$(EXTRA_FILES)" ]; then cp $(EXTRA_FILES) build/$(EXT_FNAME); fi
cp MANIFEST.toml build/$(EXT_FNAME)

rm -f $(EXT_FNAME).zip
cd build/$(EXT_FNAME)/ && zip -r ../../$(EXT_FNAME).zip *

clean:
rm -rf build $(EXT_FNAME).zip

.DEFAULT_GOAL := $(EXT_FNAME).zip
1 change: 1 addition & 0 deletions postgis
Submodule postgis added at c19ce5
Loading
Loading