Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a80c874
Update to 1.3
Diviloper Jul 27, 2025
b5269af
Add new header files
Diviloper Jul 27, 2025
130e636
Remove common config file
Diviloper Jul 27, 2025
5f202f2
Add MEOS spatial data csv to wheel
Diviloper Jul 28, 2025
95d9735
Update versioning patterns in build action
Diviloper Jul 29, 2025
f6c6c36
Update setup to only package MEOS data when PACKAGE_DATA env variable…
Diviloper Jul 29, 2025
14a84f5
Update test in build flow
Diviloper Jul 29, 2025
b69a4c6
Split test code
Diviloper Jul 29, 2025
60db068
Fix random crash when printing TGeogPoint timestamp by always passing…
Diviloper Jul 29, 2025
1e60373
Use explicit timezone in wheel test
Diviloper Jul 29, 2025
5464b9f
Try compiling a debug release
Diviloper Jul 30, 2025
c366e8e
Update pg version in linux wheel
Diviloper Jul 31, 2025
ad5e712
Update cibuildwheel version
Diviloper Jul 31, 2025
595cfd6
Use dnf instead of yum
Diviloper Jul 31, 2025
07687a1
Use json-c package from repo
Diviloper Jul 31, 2025
1990ab6
Disable python 3.14 builds
Diviloper Jul 31, 2025
54c5f13
Only call meos_initialize_timezone is one is provided
Diviloper Jul 31, 2025
9bf78c4
Sync
Diviloper Aug 1, 2025
9f45dc1
Only set local spatial ref system csv when it exists (wheel installat…
Diviloper Aug 1, 2025
a014429
Fix regex to allow spaces between function name and parameters
Diviloper Aug 1, 2025
f15b251
Update modifiers for tpoint functions and sync header
Diviloper Aug 1, 2025
b7f6bae
Add proper transformation between MEOS interpType and PyMEOS-CFFI Int…
Diviloper Aug 1, 2025
b9b0aba
Sync with MEOS
Diviloper Aug 6, 2025
540429b
Use proper postgres repository
Diviloper Aug 6, 2025
ff66784
Update output parameter name for value_split functions
Diviloper Aug 8, 2025
89d1c6d
Add ruff as dev dependency
Diviloper Aug 8, 2025
4284d8c
Add ruff check workflow
Diviloper Aug 8, 2025
0cbc71d
Update comments in build workflow
Diviloper Aug 14, 2025
0d45d68
Add ruff config
Diviloper Aug 14, 2025
7f9f152
Format properly and update to modern typing (python 3.10)
Diviloper Aug 14, 2025
137f452
Remove builds for 3.8 and 3.9 and bring back macOS 13
Diviloper Aug 14, 2025
f034a03
Use master branch if no tag is found
Diviloper Aug 14, 2025
0515762
Update pyproject.toml
Diviloper Aug 14, 2025
4e4b60f
Update cdata typing (_ffi.CData)
Diviloper Aug 14, 2025
f259d96
Remove the crashing line since it can't be reproduced to be properly …
Diviloper Aug 14, 2025
5d810d2
Use all supported versions again
Diviloper Aug 14, 2025
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
63 changes: 32 additions & 31 deletions .github/workflows/build_pymeos_cffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
is_rc: ${{ steps.check_rc.outputs.is_rc }}
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
branch: ${{ steps.check_branch.outputs.branch }}
meos_branch: ${{ steps.check_branch.outputs.meos_branch }}
version: ${{ steps.check_version.outputs.version }}

steps:
Expand All @@ -29,7 +30,7 @@ jobs:
run: |
VERSION=${GITHUB_REF#refs/tags/}

if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-alpha ]]; then
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+a[0-9]+ ]]; then
echo "Releasing an alpha version."
echo "is_alpha=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -41,7 +42,7 @@ jobs:
run: |
VERSION=${GITHUB_REF#refs/tags/}

if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]]; then
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+b[0-9]+ ]]; then
echo "Releasing a beta version."
echo "is_beta=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -53,7 +54,7 @@ jobs:
run: |
VERSION=${GITHUB_REF#refs/tags/}

if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+ ]]; then
echo "Releasing an rc version."
echo "is_rc=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -68,7 +69,7 @@ jobs:
is_rc=${{ steps.check_rc.outputs.is_rc }}

