Skip to content
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
2 changes: 1 addition & 1 deletion .dockerignore
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ci

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
# renovate: datasource=pypi depName=uv
UV_VERSION: 0.11.21

jobs:
test:
name: Test (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, Elasticsearch ${{ matrix.elastic-version }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
django-version:
- "4.2.*"
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
elastic-version:
- "7.17.29"
env:
UV_NO_DEV: 1
ELASTICSEARCH_VERSION: ${{ matrix.elastic-version }}
PYTHONUNBUFFERED: 1
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install GDAL
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gdal-bin

- name: Start Elasticsearch
run: docker compose up -d --quiet-pull --wait elasticsearch

- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
version: "${{ env.UV_VERSION }}"
python-version: "${{ matrix.python-version }}"

- name: Setup project and install dependencies
run: uv sync

# TODO: Remove this step, which relies on `setup.py`, once we
# migrate the build backend to hatch with `pyproject.toml`
- name: Install drf-haystack into the environment
run: uv pip install .

# Use always latest patch version of Django from the matrix version pattern `major.minor.*`.
- name: Install matrix django
env:
DJANGO_VERSION: ${{ matrix.django-version }}
run: uv pip install -U "django==${DJANGO_VERSION}"

- name: Run tests
run: uv run --no-sync manage.py test tests
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ docs/_build/
# PyBuilder
target/

# Pipenv
.tool-versions
.idea
# uv
uv.lock
.venv/

# IDE
.idea/
.vscode/
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions Pipfile

This file was deleted.

24 changes: 19 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
version: '2'
---
services:
elasticsearch2:
image: elasticsearch:2@sha256:41ed3a1a16b63de740767944d5405843db00e55058626c22838f23b413aa4a39
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.29}
environment:
- discovery.type=single-node
ports:
- "9200:9200"
- "9300:9300"
- 9200:9200
networks:
- es_search
healthcheck:
test:
- CMD-SHELL
- curl -fs http://localhost:9200/_cluster/health || exit 1
interval: 10s
timeout: 5s
retries: 10

networks:
es_search:
driver: bridge
12 changes: 7 additions & 5 deletions drf_haystack/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from itertools import chain

from dateutil import parser
from django.core.exceptions import ImproperlyConfigured

from drf_haystack import constants
from drf_haystack.utils import merge_dict
Expand Down Expand Up @@ -263,15 +264,16 @@ def __init__(self, backend, view):
)

try:
from haystack.utils.geo import D, Point
from django.contrib.gis.geos import Point
from django.contrib.gis.measure import D

self.D = D
self.Point = Point
except ImportError:
except ImproperlyConfigured:
warnings.warn(
"Make sure you've installed the `libgeos` library. "
"Run `apt-get install libgeos` on debian based linux systems, "
"or `brew install geos` on OS X."
"Make sure you've installed the ``GDAL`` library (which also pulls in GEOS). "
"Run `apt install gdal-bin` on debian based linux systems, "
"or `brew install gdal` on OS X."
)
raise

Expand Down
Loading