Skip to content

Commit

Permalink
Merge branch 'main' into ess-main
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan F. Esteban Müller authored and Juan F. Esteban Müller committed Nov 7, 2024
2 parents b7417e5 + e77dfe2 commit 0a76d77
Show file tree
Hide file tree
Showing 273 changed files with 37,316 additions and 5,790 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: build-pyorbit

on:
pull_request:
branches:
- main
push:
tags:
- '*'
branches:
- '*'

jobs:


apple-silicon:
runs-on: macos-14
steps:
- name: Install packages
run: |
brew reinstall pkg-config fftw
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build
run: |
.github/workflows/pip-build.sh
- name: Test
run: |
.github/workflows/pip-tests.sh
- name: Print Versions
run: |
.github/workflows/pip-versions.sh
centos-stream:
runs-on: ubuntu-latest
container:
image: quay.io/centos/centos:stream9
steps:
- name: Install packages
run: |
dnf group install -y "Development Tools"
dnf install -y python3-devel fftw3-devel
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: |
.github/workflows/pip-build.sh
- name: Test
run: |
.github/workflows/pip-tests.sh
- name: Print Versions
run: |
.github/workflows/pip-versions.sh
ubuntu:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
steps:
- name: Install packages
run: |
apt-get update -y
apt-get install -y build-essential python3 libfftw3-dev python3-venv libpython3-dev pkg-config git
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build
run: |
.github/workflows/pip-build.sh
- name: Test
run: |
.github/workflows/pip-tests.sh
- name: Print Versions
run: |
.github/workflows/pip-versions.sh
conda:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
steps:
- name: Install Conda
run: |
apt update -y
apt install -y curl gpg git build-essential
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg
install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list
apt update -y
apt install -y conda
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build
run: |
.github/workflows/conda-build.sh
- name: Test
run: |
.github/workflows/conda-tests.sh
- name: Print Versions
run: |
.github/workflows/conda-versions.sh
5 changes: 5 additions & 0 deletions .github/workflows/conda-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
. /opt/conda/etc/profile.d/conda.sh
conda env create -n po3 --file environment.yml
conda activate po3
pip install -U meson-python setuptools setuptools-scm
pip install --no-build-isolation --editable .
4 changes: 4 additions & 0 deletions .github/workflows/conda-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
. /opt/conda/etc/profile.d/conda.sh
conda activate po3
cd examples/SNS_Linac/pyorbit3_linac_model/
python pyorbit3_sns_linac_mebt_hebt2.py
7 changes: 7 additions & 0 deletions .github/workflows/conda-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
. /opt/conda/etc/profile.d/conda.sh
conda activate po3
python -V
conda -V
pip -V
gcc -v
python -m setuptools_scm
6 changes: 6 additions & 0 deletions .github/workflows/pip-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python3 -m venv .po3
. .po3/bin/activate
pip install -U pip
pip install -r requirements.txt
pip install -U setuptools
pip install --no-build-isolation --editable .
3 changes: 3 additions & 0 deletions .github/workflows/pip-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
. .po3/bin/activate
cd examples/SNS_Linac/pyorbit3_linac_model/
python pyorbit3_sns_linac_mebt_hebt2.py
5 changes: 5 additions & 0 deletions .github/workflows/pip-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
. .po3/bin/activate
python -V
pip -V
gcc -v
python -m setuptools_scm
27 changes: 15 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

include:
- remote: "https://gitlab.esss.lu.se/ics-infrastructure/gitlab-ci-yml/raw/master/PreCommit.gitlab-ci.yml"
- remote: "https://gitlab.esss.lu.se/ics-infrastructure/gitlab-ci-yml/raw/master/ArtifactoryPyPI.gitlab-ci.yml"
Expand All @@ -12,10 +11,13 @@ run-tests:
tags:
- docker
stage: test
image: continuumio/miniconda3:23.5.2-0
image: continuumio/miniconda3:24.7.1-0
before_script:
- conda install -c conda-forge gcc gxx fftw mpich pytest pytest-cov coverage numpy scipy matplotlib
- python setup.py clean
- conda env create -y -n po3 --file environment.yml
- conda init bash
- source ~/.bashrc
- conda activate po3
- conda install -y -c conda-forge gcc gxx mpich mpich-mpicc mpich-mpicxx pytest pytest-cov coverage numpy scipy matplotlib
- pip install .
script:
- pytest tests --junitxml=junit.xml --cov-report xml --cov-report term --cov orbit
Expand All @@ -32,23 +34,24 @@ run-tests:

build-pypi-package-py310:
extends: build-pypi-package
image: conda/miniconda3-centos7:latest
image: continuumio/miniconda3:24.7.1-0
before_script:
- yum install -y gcc gcc-c++
- conda update -y -n base -c defaults conda
- conda create -y -n python310 python=3.10
- conda env create -y -n python310 --file environment.yml
- conda init bash
- source ~/.bashrc
- conda activate python310
- conda install -y -c conda-forge git fftw mpich mpich-mpicc mpich-mpicxx
- conda install -y -c conda-forge python=3.10 build gcc gxx git mpich mpich-mpicc mpich-mpicxx

build-pypi-package:
image: conda/miniconda3-centos7:latest
image: continuumio/miniconda3:24.7.1-0
script:
- git config --global --add safe.directory /builds/ess-crs/pyorbit3
- python -m build
before_script:
- yum install -y gcc gcc-c++
- conda update -y -n base -c defaults conda
- conda create -y -n python311 python=3.11
- conda env create -y -n python311 --file environment.yml
- conda init bash
- source ~/.bashrc
- conda activate python311
- conda install -y -c conda-forge git fftw mpich mpich-mpicc mpich-mpicxx
- conda install -y -c conda-forge python=3.11 build gcc gxx git git-lfs mpich mpich-mpicc mpich-mpicxx
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: '^tests/examples/SNS_Linac/linac_errors/.*|^tests/examples/AccLattice_Tests/.*|^tests/examples/Optimization/.*'
exclude: '^tests/examples/SNS_Linac/linac_errors/.*|^tests/examples/AccLattice_Tests/.*|^tests/examples/Optimization/.*|^.*\.dat'


- repo: https://github.com/ambv/black
Expand Down
75 changes: 75 additions & 0 deletions MesonBuild.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# PyOrbit3 with meson

This uses meson-python to build orbit package.

There is no **setup.py** file, instead we have **meson.build**.
**pyproject.toml** is changed to use meson.

This is experimental setup that is work in progress.
The pure python part is built with hierarchical **meson.build** files in **py/**.
The C++ setup is combined in one file **src/meson.build**.

### Main modifications in C++ code
1. **src/libmain/** is not used, still there for reference but will be gone soon.
2. **src/core/** contains one C++ file per module inside _orbit.core_
3. The files **wrap_XXXX.cc** were modified to correctly reference modules
```cpp
// line
PyObject* mod = PyImport_ImportModule("_bunch");
// replaced with
PyObject* mod = PyImport_ImportModule("orbit.core.bunch");
```



# Setup

## 0. Required software

One needs compilers, python and libfftw (and potentially mpi).
See [PyORBIT3](https://github.com/PyORBIT-Collaboration/PyORBIT3) for external
requirements.


## 1. Preparing environment

First step is to clone the source code from meson branch:

```bash
git clone -b meson https://github.com/azukov/PyORBIT3.git
```

Initialize new virtual environment and install packages

```
python -m venv .mes
source .mes/bin/activate
pip install -U pip
pip install -r requirements
```
Edit **meson.build** and set correct paths/flags for python/fftw3 headers and libraries

## 2. Build

To install orbit package in development mode run following:
```bash
pip install --no-build-isolation --editable .
```
No rebuild is necessary, just edit **py/** or **src/** and meson will rebuild as needed when import happens.


## 3. Run examples

Special examples used for meson testing

```bash
cd examples/meson
python imports_test.py
python uspas_test.py
```

SNS linac example
```bash
cd examples/SNS_Linac/pyorbit3_linac_model/
python pyorbit3_sns_linac_mebt_hebt2.py
```
Loading

0 comments on commit 0a76d77

Please sign in to comment.