if [ "$is_alpha" == "true" ] || [ "$is_beta" == "true" ] || [ "$is_rc" == "true" ]; then
echo "Releasing an prerelease version."
echo "Releasing a prerelease version."
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
Expand All @@ -90,8 +91,19 @@ jobs:
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "Branch is $branch."
if [ -z "$branch" ]; then
branch="master"
echo "Branch not found. Using master."
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
exists=$(git ls-remote https://github.com/MobilityDB/MobilityDB $branch)
meos_branch="master"
if [ -n "$exists" ]; then
meos_branch=$branch
fi
echo "MEOS branch is $meos_branch."
echo "meos_branch=$meos_branch" >> $GITHUB_OUTPUT

- name: Check version
id: check_version
Expand All @@ -112,7 +124,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: "3.10"
cache: "pip"

- name: Setup pip
Expand All @@ -137,8 +149,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ ubuntu-latest, macos-13, macos-14 ]
os: [ ubuntu-latest, macos-14 ]
os: [ ubuntu-latest, macos-13, macos-14 ]
include:
- ld_prefix: "/usr/local"
- os: macos-14
Expand All @@ -156,11 +167,7 @@ jobs:

- name: Update brew
if: matrix.os == 'macos-13'
# Necessary to avoid issue with macOS runners. See
# https://github.com/actions/runner-images/issues/4020
run: |
brew reinstall python@3.12 || brew link --overwrite python@3.12
brew reinstall python@3.11 || brew link --overwrite python@3.11
brew update

- name: Get PROJ version
Expand All @@ -174,7 +181,7 @@ jobs:
- name: Install MEOS
if: runner.os == 'macOS'
run: |
git clone --depth 1 --branch ${{ needs.checks.outputs.branch }} https://github.com/MobilityDB/MobilityDB
git clone --depth 1 https://github.com/MobilityDB/MobilityDB
mkdir MobilityDB/build
cd MobilityDB/build
export MACOSX_DEPLOYMENT_TARGET="${{ matrix.os == 'macos-14' && 14 || 13.6 }}"
Expand All @@ -185,10 +192,11 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
run: python -m pip install cibuildwheel~=3.0

