Skip to content

Commit

Permalink
Remove distutils
Browse files Browse the repository at this point in the history
Distutils is gone in Python 3.12+.
  • Loading branch information
ax3l committed Oct 27, 2023
1 parent 38e4167 commit adf0f51
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 205 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dependencies/clang-san-openmpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ sudo apt-get install -y \
python3-pip \
wget

python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel
python3 -m pip install -U cmake pytest
python3 -m pip install -U -r requirements_mpi.txt
python3 -m pip install -U -r examples/requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dependencies/clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ sudo apt-get install -y \
python3-pip \
wget

python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel
python3 -m pip install -U cmake pytest
python3 -m pip install -U -r requirements_mpi.txt
python3 -m pip install -U -r examples/requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dependencies/gcc-openmpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ sudo apt-get install -y \
python3-pip \
wget

python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel
python3 -m pip install -U cmake pytest
python3 -m pip install -U -r requirements_mpi.txt
python3 -m pip install -U -r examples/requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dependencies/gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ sudo apt-get install -y \
python3-pip \
wget

python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel
python3 -m pip install -U cmake pytest
python3 -m pip install -U -r examples/requirements.txt

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
brew install ninja
brew install open-mpi
brew install pkg-config
python3 -m pip install --upgrade pip setuptools wheel pytest
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build packaging setuptools wheel pytest
python3 -m pip install --upgrade pytest
python3 -m pip install --upgrade -r requirements_mpi.txt
python3 -m pip install --upgrade -r examples/requirements.txt
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
$env:HDF5_DIR = "C:/Program Files/HDF_Group/HDF5/1.12.2/cmake/"
$env:HDF5_USE_STATIC_LIBRARIES = "ON"
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel pytest
python3 -m pip install -U -r requirements.txt
python3 -m pip install -U -r examples/requirements.txt
python3 -m pip install -U openPMD-validator
Expand Down Expand Up @@ -137,7 +138,8 @@ jobs:
set "HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.12.2/cmake/"
set "HDF5_USE_STATIC_LIBRARIES=ON"
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel pytest
python3 -m pip install -U -r requirements.txt
python3 -m pip install -U -r examples/requirements.txt
python3 -m pip install -U openPMD-validator
Expand Down
187 changes: 3 additions & 184 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,189 +30,7 @@ Our workflow is described in [CONTRIBUTING.rst](CONTRIBUTING.rst).

## Developer Environment

Please prepare you local development environment as follows.
Pick *one* of the methods below:

### Perlmutter (NERSC)

```bash
ssh perlmutter-p1.nersc.gov
```

Now ``cd`` to your ImpactX source directory.

```bash
module load cmake/3.22.0
module load cray-hdf5-parallel/1.12.2.1

# CCache for faster rebuilds
export PATH=/global/common/software/spackecp/perlmutter/e4s-22.05/78535/spack/opt/spack/cray-sles15-zen3/gcc-11.2.0/ccache-4.5.1-ybl7xefvggn6hov4dsdxxnztji74tolj/bin:$PATH

# Python
module load cray-python/3.9.13.1
if [ -d "$HOME/sw/perlmutter/venvs/impactx" ]
then
source $HOME/sw/perlmutter/venvs/impactx/bin/activate
else
python3 -m pip install --user --upgrade pip
python3 -m pip install --user virtualenv
python3 -m venv $HOME/sw/perlmutter/venvs/impactx
source $HOME/sw/perlmutter/venvs/impactx/bin/activate

python3 -m pip install --upgrade pip
MPICC="cc -target-accel=nvidia80 -shared" python3 -m pip install -U --no-cache-dir -v mpi4py
python3 -m pip install --upgrade pytest
python3 -m pip install --upgrade -r requirements.txt
python3 -m pip install --upgrade -r examples/requirements.txt
fi

# GPU-aware MPI
export MPICH_GPU_SUPPORT_ENABLED=1

# necessary to use CUDA-Aware MPI and run a job
export CRAY_ACCEL_TARGET=nvidia80

# optimize CUDA compilation for A100
export AMREX_CUDA_ARCH=8.0

# compiler environment hints
export CC=cc
export CXX=CC
export FC=ftn
export CUDACXX=$(which nvcc)
export CUDAHOSTCXX=CC
```

```bash
# work on an interactive node
salloc -N 1 --ntasks-per-node=4 -t 1:00:00 -C gpu --gpu-bind=single:1 -c 32 -G 4 --qos=interactive -A m3906_g

# configure
cmake -S . -B build_perlmutter -DImpactX_COMPUTE=CUDA -DImpactX_PYTHON=ON

# compile
cmake --build build_perlmutter -j 64

# test
ctest --test-dir build_perlmutter -E AMReX --output-on-failure

# run
cd build_perlmutter/bin
srun ./impactx ../../examples/fodo/input_fodo.in
```

### Cori KNL (NERSC)

```bash
ssh cori.nersc.gov
```

Now ``cd`` to your ImpactX source directory.

