Skip to main content

Alternative python bindings for Geant4 via pybind11

Project description

Python bindings for Geant4

Tests Wheel PyPI

Alternative Python bindings for Geant4 via pybind11. It is loosely based on g4py, but retains an API closer to the standard C++ API and does not require Boost.Python.

It currently includes all g4py bindings plus a large portion of very commonly used classes and functions that aren't currently present in g4py. However, it is still far off from replicating the full Geant4 API and is thus (currently) only applicable for simple simulations.

Installation

It's available on PyPI for all major platforms as a fully self-contained (i.e. statically linked) wheel.

pip install geant4-pybind

Note: Windows users may need to install the visual C++ redistributable package if it's not already installed.

Building

Unix (Linux, OS X) prerequisits

Windows prerequisits

Note: If you haven't downloaded the required datasets yet don't worry, you can let geant4_pybind handle them.

Installation

git clone --recursive https://github.com/HaarigerHarald/geant4_pybind
pip install ./geant4_pybind

Windows notes

The above commands have to be executed in a "Developer Command Prompt for VS 2019" and require that Python3, pip and git are added to the PATH environment variable.

General notes

If the repository was cloned non-recursively you can check out the submodule with:

git -C ./geant4_pybind submodule update --init

Usage

Minimal

A minimal example that just starts a Geant4 shell:

from geant4_pybind import *
import sys

ui = G4UIExecutive(len(sys.argv), sys.argv)
ui.SessionStart()

Full examples

Check out the examples directory, which contains the Geant4 basic examples ported to Python. However, writing simulations in Python should be pretty straight forward as the API is almost identical to the C++ one. One notable exception are template classes, which have been renamed such that their type replaces the T (i.e. G4TScoreNtupleWriter<G4RootAnalysisManager> becomes G4RootScoreNtupleWriter).

Bugs?

Yes!

Though the bigger problem is probably that there is still quite a bit missing.

License

This builds upon Geant4 and g4py and thus the Geant4 license applies. The binding code uses pybind11. All my contributions are public domain.

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

geant4_pybind-0.1.0b4.tar.gz (275.8 kB view details)

Uploaded Source

Built Distributions

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

geant4_pybind-0.1.0b4-cp39-cp39-win_amd64.whl (11.7 MB view details)

Uploaded CPython 3.9Windows x86-64

geant4_pybind-0.1.0b4-cp39-cp39-manylinux2010_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b4-cp39-cp39-macosx_10_9_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

geant4_pybind-0.1.0b4-cp38-cp38-win_amd64.whl (11.4 MB view details)

Uploaded CPython 3.8Windows x86-64

geant4_pybind-0.1.0b4-cp38-cp38-manylinux2010_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b4-cp38-cp38-macosx_10_9_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

geant4_pybind-0.1.0b4-cp37-cp37m-win_amd64.whl (11.4 MB view details)

Uploaded CPython 3.7mWindows x86-64

geant4_pybind-0.1.0b4-cp37-cp37m-manylinux2010_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b4-cp37-cp37m-macosx_10_9_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

geant4_pybind-0.1.0b4-cp36-cp36m-win_amd64.whl (11.4 MB view details)

Uploaded CPython 3.6mWindows x86-64

geant4_pybind-0.1.0b4-cp36-cp36m-manylinux2010_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b4-cp36-cp36m-macosx_10_9_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

geant4_pybind-0.1.0b4-cp35-cp35m-win_amd64.whl (11.4 MB view details)

Uploaded CPython 3.5mWindows x86-64

geant4_pybind-0.1.0b4-cp35-cp35m-manylinux2010_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

geant4_pybind-0.1.0b4-cp35-cp35m-macosx_10_9_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

Details for the file geant4_pybind-0.1.0b4.tar.gz.

File metadata

  • Download URL: geant4_pybind-0.1.0b4.tar.gz
  • Upload date:
  • Size: 275.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4.tar.gz
