Installation

Requirements

pyg4ometry is developed exclusively for Python 3 (Python2 is deprecated). It is developed on Python 3.9 and 3.10.

Packages that are required but will be found through PIP automatically:

Optional

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

  1. Download and install Docker desktop

  2. open a terminal (linux) or cmd (windows)

  3. (windows) Start Xming or Vxsrv

  4. Download the pyg4ometry docker file

  5. 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

  1. open a terminal (linux/mac) or cmd (windows)

  2. get your IP address ifconfig (linux/mac) or ipconfig /all (windows)

  3. Start XQuartz (mac) or Xming/Vxsrv (windows). For Xming/Vxsrv (might need to play with the settings when launching)

  4. 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-unix is only required for mac/linux)

Test the installation

  1. docker> cd pyg4ometry/pyg4ometry/test/pythonGeant4/

  2. docker> ipython

  3. python> import pyg4ometry

  4. python> import T001_Box

  5. python> 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.