[Git][debian-gis-team/python-rtree][upstream] New upstream version 1.2.0
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Fri Jan 19 14:07:19 GMT 2024
Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-rtree
Commits:
6ba97bbd by Bas Couwenberg at 2024-01-19T14:53:53+01:00
New upstream version 1.2.0
- - - - -
25 changed files:
- + .github/workflows/deploy.yml
- .github/workflows/build.yml → .github/workflows/test.yml
- .gitignore
- .pre-commit-config.yaml
- docs/source/changes.txt → CHANGES.rst
- MANIFEST.in
- README.md
- ci/install_libspatialindex.bash
- ci/install_libspatialindex.bat
- docs/requirements.txt
- + docs/source/changes.rst
- docs/source/class.txt → docs/source/class.rst
- docs/source/conf.py
- docs/source/history.txt → docs/source/history.rst
- docs/source/index.txt → docs/source/index.rst
- docs/source/install.txt → docs/source/install.rst
- + docs/source/misc.rst
- docs/source/performance.txt → docs/source/performance.rst
- docs/source/tutorial.txt → docs/source/tutorial.rst
- pyproject.toml
- rtree/__init__.py
- rtree/finder.py
- setup.py
- + tests/test_finder.py
- tests/test_index.py
Changes:
=====================================
.github/workflows/deploy.yml
=====================================
@@ -0,0 +1,82 @@
+name: Build and upload to PyPI
+
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - master
+ paths:
+ - '.github/workflows/deploy.yml'
+ release:
+ types:
+ - published
+
+jobs:
+ build_wheels:
+ name: Build wheel on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [windows-latest, ubuntu-latest, macos-latest]
+
+ steps:
+ - uses: actions/checkout at v4
+
+ - name: Set up QEMU
+ if: runner.os == 'Linux'
+ uses: docker/setup-qemu-action at v3
+ with:
+ platforms: arm64
+
+ - uses: actions/setup-python at v5
+ name: Install Python
+ with:
+ python-version: '3.11'
+
+ - uses: ilammy/msvc-dev-cmd at v1
+ if: startsWith(matrix.os, 'windows')
+
+ - name: Run Windows Preinstall Build
+ if: startsWith(matrix.os, 'windows')
+ run: |
+ choco install vcpython27 -f -y
+ ci\install_libspatialindex.bat
+
+ - name: Build wheels
+ uses: pypa/cibuildwheel at v2.16.2
+
+ - uses: actions/upload-artifact at v4
+ with:
+ name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
+ path: ./wheelhouse/*.whl
+
+ build_sdist:
+ name: Build source distribution
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout at v4
+
+ - name: Build sdist
+ run: pipx run build --sdist
+
+ - uses: actions/upload-artifact at v4
+ with:
+ name: cibw-sdist
+ path: dist/*.tar.gz
+
+ upload_pypi:
+ needs: [build_wheels, build_sdist]
+ runs-on: ubuntu-latest
+ environment: pypi
+ permissions:
+ id-token: write
+ if: github.event_name == 'release' && github.event.action == 'published'
+ steps:
+ - uses: actions/download-artifact at v4
+ with:
+ pattern: cibw-*
+ path: dist
+ merge-multiple: true
+
+ - uses: pypa/gh-action-pypi-publish at release/v1
=====================================
.github/workflows/build.yml → .github/workflows/test.yml
=====================================
@@ -1,15 +1,12 @@
-name: Build
+name: Test
on:
push:
branches:
- master
paths:
- - '.github/workflows/build.yml'
+ - '.github/workflows/test.yml'
pull_request:
- release:
- types:
- - published
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'
@@ -19,12 +16,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout at v4
- - uses: actions/setup-python at v4
+ - uses: actions/setup-python at v5
- uses: pre-commit/action at v3.0.0
conda:
name: Conda ${{ matrix.python-version }} - ${{ matrix.os }}
-
+ defaults:
+ run:
+ shell: bash -l {0}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
@@ -35,26 +34,27 @@ jobs:
steps:
- uses: actions/checkout at v4
- - uses: conda-incubator/setup-miniconda at v2
+ - uses: conda-incubator/setup-miniconda at v3
with:
channels: conda-forge
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Setup
- shell: bash -l {0}
run: |
conda install -c conda-forge numpy libspatialindex=${{ matrix.sidx-version }} -y
- name: Install
- shell: bash -l {0}
run: |
pip install -e .
- name: Test with pytest
- shell: bash -l {0}
run: |
pip install pytest
python -m pytest --doctest-modules rtree tests
+
ubuntu:
name: Ubuntu Python ${{ matrix.python-version }}
+ defaults:
+ run:
+ shell: bash -l {0}
runs-on: ubuntu-latest
strategy:
fail-fast: true
@@ -63,108 +63,19 @@ jobs:
steps:
- uses: actions/checkout at v4
- - uses: actions/setup-python at v4
+ - uses: actions/setup-python at v5
name: Install Python
with:
python-version: '3.11'
- name: Setup
- shell: bash -l {0}
run: |
sudo apt install libspatialindex-c6 python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install setuptools numpy pytest
- name: Build
- shell: bash -l {0}
run: |
python3 -m pip install --user .
- name: Test with pytest
- shell: bash -l {0}
run: |
python3 -m pytest --doctest-modules rtree tests
-
- wheels:
- name: Build wheel on ${{ matrix.os }}
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- os: [windows-latest, ubuntu-latest, macos-latest]
- steps:
- - uses: actions/checkout at v4
- - name: Set up QEMU
- if: runner.os == 'Linux'
- uses: docker/setup-qemu-action at v3
- with:
- platforms: arm64
- - uses: actions/setup-python at v4
- name: Install Python
- with:
- python-version: '3.11'
- - uses: ilammy/msvc-dev-cmd at v1
- if: startsWith(matrix.os, 'windows')
- - name: Run Windows Preinstall Build
- if: startsWith(matrix.os, 'windows')
- run: |
- choco install vcpython27 -f -y
- ci\install_libspatialindex.bat
- - name: Build wheels
- uses: pypa/cibuildwheel at v2.16.2
- - uses: actions/upload-artifact at v3
- with:
- name: ${{ matrix.os }}-whl
- path: wheelhouse/*.whl
-
- collect-artifacts:
- name: Package and push release
-
- #needs: [windows-wheel, linux-wheel, osx-wheel, conda, ubuntu]
- needs: [conda, ubuntu, wheels]
-
- runs-on: 'ubuntu-latest'
- strategy:
- fail-fast: true
-
- steps:
- - uses: actions/checkout at v4
- - uses: actions/setup-python at v4
- name: Install Python
- with:
- python-version: '3.11'
- - name: Source
- shell: bash -l {0}
- run: |
- sudo apt install libspatialindex-c6 python3-pip
- python3 -m pip install --upgrade pip
- python3 -m pip install setuptools numpy pytest wheel
- export PATH=$PATH:/home/runner/.local/bin
- python3 setup.py sdist
-
- - uses: actions/download-artifact at v3
- with:
- path: dist
- name: Download artifacts
-
- - name: Display structure of downloaded files
- run: ls -R
- working-directory: dist
-
- - name: Unpack
- shell: bash -l {0}
- working-directory: dist
- run: |
- for f in *whl
- do
- cd "$f"
- cp *.whl ..
- cd ..
- done;
- rm -rf *\-whl
- ls -al
-
- - uses: pypa/gh-action-pypi-publish at release/v1
- name: Publish package
- if: github.event_name == 'release' && github.event.action == 'published'
- with:
- user: __token__
- password: ${{ secrets.pypi_token }}
- packages_dir: ./dist
=====================================
.gitignore
=====================================
@@ -10,3 +10,5 @@ lib
.coverage
.tox
wheelhouse
+.vscode/
+*venv*
=====================================
.pre-commit-config.yaml
=====================================
@@ -5,6 +5,11 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
+ - repo: https://github.com/python-jsonschema/check-jsonschema
+ rev: 0.27.3
+ hooks:
+ - id: check-github-workflows
+ args: ["--verbose"]
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
@@ -17,3 +22,4 @@ repos:
rev: v1.5.1
hooks:
- id: mypy
+ exclude: 'docs/.'
=====================================
docs/source/changes.txt → CHANGES.rst
=====================================
@@ -1,38 +1,65 @@
-.. _changes:
+1.2.0: 2024-01-19
+=================
+
+- Fix test failure with built library (:PR:`291` by :user:`sebastic`)
+- Include spatialindex headers and add :py:meth:`~rtree.finder.get_include` (:PR:`292` by :user:`JDBetteridge`)
+
+1.1.0: 2023-10-17
+=================
+
+- Python 3.8+ is now required (:PR:`273`)
+- Move project metadata to pyproject.toml (:PR:`269`)
+- Refactor built wheels for PyPI (:PR:`276`)
+- Fix memory leak when breaking mid-way in _get_objects and _get_ids (:PR:`266`) (thanks :user:`akariv`!)
+
+1.0.1: 2022-10-12
+=================
+
+- Fix up type hints :PR:`243` (thanks :user:`oderby`)
+- Python 3.11 wheels :PR:`250` (thanks :user:`ewouth`)
+
+1.0.0: 2022-04-05
+=================
-Changes
-..............................................................................
+- Python 3.7+ is now required (:PR:`212`) (thanks :user:`adamjstewart`!)
+- Type hints (:PR:`215` and others) (thanks :user:`adamjstewart`!)
+- Python 3.10 wheels, including osx-arm64 :PR:`224`
+- Clean up libspatialindex C API mismatches :PR:`222` (thanks :user:`musicinmybrain`!)
+- Many doc updates, fixes, and type hints (thanks :user:`adamjstewart`!) :PR:`212` :PR:`221` :PR:`217` :PR:`215`
+- __len__ method for index :PR:`194`
+- Prevent get_coordinate_pointers from mutating inputs #205 (thanks :user:`sjones94549`!)
+- linux-aarch64 wheels :PR:`183` (thanks :user:`odidev`!)
+- black (:PR:`218`) and flake8 (:PR:`145`) linting
0.9.3: 2019-12-10
=================
-- find_library and libspatialindex library loading https://github.com/Toblerity/rtree/pull/131
+- find_library and libspatialindex library loading :PR:`131`
0.9.2: 2019-12-09
=================
-- Refactored tests to be based on unittest https://github.com/Toblerity/rtree/pull/129
-- Update libspatialindex library loading code to adapt previous behavior https://github.com/Toblerity/rtree/pull/128
-- Empty data streams throw exceptions and do not partially construct indexes https://github.com/Toblerity/rtree/pull/127
+- Refactored tests to be based on unittest :PR:`129`
+- Update libspatialindex library loading code to adapt previous behavior :PR:`128`
+- Empty data streams throw exceptions and do not partially construct indexes :PR:`127`
0.9.0: 2019-11-24
=================
- Add Index.GetResultSetOffset()
-- Add Index.contains() method for object and id (requires libspatialindex 1.9.3+) #116
-- Add Index.Flush() #107
-- Add TPRTree index support (thanks @sdhiscocks #117 )
-- Return container sizes without returning objects #90
-- Add set_result_limit and set_result_offset for Index paging 44ad21aecd3f7b49314b9be12f3334d8bae7e827
+- Add Index.contains() method for object and id (requires libspatialindex 1.9.3+) :PR:`116`
+- Add Index.Flush() :PR:`107`
+- Add TPRTree index support (thanks :user:`sdhiscocks` :PR:`117`)
+- Return container sizes without returning objects :PR:`90`
+- Add set_result_limit and set_result_offset for Index paging :commit:`44ad21aecd3f7b49314b9be12f3334d8bae7e827`
Bug fixes:
-- Better exceptions in cases where stream functions throw #80
+- Better exceptions in cases where stream functions throw :PR:`80`
- Migrated CI platform to Azure Pipelines https://dev.azure.com/hobuinc/rtree/_build?definitionId=5
- Minor test enhancements and fixups. Both libspatialindex 1.8.5 and libspatialindex 1.9.3 are tested with CI
-
0.8: 2014-07-17
===============
@@ -69,7 +96,7 @@ Bug fixes:
- Many more docstrings, sphinx docs, etc
-0.5.0: 2009-08-XX
+0.5.0: 2009-08-06
=================
0.5.0 was a complete refactoring to use libsidx - a C API for libspatialindex.
@@ -112,8 +139,8 @@ available as a result of this refactoring.
- Reraise index query errors as Python exceptions.
- Improved persistence.
-0.2:
-==================
+0.2: 19 May 2007
+================
- Link spatialindex system library.
0.1: 13 April 2007
=====================================
MANIFEST.in
=====================================
@@ -1,4 +1,4 @@
-include *.md *.txt
+include *.md *.rst *.txt
include MANIFEST.in
recursive-include benchmarks *
recursive-include tests *
=====================================
README.md
=====================================
@@ -24,29 +24,4 @@ Wheels are available for most major platforms, and `rtree` with bundled `libspat
pip install rtree
```
-# Changes
-
-## 1.1.0
-
-* Python 3.8+ is now required (#273)
-* Move project metadata to pyproject.toml (#269)
-* Refactor built wheels for PyPI (#276)
-* Fix memory leak when breaking mid-way in `_get_objects` and `_get_ids` (#266) (thanks @akariv!)
-
-## 1.0.1
-
-* Fix up type hints #243 (thanks @oderby)
-* Python 3.11 wheels #250 (thanks @ewouth)
-
-## 1.0.0
-
-
-* Python 3.7+ is now required (#212) (thanks @adamjstewart!)
-* Type hints (#215 and others) (thanks @adamjstewart!)
-* Python 3.10 wheels, including osx-arm64 #224
-* Clean up libspatialindex C API mismatches #222 (thanks @musicinmybrain!)
-* Many doc updates, fixes, and type hints (thanks @adamjstewart!) #212 #221 #217 #215
-* __len__ method for index #194
-* Prevent get_coordinate_pointers from mutating inputs #205 (thanks @sjones94549!)
-* linux-aarch64 wheels #183 (thanks @odidev!)
-* black (#218) and flake8 (#145) linting
+See [changes](https://rtree.readthedocs.io/en/latest/changes.html) for all versions.
=====================================
ci/install_libspatialindex.bash
=====================================
@@ -7,7 +7,7 @@ SHA256=63a03bfb26aa65cf0159f925f6c3491b6ef79bc0e3db5a631d96772d6541187e
# where to copy resulting files
# this has to be run before `cd`-ing anywhere
-gentarget() {
+libtarget() {
OURPWD=$PWD
cd "$(dirname "$0")"
mkdir -p ../rtree/lib
@@ -17,6 +17,16 @@ gentarget() {
echo $arr
}
+headertarget() {
+ OURPWD=$PWD
+ cd "$(dirname "$0")"
+ mkdir -p ../rtree/include
+ cd ../rtree/include
+ arr=$(pwd)
+ cd "$OURPWD"
+ echo $arr
+}
+
scriptloc() {
OURPWD=$PWD
cd "$(dirname "$0")"
@@ -26,7 +36,8 @@ scriptloc() {
}
# note that we're doing this convoluted thing to get
# an absolute path so mac doesn't yell at us
-TARGET=`gentarget`
+LIBTARGET=`libtarget`
+HEADERTARGET=`headertarget`
SL=`scriptloc`
rm $VERSION.zip || true
@@ -60,10 +71,13 @@ if [ "$(uname)" == "Darwin" ]; then
# change the rpath in the dylib to point to the same directory
install_name_tool -change @rpath/libspatialindex.6.dylib @loader_path/libspatialindex.dylib bin/libspatialindex_c.dylib
# copy the dylib files to the target director
- cp bin/libspatialindex.dylib $TARGET
- cp bin/libspatialindex_c.dylib $TARGET
+ cp bin/libspatialindex.dylib $LIBTARGET
+ cp bin/libspatialindex_c.dylib $LIBTARGET
+ cp -r ../include/* $HEADERTARGET
else
- cp -d bin/* $TARGET
+ cp -L bin/* $LIBTARGET
+ cp -r ../include/* $HEADERTARGET
fi
-ls $TARGET
+ls $LIBTARGET
+ls -R $HEADERTARGET
=====================================
ci/install_libspatialindex.bat
=====================================
@@ -21,7 +21,9 @@ ninja
mkdir %~dp0\..\rtree\lib
copy bin\*.dll %~dp0\..\rtree\lib
+xcopy /S ..\include\* %~dp0\..\rtree\include\
rmdir /Q /S bin
dir %~dp0\..\rtree\
dir %~dp0\..\rtree\lib
+dir %~dp0\..\rtree\include
=====================================
docs/requirements.txt
=====================================
@@ -1 +1,2 @@
sphinx>=4
+sphinx-issues
=====================================
docs/source/changes.rst
=====================================
@@ -0,0 +1,6 @@
+.. _changes:
+
+Changes
+..............................................................................
+
+.. include:: ../../CHANGES.rst
=====================================
docs/source/class.txt → docs/source/class.rst
=====================================
=====================================
docs/source/conf.py
=====================================
@@ -1,34 +1,24 @@
+# Configuration file for the Sphinx documentation builder.
#
-# Rtree documentation build configuration file, created by
-# sphinx-quickstart on Tue Aug 18 13:21:07 2009.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
+# For the full list of built-in configuration values, see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
import sys
-from typing import List
sys.path.append("../../")
import rtree # noqa: E402
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-# sys.path.append(os.path.abspath('.'))
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
-# -- General configuration -----------------------------------------------
+project = "Rtree"
+copyright = "2019, Sean Gilles, Howard Butler, and contributors"
+author = "Sean Gilles, Howard Butler, and contributors"
+version = release = rtree.__version__
-# If your documentation needs a minimal Sphinx version, state it here.
-needs_sphinx = "4.0"
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
@@ -36,194 +26,41 @@ extensions = [
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.ifconfig",
+ "sphinx_issues",
]
-# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
-
-# The suffix of source filenames.
-source_suffix = ".txt"
-
-# The encoding of source files.
-# source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = "index"
-
-# General information about the project.
-project = "Rtree"
-copyright = "2019, Sean Gilles, Howard Butler, and contributors."
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = rtree.__version__
-# The full version, including alpha/beta/rc tags.
-release = rtree.__version__
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-# language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-# today = ''
-# Else, today_fmt is used as the format for a strftime call.
-# today_fmt = '%B %d, %Y'
-
-# List of documents that shouldn't be included in the build.
-# unused_docs = []
-
-# List of directories, relative to source directory, that shouldn't be searched
-# for source files.
-exclude_trees: List[str] = []
-
-# The reST default role (used for this markup: `text`) to use for all documents.
-# default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-# add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-# add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-# show_authors = False
+exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
-# A list of ignored prefixes for module index sorting.
-# modindex_common_prefix = []
-
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
-# -- Options for HTML output ---------------------------------------------
-# The theme to use for HTML and HTML Help pages. Major themes that come with
-# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = "nature"
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-# html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-# html_theme_path = []
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# "<project> v<release> documentation".
-# html_title = None
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-# html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-# html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-# html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path: List[str] = []
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-# html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-# html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-# html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-# html_additional_pages = {}
-
-# If false, no module index is generated.
-# html_use_modindex = True
-
-# If false, no index is generated.
-# html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-# html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-# html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-# html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-# html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-# html_use_opensearch = ''
-
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-# html_file_suffix = ''
-
-# Output file base name for HTML help builder.
htmlhelp_basename = "Rtreedoc"
-
# -- Options for LaTeX output --------------------------------------------
-# The paper size ('letter' or 'a4').
-# latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-# latex_font_size = '10pt'
-
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
- ("index", "Rtree.tex", "Rtree Documentation", "Sean Gilles", "manual")
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-# latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-# latex_use_parts = False
-
-# Additional stuff for the LaTeX preamble.
-# latex_preamble = ''
-
-# Documents to append as an appendix to all manuals.
-# latex_appendices = []
-
-# If false, no module index is generated.
-# latex_use_modindex = True
+latex_documents = [("index", "Rtree.tex", "Rtree Documentation", author, "manual")]
pdf_documents = [("index", "Rtree", "Rtree Documentation", "The Rtree Team")]
-# A comma-separated list of custom stylesheets. Example:
pdf_language = "en_US"
pdf_fit_mode = "overflow"
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {"python": ("http://docs.python.org/3", None)}
-
-
# -- Extension configuration -------------------------------------------------
+intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
+
# sphinx.ext.autodoc
autodoc_typehints = "description"
autodoc_typehints_description_target = "documented"
+
+# sphinx-issues
+issues_github_path = "Toblerity/rtree"
+issues_commit_prefix = ""
=====================================
docs/source/history.txt → docs/source/history.rst
=====================================
@@ -34,14 +34,14 @@ is part of that source tree. The code bases are independent from each other
and can now evolve separately. Rtree is pure Python as of 0.6.0+.
-.. _`Sean Gillies`: http://sgillies.net/blog/
-.. _`Howard Butler`: http://hobu.co
-.. _`Brent Pedersen`: http://hackmap.blogspot.com/
-.. _`QGIS`: http://qgis.org
+.. _`Sean Gillies`: https://sgillies.net
+.. _`Howard Butler`: https://hobu.co
+.. _`Brent Pedersen`: https://github.com/brentp
+.. _`QGIS`: https://qgis.org
-.. _`ZODB`: http://www.zodb.org/
-.. _`R-trees`: http://en.wikipedia.org/wiki/R-tree
-.. _`ctypes`: http://docs.python.org/library/ctypes.html
-.. _`libspatialindex`: https://libspatialindex.org/
-.. _`Rtree`: http://rtree.github.com
+.. _`ZODB`: https://zodb.org
+.. _`R-trees`: https://en.wikipedia.org/wiki/R-tree
+.. _`ctypes`: https://docs.python.org/3/library/ctypes.html
+.. _`libspatialindex`: https://libspatialindex.org
+.. _`Rtree`: https://rtree.readthedocs.io
=====================================
docs/source/index.txt → docs/source/index.rst
=====================================
@@ -25,6 +25,7 @@ Documentation
install
tutorial
class
+ misc
changes
performance
history
@@ -33,7 +34,7 @@ Documentation
* :ref:`modindex`
* :ref:`search`
-.. _`R-trees`: http://en.wikipedia.org/wiki/R-tree
-.. _`ctypes`: http://docs.python.org/library/ctypes.html
-.. _`libspatialindex`: https://libspatialindex.org/
-.. _`Rtree`: http://toblerity.github.com/rtree/
+.. _`R-trees`: https://en.wikipedia.org/wiki/R-tree
+.. _`ctypes`: https://docs.python.org/3/library/ctypes.html
+.. _`libspatialindex`: https://libspatialindex.org
+.. _`Rtree`: https://rtree.readthedocs.io
=====================================
docs/source/install.txt → docs/source/install.rst
=====================================
@@ -8,26 +8,29 @@ Installation
First, download and install version 1.8.5+ of the `libspatialindex`_ library from:
-https://libspatialindex.org/
+https://libspatialindex.org
-The library is a GNU-style build, so it is a matter of::
+The library supports CMake builds, so it is a matter of::
- $ ./configure; make; make install
+ $ mkdir build && cd build
+ $ cmake ..
+ $ cmake --build . -j
+ $ cmake --install .
You may need to run the ``ldconfig`` command after installing the library to
ensure that applications can find it at startup time.
-At this point you can get Rtree 0.7.0 via easy_install::
+Rtree can be easily installed via pip::
- $ easy_install Rtree
+ $ pip install Rtree
-or by running the local setup.py::
+or by running in a local source directory::
- $ python setup.py install
+ $ pip install -e .
You can build and test in place like::
- $ python setup.py test
+ $ pytest
Windows
..............................................................................
@@ -36,10 +39,8 @@ The Windows DLLs of `libspatialindex`_ are pre-compiled in
windows installers that are available from `PyPI`_. Installation on Windows
is as easy as::
- c:\python2x\scripts\easy_install.exe Rtree
+ pip install Rtree
-.. _`PyPI`: http://pypi.python.org/pypi/Rtree/
-.. _`Rtree`: http://pypi.python.org/pypi/Rtree/
-
-.. _`libspatialindex`: https://libspatialindex.org/
+.. _`PyPI`: https://pypi.org/project/Rtree/
+.. _`libspatialindex`: https://libspatialindex.org
=====================================
docs/source/misc.rst
=====================================
@@ -0,0 +1,16 @@
+.. _misc:
+
+Miscellaneous Documentation
+------------------------------------------------------------------------------
+
+Exceptions
+==========
+
+.. autoexception:: rtree.exceptions.RTreeError
+ :members:
+
+Finder module
+=============
+
+.. automodule:: rtree.finder
+ :members:
=====================================
docs/source/performance.txt → docs/source/performance.rst
=====================================
@@ -3,10 +3,10 @@
Performance
------------------------------------------------------------------------------
-See the `tests/benchmarks.py`_ file for a comparison of various query methods
+See the `benchmarks.py`_ file for a comparison of various query methods
and how much acceleration can be obtained from using Rtree.
-.. _tests/benchmarks.py: https://raw.github.com/Rtree/Rtree/master/tests/benchmarks.py
+.. _benchmarks.py: https://github.com/Toblerity/rtree/blob/master/benchmarks/benchmarks.py
There are a few simple things that will improve performance.
@@ -38,6 +38,12 @@ Override :py:data:`~rtree.index.Index.dumps` to use the highest pickle protocol
... return cPickle.dumps(obj, -1)
>>> r = FastRtree()
+.. topic:: Update from January 2024
+
+ Pickling is currently broken and awaiting a pull requst to fix it.
+ For more information, see the `pull request on GitHub`_.
+
+.. _pull request on GitHub: https://github.com/Toblerity/rtree/pull/197
Use objects='raw'
...............................................................................
=====================================
docs/source/tutorial.txt → docs/source/tutorial.rst
=====================================
@@ -201,8 +201,10 @@ ZODB and Custom Storages
..............................................................................
https://mail.zope.org/pipermail/zodb-dev/2010-June/013491.html contains a custom
-storage backend for `ZODB`_
+storage backend for `ZODB`_ and you can find example python code `here`_. Note
+that the code was written in 2011, hasn't been updated and was only an alpha
+version.
-.. _ZODB: http://www.zodb.org/
-
-.. _`libspatialindex`: https://libspatialindex.org/
+.. _`here`: https://github.com/Toblerity/zope.index.rtree
+.. _`ZODB`: https://zodb.org
+.. _`libspatialindex`: https://libspatialindex.org
=====================================
pyproject.toml
=====================================
@@ -9,6 +9,7 @@ authors = [
]
maintainers = [
{name = "Howard Butler", email = "howard at hobu.co"},
+ {name = "Mike Taves", email = "mwtoews at gmail.com"},
]
description = "R-Tree spatial index for Python GIS"
readme = "README.md"
@@ -39,12 +40,13 @@ Repository = "https://github.com/Toblerity/rtree"
[tool.setuptools]
packages = ["rtree"]
zip-safe = false
+include-package-data = false
[tool.setuptools.dynamic]
version = {attr = "rtree.__version__"}
[tool.setuptools.package-data]
-rtree = ["lib", "py.typed"]
+rtree = ["py.typed"]
[tool.black]
target-version = ["py38", "py39", "py310", "py311", "py312"]
@@ -100,5 +102,6 @@ skip_gitignore = true
color_output = true
[tool.mypy]
+exclude = ["docs", "build"]
ignore_missing_imports = true
show_error_codes = true
=====================================
rtree/__init__.py
=====================================
@@ -6,6 +6,6 @@ hyperrectangular intersection queries.
"""
from __future__ import annotations
-__version__ = "1.1.0"
+__version__ = "1.2.0"
from .index import Index, Rtree # noqa
=====================================
rtree/finder.py
=====================================
@@ -1,28 +1,25 @@
"""
-finder.py
-------------
-
-Locate `libspatialindex` shared library by any means necessary.
+Locate `libspatialindex` shared library and header files.
"""
from __future__ import annotations
import ctypes
+import importlib.metadata
import os
import platform
import sys
from ctypes.util import find_library
+from pathlib import Path
-# the current working directory of this file
-_cwd = os.path.abspath(os.path.expanduser(os.path.dirname(__file__)))
+_cwd = Path(__file__).parent
+_sys_prefix = Path(sys.prefix)
# generate a bunch of candidate locations where the
# libspatialindex shared library *might* be hanging out
-_candidates = [
- os.environ.get("SPATIALINDEX_C_LIBRARY", None),
- os.path.join(_cwd, "lib"),
- _cwd,
- "",
-]
+_candidates = []
+if "SPATIALINDEX_C_LIBRARY" in os.environ:
+ _candidates.append(Path(os.environ["SPATIALINDEX_C_LIBRARY"]))
+_candidates += [_cwd / "lib", _cwd, Path("")]
def load() -> ctypes.CDLL:
@@ -39,29 +36,26 @@ def load() -> ctypes.CDLL:
lib_name = f"spatialindex_c-{arch}.dll"
# add search paths for conda installs
- if (
- os.path.exists(os.path.join(sys.prefix, "conda-meta"))
- or "conda" in sys.version
- ):
- _candidates.append(os.path.join(sys.prefix, "Library", "bin"))
+ if (_sys_prefix / "conda-meta").exists() or "conda" in sys.version:
+ _candidates.append(_sys_prefix / "Library" / "bin")
# get the current PATH
oldenv = os.environ.get("PATH", "").strip().rstrip(";")
# run through our list of candidate locations
for path in _candidates:
- if not path or not os.path.exists(path):
+ if not path.exists():
continue
# temporarily add the path to the PATH environment variable
# so Windows can find additional DLL dependencies.
- os.environ["PATH"] = ";".join([path, oldenv])
+ os.environ["PATH"] = ";".join([str(path), oldenv])
try:
- rt = ctypes.cdll.LoadLibrary(os.path.join(path, lib_name))
+ rt = ctypes.cdll.LoadLibrary(str(path / lib_name))
if rt is not None:
return rt
except OSError:
pass
- except BaseException as E:
- print(f"rtree.finder unexpected error: {E!s}")
+ except BaseException as err:
+ print(f"rtree.finder unexpected error: {err!s}", file=sys.stderr)
finally:
os.environ["PATH"] = oldenv
raise OSError(f"could not find or load {lib_name}")
@@ -73,63 +67,104 @@ def load() -> ctypes.CDLL:
# macos shared libraries are `.dylib`
lib_name = "libspatialindex_c.dylib"
else:
- import importlib.metadata
-
# linux shared libraries are `.so`
lib_name = "libspatialindex_c.so"
# add path for binary wheel prepared with cibuildwheel/auditwheel
try:
pkg_files = importlib.metadata.files("rtree")
- for file in pkg_files: # type: ignore
- if (
- file.parent.name == "Rtree.libs"
- and file.stem.startswith("libspatialindex")
- and ".so" in file.suffixes
- ):
- _candidates.insert(1, os.path.join(str(file.locate())))
- break
+ if pkg_files is not None:
+ for file in pkg_files: # type: ignore
+ if (
+ file.parent.name == "Rtree.libs"
+ and file.stem.startswith("libspatialindex")
+ and ".so" in file.suffixes
+ ):
+ _candidates.insert(1, Path(file.locate()))
+ break
except importlib.metadata.PackageNotFoundError:
pass
# get the starting working directory
cwd = os.getcwd()
for cand in _candidates:
- if cand is None:
- continue
- elif os.path.isdir(cand):
+ if cand.is_dir():
# if our candidate is a directory use best guess
path = cand
- target = os.path.join(cand, lib_name)
- elif os.path.isfile(cand):
+ target = cand / lib_name
+ elif cand.is_file():
# if candidate is just a file use that
- path = os.path.split(cand)[0]
+ path = cand.parent
target = cand
else:
continue
- if not os.path.exists(target):
+ if not target.exists():
continue
try:
# move to the location we're checking
os.chdir(path)
# try loading the target file candidate
- rt = ctypes.cdll.LoadLibrary(target)
+ rt = ctypes.cdll.LoadLibrary(str(target))
if rt is not None:
return rt
- except BaseException as E:
- print(f"rtree.finder ({target}) unexpected error: {E!s}")
+ except BaseException as err:
+ print(
+ f"rtree.finder ({target}) unexpected error: {err!s}",
+ file=sys.stderr,
+ )
finally:
os.chdir(cwd)
try:
# try loading library using LD path search
- path = find_library("spatialindex_c")
- if path is not None:
- return ctypes.cdll.LoadLibrary(path)
+ pth = find_library("spatialindex_c")
+ if pth is not None:
+ return ctypes.cdll.LoadLibrary(pth)
except BaseException:
pass
raise OSError("Could not load libspatialindex_c library")
+
+
+def get_include() -> str:
+ """Return the directory that contains the spatialindex \\*.h files.
+
+ :returns: Path to include directory or "" if not found.
+ """
+ # check if was bundled with a binary wheel
+ try:
+ pkg_files = importlib.metadata.files("rtree")
+ if pkg_files is not None:
+ for path in pkg_files: # type: ignore
+ if path.name == "SpatialIndex.h":
+ return str(Path(path.locate()).parent.parent)
+ except importlib.metadata.PackageNotFoundError:
+ pass
+
+ # look for this header file in a few directories
+ path_to_spatialindex_h = Path("include/spatialindex/SpatialIndex.h")
+
+ # check sys.prefix, e.g. conda's libspatialindex package
+ if os.name == "nt":
+ file = _sys_prefix / "Library" / path_to_spatialindex_h
+ else:
+ file = _sys_prefix / path_to_spatialindex_h
+ if file.is_file():
+ return str(file.parent.parent)
+
+ # check if relative to lib
+ libdir = Path(load()._name).parent
+ file = libdir.parent / path_to_spatialindex_h
+ if file.is_file():
+ return str(file.parent.parent)
+
+ # check system install
+ file = Path("/usr") / path_to_spatialindex_h
+ if file.is_file():
+ return str(file.parent.parent)
+
+ # not found
+ return ""
=====================================
setup.py
=====================================
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
-import os
+import sys
+from pathlib import Path
from setuptools import setup
from setuptools.command.install import install
@@ -7,7 +8,7 @@ from setuptools.dist import Distribution
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
# current working directory of this setup.py file
-_cwd = os.path.abspath(os.path.split(__file__)[0])
+_cwd = Path(__file__).resolve().parent
class bdist_wheel(_bdist_wheel): # type: ignore[misc]
@@ -26,54 +27,54 @@ class BinaryDistribution(Distribution): # type: ignore[misc]
class InstallPlatlib(install): # type: ignore[misc]
def finalize_options(self) -> None:
"""
- Copy the shared libraries into the wheel. Note that this
- will *only* check in `rtree/lib` rather than anywhere on
- the system so if you are building a wheel you *must* copy or
- symlink the `.so`/`.dll`/`.dylib` files into `rtree/lib`.
+ Copy the shared libraries and header files into the wheel. Note that
+ this will *only* check in `rtree/lib` and `include` rather than
+ anywhere on the system so if you are building a wheel you *must* copy
+ or symlink the `.so`/`.dll`/`.dylib` files into `rtree/lib` and
+ `.h` into `rtree/include`.
"""
- # use for checking extension types
- from fnmatch import fnmatch
-
install.finalize_options(self)
if self.distribution.has_ext_modules():
self.install_lib = self.install_platlib
- # now copy over libspatialindex
- # get the location of the shared library on the filesystem
-
- # where we're putting the shared library in the build directory
- target_dir = os.path.join(self.build_lib, "rtree", "lib")
- # where are we checking for shared libraries
- source_dir = os.path.join(_cwd, "rtree", "lib")
-
- # what patterns represent shared libraries
- patterns = {"*.so", "libspatialindex*dylib", "*.dll"}
-
- if not os.path.isdir(source_dir):
- # no copying of binary parts to library
- # this is so `pip install .` works even
- # if `rtree/lib` isn't populated
- return
-
- for file_name in os.listdir(source_dir):
- # make sure file name is lower case
- check = file_name.lower()
- # use filename pattern matching to see if it is
- # a shared library format file
- if not any(fnmatch(check, p) for p in patterns):
- continue
-
- # if the source isn't a file skip it
- if not os.path.isfile(os.path.join(source_dir, file_name)):
- continue
-
- # make build directory if it doesn't exist yet
- if not os.path.isdir(target_dir):
- os.makedirs(target_dir)
-
- # copy the source file to the target directory
- self.copy_file(
- os.path.join(source_dir, file_name), os.path.join(target_dir, file_name)
- )
+
+ # source files to copy
+ source_dir = _cwd / "rtree"
+
+ # destination for the files in the build directory
+ target_dir = Path(self.build_lib) / "rtree"
+
+ source_lib = source_dir / "lib"
+ target_lib = target_dir / "lib"
+ if source_lib.is_dir():
+ # what patterns represent shared libraries for supported platforms
+ if sys.platform.startswith("win"):
+ lib_pattern = "*.dll"
+ elif sys.platform.startswith("linux"):
+ lib_pattern = "*.so*"
+ elif sys.platform == "darwin":
+ lib_pattern = "libspatialindex*dylib"
+ else:
+ raise ValueError(f"unhandled platform {sys.platform!r}")
+
+ target_lib.mkdir(parents=True, exist_ok=True)
+ for pth in source_lib.glob(lib_pattern):
+ # if the source isn't a file skip it
+ if not pth.is_file():
+ continue
+
+ # copy the source file to the target directory
+ self.copy_file(str(pth), str(target_lib / pth.name))
+
+ source_include = source_dir / "include"
+ target_include = target_dir / "include"
+ if source_include.is_dir():
+ for pth in source_include.rglob("*.h"):
+ rpth = pth.relative_to(source_include)
+
+ # copy the source file to the target directory
+ target_subdir = target_include / rpth.parent
+ target_subdir.mkdir(parents=True, exist_ok=True)
+ self.copy_file(str(pth), str(target_subdir))
# See pyproject.toml for other project metadata
=====================================
tests/test_finder.py
=====================================
@@ -0,0 +1,19 @@
+from ctypes import CDLL
+from pathlib import Path
+
+from rtree import finder
+
+
+def test_load():
+ lib = finder.load()
+ assert isinstance(lib, CDLL)
+
+
+def test_get_include():
+ incl = finder.get_include()
+ assert isinstance(incl, str)
+ if incl:
+ path = Path(incl)
+ assert path.is_dir()
+ assert (path / "spatialindex").is_dir()
+ assert (path / "spatialindex" / "SpatialIndex.h").is_file()
=====================================
tests/test_index.py
=====================================
@@ -2,6 +2,7 @@ from __future__ import annotations
import ctypes
import pickle
+import sys
import tempfile
import unittest
from typing import Iterator
@@ -451,6 +452,7 @@ class IndexSerialization(unittest.TestCase):
self.assertTrue(len(hits), 10)
self.assertEqual(hits, [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])
+ @pytest.mark.skipif(not sys.maxsize > 2**32, reason="Fails on 32bit systems")
def test_interleaving(self) -> None:
"""Streaming against a persisted index without interleaving"""
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-rtree/-/commit/6ba97bbd2d6d47c8c40710d763347549bf62688e
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-rtree/-/commit/6ba97bbd2d6d47c8c40710d763347549bf62688e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20240119/7b7c281c/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list