- name: Set PROJ_DATA (macOS)
if: runner.os == 'macOS'
Expand All @@ -211,25 +219,19 @@ jobs:
export PACKAGE_DATA=1
python -m cibuildwheel --output-dir wheelhouse
env:
# Disable PyPy builds
# Disable builds on musllinux
# Disable builds on musllinux and python 3.8, 3.9 and 3.14
CIBW_SKIP: "*musllinux* cp38* cp39* cp314*"
# Disable builds in linux architectures other than x86_64
CIBW_SKIP: "pp* *musllinux*"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ENVIRONMENT_PASS_LINUX: PACKAGE_DATA LD_LIBRARY_PATH PROJ_DATA C_INCLUDE_PATH
CIBW_ENVIRONMENT_MACOS: >
MACOSX_DEPLOYMENT_TARGET="${{ matrix.os == 'macos-14' && 14 || 13.6 }}"
CIBW_BEFORE_ALL_LINUX: >
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&
yum -y update &&
yum -y install gcc gcc-c++ make cmake postgresql13-devel proj81-devel geos39-devel gsl-devel &&
git clone --branch json-c-0.17 --depth 1 https://github.com/json-c/json-c &&
mkdir json-c-build &&
cd json-c-build &&
cmake ../json-c &&
make &&
make install &&
git clone --depth 1 --branch ${{ needs.checks.outputs.branch }} https://github.com/MobilityDB/MobilityDB &&
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&
dnf -qy module disable postgresql &&
dnf -y update &&
dnf -y install gcc gcc-c++ make cmake postgresql16-devel proj81-devel geos39-devel gsl-devel json-c-devel &&
git clone --depth 1 --branch ${{ needs.checks.outputs.meos_branch }} https://github.com/MobilityDB/MobilityDB &&
mkdir MobilityDB/build &&
cd MobilityDB/build &&
cmake .. -DMEOS=on -DGEOS_INCLUDE_DIR=/usr/geos39/include/ -DGEOS_LIBRARY=/usr/geos39/lib64/libgeos_c.so -DGEOS_CONFIG=/usr/geos39/bin/geos-config -DPROJ_INCLUDE_DIRS=/usr/proj81/include/ -DPROJ_LIBRARIES=/usr/proj81/lib/libproj.so &&
Expand All @@ -252,9 +254,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
# os: [ ubuntu-latest, macos-13, macos-14 ]
os: [ ubuntu-latest, macos-14 ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
os: [ ubuntu-latest, macos-13, macos-14 ]

steps:
- name: Checkout
Expand All @@ -280,7 +281,7 @@ jobs:
- name: Run PyMEOS-CFFI check
run: |
python -c "import pymeos_cffi; print(pymeos_cffi.__version__);"
python -c "from pymeos_cffi import *; meos_initialize(None); print(tpoint_out(tgeompoint_in('POINT(2 3)@2000-01-01'), 3)); meos_finalize();"
python -c "from pymeos_cffi import *; meos_initialize(None); print(tgeo_out(tgeompoint_in('POINT(2 3)@2000-01-01'), 3)); meos_finalize();"

upload_pypi:
name: Upload to PyPI
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint code with Ruff

on:
push:
branches: [ "master", "stable-[0-9]+.[0-9]+" ]
pull_request:
branches: [ "master", "stable-[0-9]+.[0-9]+" ]

jobs:
lint:
name: Lint code with Ruff
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Ruff
uses: astral-sh/ruff-action@v3
with:
args: "--version"

- name: Check rules
run: "ruff check"

- name: Check format
run: "ruff format --check --diff"
29 changes: 15 additions & 14 deletions builder/build_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
import re
import subprocess
import sys
from typing import Set, Tuple, Match

header_files = [
"meos.h",
"meos_catalog.h",
"meos_geo.h",
"meos_internal.h",
"meos_internal_geo.h",
"meos_npoint.h",
]


def get_defined_functions(library_path):
Expand All @@ -20,9 +28,7 @@ def remove_undefined_functions(content, so_path):

def remove_if_not_defined(m):
function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*")
if function in defined or (
sys.platform == "darwin" and ("_" + function) in defined
):
if function in defined or (sys.platform == "darwin" and ("_" + function) in defined):
for t in undefined_types:
if t in m.group(0):
print(f"Removing function due to undefined type {t}: {function}")
Expand All @@ -41,10 +47,8 @@ def remove_if_not_defined(m):
return content


def remove_repeated_functions(
content: str, seen_functions: set
) -> Tuple[str, Set[str]]:
def remove_if_repeated(m: Match):
def remove_repeated_functions(content: str, seen_functions: set) -> tuple[str, set[str]]:
def remove_if_repeated(m: re.Match):
function = m.group("function")
if function in seen_functions:
print(f"Removing repeated function: {function}")
Expand All @@ -63,7 +67,6 @@ def remove_if_repeated(m: Match):


def build_header_file(include_dir, so_path=None, destination_path="builder/meos.h"):
files = ["meos.h", "meos_catalog.h", "meos_internal.h"]
global_content = """
typedef struct
{
Expand All @@ -89,9 +92,9 @@ def build_header_file(include_dir, so_path=None, destination_path="builder/meos.
"""

functions = set()
for file_name in files:
for file_name in header_files:
file_path = os.path.join(include_dir, file_name)
with open(file_path, "r") as f:
with open(file_path) as f:
content = f.read()
# Remove comments
content = re.sub(r"//.*", "", content)
Expand All @@ -105,9 +108,7 @@ def build_header_file(include_dir, so_path=None, destination_path="builder/meos.
content,
flags=re.RegexFlag.MULTILINE,
)
content = re.sub(
r"//#ifdef.*?//#endif", "", content, flags=re.RegexFlag.DOTALL
)
content = re.sub(r"//#ifdef.*?//#endif", "", content, flags=re.RegexFlag.DOTALL)
content = content.replace("//#endif", "")
content = re.sub(r"//# *\w+ +([\w,()]+) *((?:\\\n|.)*?)\n", "", content)

Expand Down
13 changes: 11 additions & 2 deletions builder/build_pymeos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

from cffi import FFI

header_files = [
"meos.h",
"meos_catalog.h",
"meos_geo.h",
"meos_internal.h",
"meos_internal_geo.h",
"meos_npoint.h",
]

ffibuilder = FFI()

with open(os.path.join(os.path.dirname(__file__), "meos.h"), "r") as f:
with open(os.path.join(os.path.dirname(__file__), "meos.h")) as f:
content = f.read()

ffibuilder.cdef(content)
Expand All @@ -22,7 +31,7 @@ def get_include_dirs():

ffibuilder.set_source(
"_meos_cffi",
'#include "meos.h"\n' '#include "meos_catalog.h"\n' '#include "meos_internal.h"',
"\n".join(f'#include "{h}"' for h in header_files),
libraries=["meos"],
library_dirs=get_library_dirs(),
include_dirs=get_include_dirs(),
Expand Down
Loading
Loading