pysolrmarc
A Python wrapper for Solrmarc that converts binary MARC records into Solr documents by communicating with the Solrmarc Java process via stdin/stdout (NDJSON).
Installation
pip install pysolrmarc
Prerequisites
- Java 8+ must be installed and available on
PATH. - A Solrmarc installation directory (default:
/opt/solrmarc) containing:solrmarc/solrmarc_core_ant.jarsolrmarc/lib/(Java dependencies)solrmarc/lib_solrj/andsolrmarc/lib_local/solrmarc/log4j.properties- A mapping properties file (e.g.
index.kxp.tit.properties) - A reader options file (e.g.
marcreader.properties)
Quick Start
import pysolrmarc
with pysolrmarc.Solrmarc(
mapping="/opt/solrmarc/mappings/ahn/index.kxp.tit.properties",
reader_opts="/opt/solrmarc/mappings/ahn/marcreader.properties",
) as sm:
solr_doc = sm.convert(binary_marc_record)
print(solr_doc)
The context manager ensures the Java process is terminated gracefully when done. You can also use it without with and call close() manually:
sm = pysolrmarc.Solrmarc(
mapping="/opt/solrmarc/mappings/ahn/index.kxp.tit.properties",
reader_opts="/opt/solrmarc/mappings/ahn/marcreader.properties",
path="/opt/solrmarc",
)
try:
solr_doc = sm.convert(binary_marc_record)
finally:
sm.close()
API Reference
Solrmarc(mapping, reader_opts, path="/opt/solrmarc")
Creates a new Solrmarc instance and starts the Java process.
| Parameter | Type | Description |
|---|---|---|
mapping |
str |
Full path to the Solrmarc mapping properties file. |
reader_opts |
str |
Full path to the reader options configuration file. |
path |
str |
Root path of the Solrmarc installation (default: /opt/solrmarc). |
Supports the context manager protocol (with statement).
convert(marc, retries=2) -> dict | None
Converts a single binary MARC record to a Solr document dict.
| Parameter | Type | Description |
|---|---|---|
marc |
bytes |
Binary MARC record data. |
retries |
int |
Number of retry attempts on timeout (default: 2). |
Returns a dict representing the Solr document, or None if Solrmarc returned an empty response.
Raises an Exception if JSON decoding fails or all retries are exhausted.
start() -> None
Starts the Solrmarc Java process. Called automatically on __init__. Use to restart after calling stop().
stop() -> None
Kills the Solrmarc process forcefully (sends SIGKILL).
restart() -> None
Stops and restarts the Solrmarc instance.
close() -> None
Terminates the Solrmarc process gracefully (sends SIGTERM). Called automatically when exiting a with block.
Build and Publish
pip install hatch
hatch build
uv publish dist/*
To publish to a private registry:
uv publish --publish-url https://git.slub-dresden.de/api/v4/projects/2300/packages/pypi dist/*
License
MIT – see LICENSE.
Metadata
Release files for pysolrmarc 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysolrmarc-0.5.0.tar.gz | 5.8 kB | Without provenance | Details for pysolrmarc-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysolrmarc-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pysolrmarc-0.5.0-py3-none-any.whl |
Total release size: 10.9 kB
Release files / pysolrmarc-0.5.0.tar.gz
| Download URL | pysolrmarc-0.5.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e656f649a9dd2300da5fa0282d4d7099d6ebd6a59672c55a0acf07bd12aeaa1d
|
|
BLAKE2b-256 checksum How to use checksums |
595ff8d176012d001e41d8be32088ae29a457c162ddac32f9263c31742d1f44a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pysolrmarc-0.5.0-py3-none-any.whl
| Download URL | pysolrmarc-0.5.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bdc3366339b4e09ba46e2732296280b6fd2a6247c6deb1304d7cbd2a81959f7
|
|
BLAKE2b-256 checksum How to use checksums |
3235643f66d9547e00df3d8207261e60122dc3b3ccbc2918f52ed8295b7adda9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for pysolrmarc 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.