Skip to main content

Sample from custom discrete and continuous distributions (Python bindings for the simsam Rust crate)

Project description

simsam-rs (Python)

Python bindings for the simsam Rust crate, built with PyO3 and maturin.

Install from PyPI (import name is still simsam):

pip install simsam-rs
import simsam

dist = simsam.from_pdf(lambda x: 2.0 * x, simsam.Interval(0.0, 1.0))
print(dist.mean())
print(dist.sample_n(10_000))

Development

cd python
uv sync
uv run maturin develop --release
uv run pytest

Publishing to PyPI (maintainers)

PyPI package name: simsam-rs. User code: import simsam.

Default wheels do not include the optional symbolic feature.

One-off local release

cd python
uv run maturin build --release
uv run maturin publish --username __token__ --password "$PYPI_API_TOKEN"

Or upload artifacts from dist/ with twine.

CI release (recommended)

  1. On PyPI, create project simsam-rs and configure a trusted publisher for this GitHub repo (workflow: publish-pypi.yml, environment: pypi).
  2. Push a tag: git tag py-v0.1.0 && git push origin py-v0.1.0
  3. GitHub Actions builds macOS / Linux / Windows wheels plus an sdist, then uploads to PyPI.

Bump version in python/pyproject.toml and python/Cargo.toml (keep in sync with the root Rust crate when releasing together).

Dry-run CI locally

From the repository root (same layout as GitHub Actions):

# macOS wheel (needs python.org CPython framework, e.g. 3.9 from python.org)
uv tool run cibuildwheel --platform macos --output-dir wheelhouse python

# Linux wheel — closest match to CI; requires Docker
uv tool run cibuildwheel --platform linux --output-dir wheelhouse python

# Windows wheel — only on Windows
uv tool run cibuildwheel --platform windows --output-dir wheelhouse python

Note: the GitHub Action uses package-dir: python; the CLI equivalent is the positional python argument at the end (not --package-dir).

On macOS outside CI, cibuildwheel expects official python.org framework installs. If you only have Homebrew/uv Python, either install the python.org pkg or use the simpler dev loop below.

Quick local check without cibuildwheel (builds a wheel for your current machine only):

cd python
uv sync
uv run maturin build --release
uv run pytest -k "not symbolic"

Smoke-test a built wheel:

uv venv /tmp/simsam-wheel-test
source /tmp/simsam-wheel-test/bin/activate
pip install wheelhouse/simsam_rs-*.whl   # or python/target/wheels/*.whl
pytest python/tests -k "not symbolic"

Skip cibuildwheel tests while debugging build-only issues:

CIBW_TEST_SKIP='*' uv tool run cibuildwheel --platform macos --output-dir wheelhouse python

Optional symbolic builds (not published to PyPI by default)

uv run maturin develop --release --features symbolic,pyo3/extension-module

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simsam_rs-0.1.0.tar.gz (86.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

simsam_rs-0.1.0-cp38-abi3-win_amd64.whl (328.2 kB view details)

Uploaded CPython 3.8+Windows x86-64

simsam_rs-0.1.0-cp38-abi3-win32.whl (301.2 kB view details)

Uploaded CPython 3.8+Windows x86

simsam_rs-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (461.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

simsam_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (402.7 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file simsam_rs-0.1.0.tar.gz.

File metadata

  • Download URL: simsam_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 86.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simsam_rs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f268c488d168124d98154213633c2621141e37676449414566c33b86b3f6e0e
MD5 e8840625e3a775a7c1b647a1795a4553
BLAKE2b-256 00495b3e291444bb4939dbc1b080f8eb570fb99e9d9cf06bdc0f8c5a6ed057cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for simsam_rs-0.1.0.tar.gz:

Publisher: publish-pypi.yml on shanziheng1721/simsam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simsam_rs-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: simsam_rs-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 328.2 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simsam_rs-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 459749b830b3cb43d82eaf0487a1fdce4db45bbb90ea70f9bb3e449410f52732
MD5 a541c3a41158d88998e996f3e7044808
BLAKE2b-256 2317669d62e0b63dac2b153e55afe3f7af73be4fea42659baf82bd3c6d064b21

See more details on using hashes here.

Provenance

The following attestation bundles were made for simsam_rs-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on shanziheng1721/simsam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simsam_rs-0.1.0-cp38-abi3-win32.whl.

File metadata

  • Download URL: simsam_rs-0.1.0-cp38-abi3-win32.whl
  • Upload date:
  • Size: 301.2 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simsam_rs-0.1.0-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 0e5106176bf9d7aeb1fc919b0c6e0d96815cfab8f2613a2504b73b8edbd0f815
MD5 a8b3564285caa5dc5435972638f457d9
BLAKE2b-256 0355cd38a5607ebb1942fdefbcd906de6481f6692a8182b5dbcf1be5034593e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for simsam_rs-0.1.0-cp38-abi3-win32.whl:

Publisher: publish-pypi.yml on shanziheng1721/simsam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simsam_rs-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for simsam_rs-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f1820742d5239c5fc19ab5649c4faafbb077b3cce36927ac5fa2636fe5e75e2c
MD5 e36276b672b7121d698e4be5de568ef0
BLAKE2b-256 1c1b8defec912121cd9be320a0220e298f364a5bd03e93e846887ef1176462d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for simsam_rs-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: publish-pypi.yml on shanziheng1721/simsam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simsam_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for simsam_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61d09391c3a3d414c91640fa5666a5d31f8538fb945382ddb93349ffb66a219c
MD5 42feaef53885e2cd61c1a86cde6b03c1
BLAKE2b-256 e22bd4be53f74c1e59ea8cd67e7ba013ada3ad59474594e7479810f920cab317

See more details on using hashes here.

Provenance

The following attestation bundles were made for simsam_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on shanziheng1721/simsam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page