Installation¶
Requirements¶
pyg4ometry is developed exclusively for Python 3 (Python2 is deprecated). It is developed on Python 3.9 and 3.10.
VTK (Visualisation toolkit) (including Python bindings)
pybind11
Packages that are required but will be found through PIP automatically:
pandas
pypandoc
networkx
numpy
sympy
Optional
Freecad for CAD conversion.
Note
A full list can be found in pyg4ometry/setup.py.
Note
if you are choosing a python version, it is worth choosing according to which version VTK provides a python build of through PIP if you use that. See https://pypi.org/project/vtk/#files For example, there are limited builds for M1 Mac (ARM64).
Installation¶
To install pyg4ometry, simply run make install from the root pyg4ometry
directory:
cd /my/path/to/repositories/
git clone http://bitbucket.org/jairhul/pyg4ometry
git checkout develop
cd pyg4ometry
make install
Note
To build using the git directory and not installing into /usr/local use make develop
instead of make install
To build pycsg with cpython:
make build_ext
Or install from pypi:
pip install pyg4ometry
or alternatively, run make develop from the same directory to ensure
that any local changes are picked up.
Docker image¶
Download and install Docker desktop
open a terminal (linux) or cmd (windows)
Download the pyg4ometry docker file
docker build -t ubuntu-pyg4ometry -f Dockerfile-ubuntu-pyg4ometry .
If you need to update increment the variable ARG PYG4OMETRY_VER=1
To start the container
open a terminal (linux/mac) or cmd (windows)
get your IP address
ifconfig(linux/mac) oripconfig /all(windows)Start XQuartz (mac) or Xming/Vxsrv (windows). For Xming/Vxsrv (might need to play with the settings when launching)
docker run -ti -v /tmp/.X11-unix:/tmp/.X11-unix -v YOURWORKDIR:/tmp/Physics -e DISPLAY=YOUR_IP ubuntu-pyg4ometry(the-v /tmp/.X11-unix:/tmp/.X11-unixis only required for mac/linux)
Test the installation
docker> cd pyg4ometry/pyg4ometry/test/pythonGeant4/docker> ipythonpython> import pyg4ometrypython> import T001_Boxpython> T001_Box.Test(True,True)
Linux installation¶
There are docker files for Centos 7 and Ubuntu 20. The docker files can be used as list of instructions for installation for each of these OSes.
FreeCAD support for CAD to GDML conversion¶
For FreeCAD support and you already have it installed you need to add library to PYTHONPATH, for example
export PYTHONPATH=/opt/local/libexec/freecad/lib/
Building FreeCAD can be a pain for MAC so
mkdir FreeCAD
cd FreeCAD
set FCROOT=$pwd
wget https://github.com/FreeCAD/FreeCAD/archive/refs/tags/0.19.4.tar.gz
tar zxf 0.19.4.tar.gz
mkdir build
mkdir install
cd build
cmake ../FreeCAD-0.19.4 -DCMAKE_INSTALL_PREFIX=../install \
-DCOIN3D_LIBRARIES=/opt/local/Library/Frameworks/Inventor.framework/Libraries/libCoin.dylib -DBUILD_FEM=0 \
-DBUILD_MATERIAL=0 -DBUILD_SHIP=0 -DBUILD_DRAFT=0 -DBUILD_TUX=0 -DBUILD_ARCH=0 -DBUILD_PLOT=0 \
-DBUILD_OPENSCAD=0
make -jN
make install
export PYTHONPATH=$PYTHONPATH:$FCROOT/install
Python 3.9¶
At the time of writing, there are limited VTK distributions for Python 3.9 on pypi (what
PIP uses when finding packages). However,
you can have VTK with Python 3.9 through say MacPorts or by compiling it yourself. In this
case, you can comment out the VTK requirement from the setup.py around line 86, as long
as you know you can import vtk ok in your Python installation.
Warning
ANTLR will create an unbelievable amount of warnings when using a different ANRLR version that the one the parser was generated with. It should work though. We are trying to include multiple versions of the ANTLR parser to avoid this in future.