```bash
module swap craype-haswell craype-mic-knl
module swap PrgEnv-intel PrgEnv-gnu
module load cmake/3.22.1
module load cray-hdf5-parallel/1.10.5.2
module load cray-fftw/3.3.8.10

# Python
module load cray-python/3.9.7.1
if [ -d "$HOME/sw/knl/venvs/impactx" ]
then
source $HOME/sw/knl/venvs/impactx/bin/activate
else
python3 -m pip install --user --upgrade pip
python3 -m pip install --user virtualenv
python3 -m venv $HOME/sw/knl/venvs/impactx
source $HOME/sw/knl/venvs/impactx/bin/activate

python3 -m pip install --upgrade pip
MPICC="cc -shared" python3 -m pip install -U --no-cache-dir -v mpi4py
python3 -m pip install --upgrade pytest
python3 -m pip install --upgrade -r requirements.txt
python3 -m pip install --upgrade -r examples/requirements.txt
fi

# tune exactly for KNL sub-architecture
export CXXFLAGS="-march=knl"
export CFLAGS="-march=knl"
```

```bash
# configure
cmake -S . -B build_knl

# compile
cmake --build build_knl -j 8

# test
srun -C knl -N 1 -t 30 -q debug ctest --test-dir build_knl --output-on-failure

# run
cd build_knl/bin
srun -C knl -N 1 -t 30 -q debug ./impactx ../../examples/fodo/input_fodo.in
```

### Homebrew (macOS)

```bash
brew update
brew install adios2 # for openPMD
brew install ccache
brew install cmake
brew install fftw
brew install git
brew install hdf5-mpi # for openPMD
brew install libomp # for OpenMP
brew install pkg-config # for fftw
brew install open-mpi
```

### Apt (Debian/Ubuntu)

```bash
sudo apt update
sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-matplotlib python3-numpy python3-scipy
```

### Spack (Linux)

```bash
spack env create impactx-dev
spack env activate impactx-dev
spack add adios2 # for openPMD
spack add ccache
spack add cmake
spack add fftw
spack add hdf5 # for openPMD
spack add mpi
spack add pkgconfig # for fftw
spack add python
spack add py-pip
spack add py-setuptools
spack add py-wheel

# OpenMP support on macOS
[[ $OSTYPE == 'darwin'* ]] && spack add llvm-openmp

# optional: Linux only
#spack add cuda

spack install
python3 -m pip install matplotlib numpy openpmd-api pandas pytest scipy
```

In new terminals, re-activate the environment with `spack env activate impactx-dev` again.

### Conda (Linux/macOS/Windows)

```bash
conda create -n impactx-dev -c conda-forge adios2 ccache cmake compilers git hdf5 fftw matplotlib ninja numpy openpmd-api pandas pytest scipy
conda activate impactx-dev

# compile with -DImpactX_MPI=OFF
```
Please see our [developer installation section](https://impactx.readthedocs.io/en/latest/install/dependencies.html#install-dependencies) of the documentation for an easy install of our software dependencies.

## Get the Source Code

Expand Down Expand Up @@ -303,7 +121,8 @@ Examples:

In order to run our tests, you need to have a few Python packages installed:
```console
python3 -m pip install --upgrade pip setuptools wheel pytest
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build packaging setuptools wheel pytest
python3 -m pip install --upgrade -r examples/requirements.txt
```

Expand Down
3 changes: 2 additions & 1 deletion docs/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ In order to run our tests, you need to have a few :ref:`Python packages installe

.. code-block:: sh
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel pytest
python3 -m pip install -r examples/requirements.txt
Run
Expand Down
3 changes: 2 additions & 1 deletion docs/source/install/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ ImpactX depends on popular third party software.

.. code-block:: bash
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -U pip
python3 -m pip install -U build packaging setuptools wheel pytest
python3 -m pip install -U -r examples/requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
requires = [
"setuptools>=42",
"wheel",
"cmake>=3.20.0,<4.0.0"
"cmake>=3.20.0,<4.0.0",
"packaging>=23",
]
build-backend = "setuptools.build_meta"
18 changes: 7 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Authors: Axel Huebl
# License: BSD-3-Clause-LBNL
#
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.version import LooseVersion
import os
import platform
import re
Expand All @@ -16,6 +13,7 @@
import sys

from setuptools import Extension, setup
import setuptools.command.build
from setuptools.command.build_ext import build_ext


Expand All @@ -33,10 +31,8 @@ def run(self):
# by default, this stays around. we want to make sure generated
# files like libwarpx.(2d|3d|rz).(so|pyd) are always only the
# ones we want to package and not ones from an earlier wheel's stage
c = clean(self.distribution)
c.all = True
c.finalize_options()
c.run()
if os.path.exists(self.build_base):
shutil.rmtree(self.build_base)

# call superclass
build.run(self)
Expand Down Expand Up @@ -68,6 +64,8 @@ def __init__(self, name, sourcedir=""):

class CMakeBuild(build_ext):
def run(self):
from packaging.version import parse

try:
out = subprocess.check_output(["cmake", "--version"])
except OSError:
Expand All @@ -77,10 +75,8 @@ def run(self):
+ ", ".join(e.name for e in self.extensions)
)

cmake_version = LooseVersion(
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
)
if cmake_version < "3.20.0":
cmake_version = parse(re.search(r"version\s*([\d.]+)", out.decode()).group(1))
if cmake_version < parse("3.20.0"):
raise RuntimeError("CMake >= 3.20.0 is required")

for ext in self.extensions:
Expand Down

0 comments on commit adf0f51

Please sign in to comment.