Swiss Ephemeris Python FFI
Pure Python ctypes runtime-FFI binding for the Swiss Ephemeris C library.
This project is the Python sibling of Swiss-Ephemeris-PHP: the wrapper loads
the native Swiss Ephemeris shared library at runtime and exposes the C API as-is.
Latest Upstream Status
Checked against upstream on April 25, 2026.
- Latest upstream release tag:
v2.10.3finalreleased on April 14, 2026. - Current upstream
masterchecked: commit2f18c14from April 18, 2026 (fixed bug in semo4200.se1). - Internal Swiss Ephemeris version string: the upstream C header still defines
SE_VERSIONas2.10.03. - Bundled native libraries: sourced from the sibling
Swiss-Ephemeris-PHPprebuilt libraries.
See VERSION.md and UPSTREAM_SYNC.md for detailed version tracking.
Design Contract
The raw binding does not:
- recalculate anything;
- round numeric outputs;
- normalize angles;
- reshape output arrays;
- hide return flags;
- convert C output arrays into Python arrays;
- drop
serrparameters where the C API has them; - change house cusp indexing;
- create a higher-level astrology API.
Callers pass ctypes buffers and pointers exactly as the C API requires.
Python Support
The project baseline is Python 3.10 and the target support range is Python 3.10 through Python 3.14.
Installation
pip install swisseph-ffi
Native Libraries
The package ships the same prebuilt Swiss Ephemeris binaries as
Swiss-Ephemeris-PHP:
linux-x64/libswe.solinux-arm64/libswe.somacos-x64/libswe.dylibmacos-arm64/libswe.dylibwindows-x64/swe.dll
You can override discovery with SWISSEPH_LIBRARY_PATH.
Library search order:
SWISSEPH_LIBRARY_PATH- bundled
swisseph_ffi/libs/<os-arch>/ - common system library paths on Linux/macOS
Why Another Python Package?
Python already has mature Swiss Ephemeris bindings such as pyswisseph and
pysweph. They are useful and work well for many CPython users.
This package takes a different approach: the Python layer is pure Python and
uses runtime FFI through ctypes. It does not compile a CPython extension
module and does not reshape the raw C API into a Pythonic convenience API.
Quick Start
from swisseph_ffi import SwissEph, SE_GREG_CAL, SE_SUN, SEFLG_SPEED
from swisseph_ffi import c_double, create_string_buffer
swe = SwissEph()
jd = swe.swe_julday(2000, 1, 1, 12.0, SE_GREG_CAL)
xx = (c_double * 6)()
serr = create_string_buffer(256)
ret = swe.swe_calc_ut(jd, SE_SUN, SEFLG_SPEED, xx, serr)
print(ret, list(xx), serr.value)
Scope
This package intentionally starts with the raw 1:1 layer only. A convenience API can be built separately later without changing the raw ABI binding.
Development Checks
python -m pip install -e ".[dev]"
python -m ruff check .
python -m ruff format . --check
python -m pyright
python -m pytest
python -m build
python -m twine check dist/*
The test suite includes:
- all 106 C functions loaded and signature-checked;
- runtime behavior tests mirrored from
Swiss-Ephemeris-PHP; - optional
swetestparity tests when the CLI and ephemeris files are available.
License
This package metadata declares AGPL-3.0-or-later.
The upstream Swiss Ephemeris C library and ephemeris data are distributed under Astrodienst's dual licensing model: AGPL or Swiss Ephemeris Professional License. If you use Swiss Ephemeris in commercial, closed-source, SaaS, or public web-service software, review Astrodienst's license terms before use.
Release files for swisseph-ffi 1.0.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 | |
|---|---|---|---|
| swisseph_ffi-1.0.0.tar.gz | 1.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swisseph_ffi-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.2 MB
Release files / swisseph_ffi-1.0.0.tar.gz
| Download URL | swisseph_ffi-1.0.0.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3564d62e3456bbc6ac374b135c971ec547fbe60f6b1e18ea727af8886d339f2c
|
|
BLAKE2b-256 checksum How to use checksums |
2ca927232fdc22a93736f6fe3cd18128db32b30900902a4c7886218eac1bd2b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 2, 2026.
Transparency logRelease files / swisseph_ffi-1.0.0-py3-none-any.whl
| Download URL | swisseph_ffi-1.0.0-py3-none-any.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15f638049454251f678557da184fb3f8dfc3ff99df9a1b566470553dde2047ec
|
|
BLAKE2b-256 checksum How to use checksums |
5fb11becc43ccebaa749207cbbf1e8fa86bf0c265bca5408a6b72e04114676ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 2, 2026.
Transparency log