Algorithm Hash digest
SHA256 48abe75a1e2d96604c6964afcfe0b6acd8e72ea17b1636714b472ee772d6a3e8
MD5 78a690eb4b3990abfe3ee2ee15aa40c0
BLAKE2b-256 64083736671655d1d5b720306ab3396e47114e298891454bda9410d2587481bc

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 11.7 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ecccf8184d5a3171cc2c59ecf4c2090f112939d1057489e30e3d1febbdec2210
MD5 7204698b530c152349a36e367e3be033
BLAKE2b-256 19ba01aa4101866fab9cdc2cca090ddfcdf9bb7eddb930112f6b0bbb876a6001

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 88d9f266a2f368d6035168cf9de02223b97e025e3659d005c455cf1e96728216
MD5 80c777780f1dce7d69566e3439a44748
BLAKE2b-256 8565a3a1ce2dd97eaf25310fa51263c8dfba478a23daf2302741f236f4586b83

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cee5d5839335998fae6c7fa9d2aa16cbb1242a10a3e285f4891b62550325ccd4
MD5 07226b838503bc14ae4735785be822e2
BLAKE2b-256 55345555e73684dd1d3eceacfcb0cb9c6e0df0ec9c798b4df8e213e952120026

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 77f19236cbd4ed95ea9b91f236d824c701aef9914138f860efb8218c8509d498
MD5 c2bc3d29422dbc97ecec82a683d8de70
BLAKE2b-256 d7e8caed66bc36b79134f6161b19065bc5d7997787c8fbf62bd7ecc228a6a6cd

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e45142b58fc83e253c9286d1990af2eb06ad6e56134a951ae97f08c2b246977f
MD5 54983eca6edb03969c8e3bafd9b36620
BLAKE2b-256 6580b8589c0c1dcd9aed41ffbce3f1f959f7b29484933af7e1f3bba308b025e2

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1fc1716829178e4e3ac9029c11de99283268db11b2ff5870cb9b0f6efa57a43d
MD5 2b5a03a58780cfe6f709089cc9ab54e4
BLAKE2b-256 f6c0d2fd6ff12cb3d8c89f9f5fbe5cc1be26372b04b91c141355163879c8c5ae

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 08a21bc84849a82e4328a3e93591556fb62ab51e76a680a7057fec7a15b355ad
MD5 043ee8def39c22f1002437fc5f3bbf3d
BLAKE2b-256 46de7b99b83dd5aec31d75b538ff2ba95c12a75b0067618c9ba8ebde6b49a8bf

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1b893c53e74b1944812d2b2931ba371571e5fb7192e2e20f99b3e03cfea1f81f
MD5 8b70afb698cf023cd621ab8af2b229b9
BLAKE2b-256 4a559b2474e46b7918f0674f77235ae3a3e5b043a7c49638bbf5741e9dc836aa

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3d6950a80bb99ed7843b6646c285fe3c9195ef54a87104464ee680416998ba66
MD5 b5287b1701a76a6294b3b0a5f24b5261
BLAKE2b-256 cc68c40a81f209979a1c8c748bb013ac27009f364aef521aed6fb9d02c7f7df4

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e0f4ecc147d61f965af89bdf24bcb9af3e07cfa19975497fc95733f0d2ebcc07
MD5 40364a256cdabf86329090659d61ebd2
BLAKE2b-256 5816540d16f419e050a32c346f54c0d9f704121673c02845d3e56a9d00a1ea14

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f45ee573eeb9959baf0529dc40ddf854fc52a448829a8b1adfe08fa16e1360ca
MD5 10824180fc28925b47b07f6be087849b
BLAKE2b-256 8caee717718a82dc3dc67581efe8ada69bc3844717e8a6adb7d516a7246d1253

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0bc5f324183d6e14a4892e7316bb3d382621051f2069f67f6dc1bcbcd8ca1d11
MD5 390b2fcdce54f2a2ccea49ab5fc091c1
BLAKE2b-256 2131a2249033cf424f15ccd8ed89df5bfdea7fa1a118b08f13aa9fa960390f30

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 37ef06fcdafa3e15882db62ae9f028f35836e44dfc11131315125e640e2fa5a2
MD5 e0d833b1aedd0f973b19f417e87c2e9a
BLAKE2b-256 14960a1d5d0664bbb15aebfe125dc8e99109286252edb759ce4c0f8dd2b86d14

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1c4c0a8eeb2591c988f1c642495d8a90e550753d3ff8604e4b5a2a5a55792902
MD5 8e66b22dcbb903d3f92a35ae3c4024dc
BLAKE2b-256 76b6a9ce772e1290320be8409af87cf1d21711e7ae8a7b5e4806bfa9f861cb22

See more details on using hashes here.

File details

Details for the file geant4_pybind-0.1.0b4-cp35-cp35m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: geant4_pybind-0.1.0b4-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for geant4_pybind-0.1.0b4-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 588fb20dfd4bea2919447f8d885df800eafbcf34ba279f4fc4f090a4719d6828
MD5 051badf5c59fefa55ec2e9bed4e588af
BLAKE2b-256 2a12b419038f3260e7cc442600f1cf764c96e91750c9a97534e59e1ddf648650

See more details on using hashes here.

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