Complete 100% 1:1 Python FFI Wrapper for the Swiss Ephemeris C Library - Direct C function calls with zero abstraction for maximum astronomical precision
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swisseph_ffi-1.0.0.tar.gz.
File metadata
- Download URL: swisseph_ffi-1.0.0.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3564d62e3456bbc6ac374b135c971ec547fbe60f6b1e18ea727af8886d339f2c
|
|
| MD5 |
7b417bff8c8b88c0142b14e7d87fc014
|
|
| BLAKE2b-256 |
2ca927232fdc22a93736f6fe3cd18128db32b30900902a4c7886218eac1bd2b4
|
Provenance
The following attestation bundles were made for swisseph_ffi-1.0.0.tar.gz:
Publisher:
publish.yml on jayeshmepani/Swiss-Ephemeris-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swisseph_ffi-1.0.0.tar.gz -
Subject digest:
3564d62e3456bbc6ac374b135c971ec547fbe60f6b1e18ea727af8886d339f2c - Sigstore transparency entry: 1429431114
- Sigstore integration time:
-
Permalink:
jayeshmepani/Swiss-Ephemeris-Python@6c4ec75308070cb2b95a2b5a78d68b85cbf2b179 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jayeshmepani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c4ec75308070cb2b95a2b5a78d68b85cbf2b179 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file swisseph_ffi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: swisseph_ffi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f638049454251f678557da184fb3f8dfc3ff99df9a1b566470553dde2047ec
|
|
| MD5 |
cec96b1b3b018a89b239bbe81cc3d8a3
|
|
| BLAKE2b-256 |
5fb11becc43ccebaa749207cbbf1e8fa86bf0c265bca5408a6b72e04114676ec
|
Provenance
The following attestation bundles were made for swisseph_ffi-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on jayeshmepani/Swiss-Ephemeris-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swisseph_ffi-1.0.0-py3-none-any.whl -
Subject digest:
15f638049454251f678557da184fb3f8dfc3ff99df9a1b566470553dde2047ec - Sigstore transparency entry: 1429431116
- Sigstore integration time:
-
Permalink:
jayeshmepani/Swiss-Ephemeris-Python@6c4ec75308070cb2b95a2b5a78d68b85cbf2b179 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jayeshmepani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c4ec75308070cb2b95a2b5a78d68b85cbf2b179 -
Trigger Event:
workflow_dispatch
-
Statement type: