Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Windows #205

Merged
merged 12 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: 🪟 Windows

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-windows
cancel-in-progress: true

jobs:
build_win_msvc:
name: MSVC C++17 w/o MPI
runs-on: windows-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.x'
- name: CCache Cache
uses: actions/cache@v2
# - once stored under a key, they become immutable (even if local cache path content changes)
# - for a refresh the key has to change, e.g., hash of a tracked file in the key
with:
path: |
~/.ccache
~/.cache/ccache
key: ccache-windows-winmsvc-${{ hashFiles('.github/workflows/windows.yml') }}-${{ hashFiles('cmake/dependencies/ABLASTR.cmake') }}
restore-keys: |
ccache-windows-winmsvc-${{ hashFiles('.github/workflows/windows.yml') }}-
ccache-windows-winmsvc-
- name: Build & Install
run: |
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -r requirements.txt
python3 -m pip install -r examples/requirements.txt

cmake -S . -B build `
-DBUILD_SHARED_LIBS=OFF `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_VERBOSE_MAKEFILE=ON `
-DImpactX_COMPUTE=NOACC `
-DImpactX_MPI=OFF `
-DImpactX_PYTHON=ON
if(!$?) { Exit $LASTEXITCODE }
cmake --build build --config RelWithDebInfo --parallel 2
if(!$?) { Exit $LASTEXITCODE }
cmake --build build --config RelWithDebInfo --target pip_install
if(!$?) { Exit $LASTEXITCODE }

ctest --test-dir build --build-config RelWithDebInfo --output-on-failure -E "(AMReX|py|pytest|analysis|plot)"
if(!$?) { Exit $LASTEXITCODE }

build_win_clang:
name: Clang C++17 w/ OMP w/o MPI
runs-on: windows-2019
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.x'
- name: CCache Cache
uses: actions/cache@v2
# - once stored under a key, they become immutable (even if local cache path content changes)
# - for a refresh the key has to change, e.g., hash of a tracked file in the key
with:
path: |
~/.ccache
~/.cache/ccache
key: ccache-windows-winclang-${{ hashFiles('.github/workflows/windows.yml') }}-${{ hashFiles('cmake/dependencies/ABLASTR.cmake') }}
restore-keys: |
ccache-windows-winclang-${{ hashFiles('.github/workflows/windows.yml') }}-
ccache-windows-winclang-
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build & Install
shell: cmd
run: |
python3 -m pip install -U pip setuptools wheel pytest
python3 -m pip install -r requirements.txt
python3 -m pip install -r examples/requirements.txt

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\vc\Auxiliary\build\vcvarsall.bat" x64
cmake -S . -B build ^
-G "Ninja" ^
-DCMAKE_C_COMPILER=clang-cl ^
-DCMAKE_CXX_COMPILER=clang-cl ^
-DBUILD_SHARED_LIBS=OFF ^
-DCMAKE_BUILD_TYPE=Release ^
ax3l marked this conversation as resolved.
Show resolved Hide resolved
-DCMAKE_VERBOSE_MAKEFILE=ON ^
-DImpactX_COMPUTE=OMP ^
-DImpactX_MPI=OFF ^
-DImpactX_PYTHON=ON
if errorlevel 1 exit 1
cmake --build build --config Release --parallel 2
if errorlevel 1 exit 1
cmake --build build --config Release --target pip_install
if errorlevel 1 exit 1

ctest --test-dir build --build-config Release --output-on-failure -E "(AMReX|py|pytest|analysis|plot)"
if errorlevel 1 exit 1
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ if(ImpactX_PYTHON)

# build the wheel by re-using the lib library we build
add_custom_target(${ImpactX_CUSTOM_TARGET_PREFIX}pip_wheel
${CMAKE_COMMAND} -E rm -f "impactx*.whl"
${CMAKE_COMMAND} -E rm -f -r impactx-whl
COMMAND
${CMAKE_COMMAND} -E env PYIMPACTX_LIBDIR=$<TARGET_FILE_DIR:pyImpactX>
${Python_EXECUTABLE} -m pip wheel -v --no-build-isolation ${ImpactX_SOURCE_DIR}
${Python_EXECUTABLE} -m pip wheel -v --no-build-isolation --no-deps --wheel-dir=impactx-whl ${ImpactX_SOURCE_DIR}
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
DEPENDS
Expand Down Expand Up @@ -408,7 +408,7 @@ if(ImpactX_PYTHON)
# because otherwise pip would also force reinstall all dependencies.
add_custom_target(${ImpactX_CUSTOM_TARGET_PREFIX}pip_install
${CMAKE_COMMAND} -E env IMPACTX_MPI=${ImpactX_MPI}
${Python_EXECUTABLE} -m pip install --force-reinstall --no-deps ${PYINSTALLOPTIONS} "impactx*.whl"
${Python_EXECUTABLE} -m pip install --force-reinstall --no-index --no-deps ${PYINSTALLOPTIONS} --find-links=impactx-whl impactx
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
DEPENDS
Expand Down
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
include README.md LICENSE
include README.md LICENSE.txt
include CODE_OF_CONDUCT.rst CONTRIBUTING.rst
include pyproject.toml
include requirements.txt
include requirements.txt requirements_mpi.txt

global-include CMakeLists.txt *.cmake *.in

recursive-include cmake *
recursive-include docs *
recursive-include etc *
recursive-include examples *
recursive-include include *
recursive-include src *
recursive-include tests *

Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,27 @@ 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:
# spack add cuda
# spack add python
# spack add py-pip
# spack add py-pandas
# spack add py-numpy
# spack add py-scipy
# 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)
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 pandas scipy
conda create -n impactx-dev -c conda-forge adios2 ccache cmake compilers git hdf5 fftw matplotlib ninja numpy pandas pytest scipy
conda activate impactx-dev

# compile with -DImpactX_MPI=OFF
Expand Down Expand Up @@ -294,8 +294,7 @@ Examples:

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

Expand Down
2 changes: 1 addition & 1 deletion cmake/dependencies/ABLASTR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ set(ImpactX_ablastr_branch "22.08"
set(ImpactX_amrex_repo "https://github.com/AMReX-Codes/amrex.git"
CACHE STRING
"Repository URI to pull and build AMReX from if(ImpactX_amrex_internal)")
set(ImpactX_amrex_branch "1bda173b489024d5f4ec79627f3f612c350e521f"
set(ImpactX_amrex_branch "bd5f6a9f6a1a3a66c51eefd7950432d3bf3319a1"
CACHE STRING
"Repository branch for ImpactX_amrex_repo if(ImpactX_amrex_internal)")

Expand Down
4 changes: 2 additions & 2 deletions docs/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +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
python3 -m pip install -r requirements.txt
python3 -m pip install -U pip 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 @@ -76,7 +76,8 @@ Compile including Python Bindings

.. code-block:: bash

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

For PICMI Python bindings, add a configure option and call our ``pip_install`` *CMake target*:

Expand Down
23 changes: 8 additions & 15 deletions docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,21 @@ Spack (macOS/Linux)
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:
# spack add cuda
# spack add python
# spack add py-pip
# spack add py-pip
# spack add py-pandas
# spack add py-numpy
# spack add py-scipy
# 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)

If you also want to run runtime tests and added Python (``spack add python`` and ``spack add py-pip``) above, install also these additional Python packages in the active Spack environment:

.. code-block:: bash

python3 -m pip install matplotlib yt scipy numpy openpmd-api
In new terminals, re-activate the environment with ``spack env activate impactx-dev`` again.


Brew (macOS/Linux)
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function(impactx_test_set_pythonpath test_name)
if(WIN32)
string(REPLACE ";" "\\;" WIN_PYTHONPATH "$ENV{PYTHONPATH}")
string(REGEX REPLACE "/" "\\\\" WIN_PYTHON_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY})
set_tests_properties(TEST ${test_name}
set_tests_properties(${test_name}
PROPERTIES ENVIRONMENT "PYTHONPATH=${WIN_PYTHON_OUTPUT_DIRECTORY}\;${WIN_PYTHONPATH}"
)
else()
Expand Down
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ def build_extension(self, ext):
#if ImpactX_pyamrex_src:
# cmake_args.append('-DImpactX_pyamrex_src=' + ImpactX_pyamrex_src)

if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not None:
cmake_args.append('-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=' +
CMAKE_INTERPROCEDURAL_OPTIMIZATION)
if sys.platform == "darwin":
cmake_args.append('-DCMAKE_INSTALL_RPATH=@loader_path')
else:
# values: linux*, aix, freebsd, ...
# just as well win32 & cygwin (although Windows has no RPaths)
cmake_args.append('-DCMAKE_INSTALL_RPATH=$ORIGIN')

cmake_args += extra_cmake_args

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]

Expand Down Expand Up @@ -186,6 +191,8 @@ def build_extension(self, ext):
ImpactX_SPACEDIM = os.environ.get('IMPACTX_SPACEDIM', '3')
BUILD_SHARED_LIBS = os.environ.get('IMPACTX_BUILD_SHARED_LIBS',
'OFF')
CMAKE_INTERPROCEDURAL_OPTIMIZATION = os.environ.get(
'CMAKE_INTERPROCEDURAL_OPTIMIZATION', None)
# CMake dependency control (developers & package managers)
ImpactX_amrex_src = os.environ.get('IMPACTX_AMREX_SRC')
ImpactX_amrex_internal = os.environ.get('IMPACTX_AMREX_INTERNAL', 'ON')
Expand All @@ -198,6 +205,16 @@ def build_extension(self, ext):
# 'https://github.com/AMReX-Codes/pyamrex.git')
#ImpactX_pyamrex_branch = os.environ.get('IMPACTX_PYAMREX_BRANCH', 'development')

# extra CMake arguments
extra_cmake_args = []
for k, v in os.environ.items():
extra_cmake_args_prefix = "IMPACTX_CMAKE_"
if k.startswith(extra_cmake_args_prefix) and \
len(k) > len(extra_cmake_args_prefix):
extra_cmake_args.append("-D{0}={1}".format(
k[len(extra_cmake_args_prefix):],
v))

# https://cmake.org/cmake/help/v3.0/command/if.html
if ImpactX_MPI.upper() in ['1', 'ON', 'TRUE', 'YES']:
ImpactX_MPI = "ON"
Expand Down