mirror of
https://github.com/dathere/ckan_geoconnex_bulk_runner.git
synced 2026-07-05 15:12:20 +00:00
feat: add initial Python package
This commit is contained in:
parent
e6b29be459
commit
71b08a53f0
8 changed files with 290 additions and 7 deletions
73
ckan_geoconnex_bulk_runner_py/.github/workflows/CI.yml
vendored
Normal file
73
ckan_geoconnex_bulk_runner_py/.github/workflows/CI.yml
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# This file is autogenerated by maturin v1.13.3
|
||||
# To update, run
|
||||
#
|
||||
# maturin generate-ci github
|
||||
#
|
||||
name: CI
|
||||
|
||||
on:
|
||||
# TODO: Enable when implementation is ready
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
# - master
|
||||
# tags:
|
||||
# - '*'
|
||||
# pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
target: x86_64
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Build wheels
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
target: ${{ matrix.platform.target }}
|
||||
args: --release --out dist --find-interpreter
|
||||
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
manylinux: auto
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: wheels-linux-${{ matrix.platform.target }}
|
||||
path: dist
|
||||
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
||||
needs: [linux]
|
||||
permissions:
|
||||
# Use to sign the release artifacts
|
||||
id-token: write
|
||||
# Used to upload release artifacts
|
||||
contents: write
|
||||
# Used to generate artifact attestation
|
||||
attestations: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v7
|
||||
- name: Generate artifact attestation
|
||||
uses: actions/attest@v4
|
||||
with:
|
||||
subject-path: 'wheels-*/*'
|
||||
- name: Install uv
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: astral-sh/setup-uv@v7
|
||||
- name: Publish to PyPI
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
run: uv publish 'wheels-*/*'
|
||||
env:
|
||||
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
||||
72
ckan_geoconnex_bulk_runner_py/.gitignore
vendored
Normal file
72
ckan_geoconnex_bulk_runner_py/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/target
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
.venv/
|
||||
env/
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
include/
|
||||
man/
|
||||
venv/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
pip-selfcheck.json
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
*.pot
|
||||
|
||||
.DS_Store
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyCharm
|
||||
.idea/
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
|
||||
# Pyenv
|
||||
.python-version
|
||||
14
ckan_geoconnex_bulk_runner_py/Cargo.toml
Normal file
14
ckan_geoconnex_bulk_runner_py/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "ckan_geoconnex_bulk_runner_py"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
name = "ckan_geoconnex_bulk_runner_py"
|
||||
|
||||
[dependencies]
|
||||
ckan_geoconnex_bulk_runner = { path = "../ckan_geoconnex_bulk_runner" }
|
||||
pyo3 = "0.28.3"
|
||||
serde_json = "1.0.149"
|
||||
13
ckan_geoconnex_bulk_runner_py/pyproject.toml
Normal file
13
ckan_geoconnex_bulk_runner_py/pyproject.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[build-system]
|
||||
requires = ["maturin>=1.13,<2.0"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "ckan_geoconnex_bulk_runner_py"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
31
ckan_geoconnex_bulk_runner_py/src/lib.rs
Normal file
31
ckan_geoconnex_bulk_runner_py/src/lib.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use pyo3::prelude::*;
|
||||
|
||||
/// Python functions for Geoconnex integration that can be used in CKAN extensions.
|
||||
/// Based on <https://github.com/dathere/ckan_geoconnex_bulk_runner>.
|
||||
#[pymodule]
|
||||
mod ckan_geoconnex_bulk_runner_py {
|
||||
use pyo3::{exceptions::PyException, prelude::*};
|
||||
|
||||
#[pyfunction]
|
||||
/// Construct Geoconnex-compatible JSON-LD as a string from dataset metadata.
|
||||
///
|
||||
/// Input: Dataset metadata (output of /package_show for a CKAN dataset) as a string.
|
||||
/// Output: Constructed Geoconnex-compatible JSON-LD as a string.
|
||||
fn construct_dataset_jsonld_from_metadata(dataset_metadata: String) -> PyResult<String> {
|
||||
match serde_json::to_value(dataset_metadata) {
|
||||
Ok(dataset_json) => {
|
||||
match ckan_geoconnex_bulk_runner::jsonld::construct_dataset_jsonld_from_metadata(
|
||||
dataset_json,
|
||||
) {
|
||||
Ok(jsonld) => serde_json::to_string(&jsonld).map_err(|e| {
|
||||
PyException::new_err(format!(
|
||||
"Error when converting JSON-LD to string: {e}"
|
||||
))
|
||||
}),
|
||||
Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
}
|
||||
}
|
||||
Err(e) => Err(PyException::new_err(e.to_string())),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue