diff --git a/README.md b/README.md index 90c9642a..ad72d81b 100644 --- a/README.md +++ b/README.md @@ -40,33 +40,35 @@ print("Average pT for charged pions {0:4.3f}".format(average_pt)) - Python 3.6+ - Linux, Mac OS X, or Windows -### Without docker +### From PyPI (not yet available) -If you have trouble with this installation guide, look into the subsection which explains how to install in impy in a fixed docker environment. + pip install impy -The package is (will be) available including pre-compiled binaries. The installation in that case simplifies to (*this does not work yet use installation from source*): +The package will be available as a pre-compiled binary wheels in the future, but for now you have to compile it from source, see next subsection. - pip install impy +### From source -To build from source (the **recursive** flag is important to checkout the sub-modules): +Installation from source requires a Python installation setup for development, as well as C and Fortran compilers. + +To build from source (the **recursive** flag is important to check out submodules): git clone --recursive https://github.com/impy-project/impy cd impy - pip install -e . - make -j + pip install -v -e . -For now, you need to call make by hand, but this will be automated. The command `pip install -e .` installs the package in editable mode (for developers). +This takes a while. The command `pip install -v -e .` installs the package in editable mode (for developing the Python layer) and with verbose output, so that you can watch the compilation happening. Warnings can be ignored, but watch out for errors. -Because of the architectural transition and there are many issues on mac, building from source may be a bit complicated. Using brew gcc and python it is possible to build the code by: +To run the tests or try the examples, it is convenient use this modified `pip install` instead: - CC=gcc-10 CXX=gcc-10 FC=gfortran-10 PYTHON_EXE=/usr/local/opt/python@3.8/bin/python3 make -jXXX + pip install -v -e .'[test,examples]' -Replace `gcc-10` by your version in brew. The official Mac Python is currently broken due to the transition to Apple Silicon, but it is possible to build with a bit of hacking. But currently -I don't use a Mac and cannot debug it. - -### With docker +This installs impy and additional optional Python packages to run tests and examples. -This guide works on Linux and OSX. You need a running docker server. Please google how to set up docker on your machine. +If installation from source fails, please look into the subsection below which explains how to install in impy in a verified docker environment. The docker environment has a properly set up environment verified by us, so that the installation is guaranteed to succeed. + +### From source in Docker + +This guide works on Linux and OSX. You need a running Docker server. Please google how to set up Docker on your machine. # download impy git clone --recursive https://github.com/impy-project/impy @@ -80,30 +82,37 @@ This guide works on Linux and OSX. You need a running docker server. Please goog # docker pull quay.io/pypa/manylinux2014_aarch64 # create docker instance and bind impy directory - docker run -d -it --name impy -v "$(pwd)":/app quay.io/pypa/manylinux2014_x86_64 + docker run --rm -d -it --name impy -v "$(pwd)":/app quay.io/pypa/manylinux2014_x86_64 # enter your docker instance docker exec -it impy /bin/bash cd /app - # select python version, e.g. 3.8, and enter virtual environment - python3.8 -m venv venv + # select python version, e.g. 3.9, and enter virtual environment + python3.9 -m venv venv source venv/bin/activate # install impy and dependencies (prefer binary wheels for deps) - pip install --prefer-binary -e . + pip install --prefer-binary -v -e . + +You can now use impy inside the docker instance. If you run Linux, you can also make a wheel inside +docker and install it in your host. + + # inside docker + pip install wheel + python setup.py bdist_wheel - # compile the FORTRAN interface (this will be automated in the future) - make -j + # exit docker with ctrl+D + pip install dist/*.whl -You can now use impy inside the docker instance. +This should allow you to use impy also outside docker. This works only if you use the same Python version inside and outside of docker. ## User interface There are two ways to interact with the code. -1. As in the example above, via plain python in scripts or jupyter notebooks. Look at this [example](examples/compare_two_models.ipynb). +1. As in the example above, via plain python in scripts or Jupyter notebooks. Look at this [example](examples/compare_models.ipynb). 2. Via a HEPMC output that can be piped in Rivet or other tools supporting the format. diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a6141a62..00000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -numpy -scipy -particletools -pyyaml -pyhepmc - ng -six -pytest diff --git a/setup.cfg b/setup.cfg index 213106e4..f7a2870e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,6 @@ install_requires = numpy scipy pyhepmc - six particletools [options.packages.find] @@ -47,6 +46,8 @@ examples = boost-histogram particle matplotlib + tqmd + joblib [flake8] max-line-length = 90 diff --git a/src/impy/common.py b/src/impy/common.py index 62162dc5..f5799cc3 100644 --- a/src/impy/common.py +++ b/src/impy/common.py @@ -7,8 +7,7 @@ such as the rapidity :func:`MCEvent.y` or the laboratory momentum fraction :func:`MCEvent.xlab`. """ -import six -from abc import ABCMeta, abstractmethod, abstractproperty +from abc import ABC, abstractmethod, abstractproperty import numpy as np from impy import impy_config @@ -53,7 +52,7 @@ def __init__( self._vt_arr = vt_arr -class MCEvent(object, six.with_metaclass(ABCMeta)): +class MCEvent(ABC): """The basis of interaction between user and all the event generators. The derived classes are expected to interact with the particle stack @@ -376,7 +375,7 @@ def fw(self): # ========================================================================= # Settings # ========================================================================= -class Settings(six.with_metaclass(ABCMeta)): +class Settings(ABC): """Custom classes derived from this template allow to set certain low level variables in the generators before or after initialization, or for each event. @@ -424,7 +423,7 @@ def __ne__(self, other_instance): other_attr = other_instance.__dict__ - for attr, value in six.iteritems(self.__dict__): + for attr, value in self.__dict__.items(): if attr == "lib": continue elif attr not in other_attr.keys(): @@ -437,7 +436,7 @@ def __ne__(self, other_instance): # ========================================================================= # MCRun # ========================================================================= -class MCRun(six.with_metaclass(ABCMeta)): +class MCRun(ABC): #: Prevent creating multiple classes within same python scope _is_initialized = [] diff --git a/src/impy/kinematics.py b/src/impy/kinematics.py index 6befc2ea..b34a669d 100644 --- a/src/impy/kinematics.py +++ b/src/impy/kinematics.py @@ -15,7 +15,6 @@ """ -import six import numpy as np from impy import pdata from impy.util import info @@ -309,7 +308,7 @@ def __setstate__(self, state): } def __ne__(self, other): - for key, value in six.iteritems(other.__dict__): + for key, value in other.__dict__.items(): if key == "boost_def": continue if value != self.__dict__[key]: diff --git a/src/impy/writer.py b/src/impy/writer.py index 51efd918..972b2e60 100644 --- a/src/impy/writer.py +++ b/src/impy/writer.py @@ -1,8 +1,7 @@ -from abc import ABCMeta, abstractmethod -from six import with_metaclass +from abc import ABC, abstractmethod -class Writer(object, with_metaclass(ABCMeta)): +class Writer(ABC): @abstractmethod def write(self, event): pass