g42so
This is g42so, a simple Python script that compiles
Geant4 detector-construction and
primary-generator-action classes, wraps them in C-style (unmangled) adapter
functions and produces a shared library. The library can then be loaded via
dlopen by third-party code, allowing instantiation of a Geant4 detector
construction or primary generator action even if the name of the specific class
is not known in advance.
Installing g42so
The recommended installation procedure for g42so is to use pip:
$ pip install g42so
Quick tutorial
Compilation is delegated to g++ by default (no, I did
not reimplement gcc from scratch), but this can be configured using the -c
option. Note however that g42so must know what compilation flags to use for
your compiler; at the moment, it only recognizes g++ and clang++.
Running g42so -h gives a list of available options. You will typically want
to run something along the lines of the following:
$ g42so -I /path/to/include/ \
/path/to/src/MyDetectorConstruction.cc /path/to/src/MyPrimaryGeneratorAction.cc
Notes
-
Geant4 must be installed and the
geant4-configscript must be in the$PATH, or its location can be specified with the--geant4-configoption. -
g42sotries to automatically detect the names of the classes you want to wrap. If it fails or is unsure, it will ask you to explicitly specify your class names. -
If your class constructors require arguments, you will need to customise the C wrappers generated by the code. First run
$ g42so --dump-detector-wrapper >detectorWrapper.ccto dump the relevant wrapper. Modify it to your needs and pass it to
g42soalong with the--custom-detector-wrapperoption, which tellsg42sonot to include its default wrapper. For instance:$ g42so --custom-detector-wrapper -I /path/to/include/ \ /path/to/src/MyDetectorConstruction.cc detectorWrapper.ccThe
--dump-pga-wrapperand--custom-pga-wrapperdo the same job for primary-generator-action classes. -
Note that
dlopening shared libraries that link to Geant4 is likely to fail if Geant4 was compiled is multi-threaded mode (theGEANT4_BUILD_MULTITHREADEDCMake flag is set toON) with the default value for theGEANT4_BUILD_TLS_MODEL(the default isinitial-exec). If you want todlopenthe libraries created byg42so(which is the whole point of this tool, really!), then you should make sure that either Geant4 was compiled in single-threaded mode, orGEANT4_BUILD_TLS_MODELwas set toglobal-dynamic.
Metadata
Release files for g42so 0.3.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 | |
|---|---|---|---|
| g42so-0.3.0.tar.gz | 8.3 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| g42so-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
| g42so-0.3.0-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 29.5 kB
Release files / g42so-0.3.0.tar.gz
| Download URL | g42so-0.3.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd056527030d303c94c380c617e5b62289efa3ed8b3e762dcb38ec74cc5e364e
|
|
BLAKE2b-256 checksum How to use checksums |
6192cfe0cc13ad4ffe1ad39d7cd87639079974d02d89ded3c1ff35489d25a0bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2
|
Release files / g42so-0.3.0-py3-none-any.whl
| Download URL | g42so-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c51663fb3ceda9226f8dca23d1dab442f585035f6cc37fd8db7bca328fa10b6c
|
|
BLAKE2b-256 checksum How to use checksums |
c7f8fce4fe8ab9fb196b644d3f0c963599e32ff1304bb54d66e0ffc11e47a84a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2
|
Release files / g42so-0.3.0-py2-none-any.whl
| Download URL | g42so-0.3.0-py2-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
4ca7bed57dc160d31db30f787a5bed8cc15e06ebc9e9bad5332ec8837a13515f
|
|
BLAKE2b-256 checksum How to use checksums |
38eb09bf9d0924481ed4744f28f724a9cb2be40a7313bde47f61eb98a6113db7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2
|