-
Notifications
You must be signed in to change notification settings - Fork 2
199 lines (176 loc) · 9.97 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: main
on:
push:
#schedule:
# - cron: '*/120 8-18 * * *' # every 2 hours from 8:00 to 18:00 every day
jobs:
main:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022] # [ubuntu-22.04, macos-12, windows-2022]
build_system: [cmake] # [cmake, fpm]
compiler: [gfortran] # [gfortran, ifort]
# include:
# - os: ubuntu-22.04
# build_system: cmake
# compiler: ifort
#- os: ubuntu-22.04
# build_system: fpm
# compiler: ifort
steps:
- name: Check-out repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Set up nmake environment
if: runner.os == 'windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Upgrade PIP
run: python -m pip install --upgrade pip
- name: Declare env variables (independent)
shell: bash
run: |
echo "PROJECTS_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "CRYSFML_PROJECT=crysfml08" >> $GITHUB_ENV
echo "PYCRYSFML_PROJECT=pycrysfml08" >> $GITHUB_ENV
echo "DIST_PACKAGE_NAME=pycrysfml08" >> $GITHUB_ENV
- name: Declare env variables (dependent)
shell: bash
run: |
echo "CRYSFML_REPO=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_repo" >> $GITHUB_ENV
echo "PYCRYSFML_REPO=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_repo" >> $GITHUB_ENV
echo "CRYSFML_BUILD=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_build" >> $GITHUB_ENV
echo "PYCRYSFML_BUILD=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_build" >> $GITHUB_ENV
echo "CRYSFML_DIST=${{ env.PROJECTS_DIR }}/${{ env.CRYSFML_PROJECT }}_dist" >> $GITHUB_ENV
echo "PYCRYSFML_DIST=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_dist" >> $GITHUB_ENV
echo "PYCRYSFML_WHEEL=${{ env.PROJECTS_DIR }}/${{ env.PYCRYSFML_PROJECT }}_wheel" >> $GITHUB_ENV
if [[ '${{ runner.os }}' == 'macOS' ]]; then
echo "LIBPYTHON=-L/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -lpython3.11" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)" >> $GITHUB_ENV # needed because of `brew reinstall gcc`
fi
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.compiler }}' == 'ifort' ]]; then
echo "COMPILER_OPTIONS=-fpp -fPIC" >> $GITHUB_ENV
elif [[ '${{ matrix.compiler }}' == 'gfortran' ]]; then
echo "COMPILER_OPTIONS=-cpp -std=f2008 -ffree-line-length-none -fPIC" >> $GITHUB_ENV
fi
if [[ '${{ runner.os }}' == 'Windows' ]]; then
echo "LIBPYTHON=${{ env.Python_ROOT_DIR }}\\libs\\python311.lib" >> $GITHUB_ENV
ls -l ${{ env.Python_ROOT_DIR }}\\libs
echo "COMPILER_OPTIONS= -std=f2008 -ffree-line-length-none -fPIC" >> $GITHUB_ENV
fi
- name: Install OS-specific dependences (macOS)
if: runner.os == 'macOS' && matrix.compiler == 'gfortran'
run: |
brew reinstall gcc # to add gfortran
gfortran --version
#brew install llvm # ??? OpenMP for parallel compilation in FPM
#brew reinstall libomp # ??? OpenMP for parallel compilation in FPM
- name: Install OS-specific dependences (Linux + ifort)
if: runner.os == 'Linux' && matrix.compiler == 'ifort'
run: |
curl -Lo- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo gpg --dearmor -o /usr/share/keyrings/oneapi-archive-keyring.gpg
sudo tee /etc/apt/sources.list.d/oneAPI.list <<< "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
sudo apt-get install intel-oneapi-compiler-fortran
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
ifort --version
#- name: Install OS-specific dependences (Linux + ifort)
# if: runner.os == 'Linux' && matrix.compiler == 'ifort'
# run: |
# wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
# sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
# rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
# echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
# sudo apt-get update
# sudo apt-get install intel-oneapi-compiler-fortran
# source /opt/intel/oneapi/setvars.sh
# printenv >> $GITHUB_ENV
# ifort --version
- name: Download CrysFML (fpm_macos branch)
run: git clone --single-branch --branch fpm_macos https://code.ill.fr/rodriguez-carvajal/crysfml2008.git ${{ env.CRYSFML_REPO }}
- name: Build CrysFML using CMake on Linux/macos
if: matrix.build_system == 'cmake' && (runner.os == 'Linux' || runner.os == 'macOS')
run: |
echo '### cmake -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }}'
cmake -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }}
echo '### cmake --build ${{ env.CRYSFML_BUILD }} --parallel'
cmake --build ${{ env.CRYSFML_BUILD }} --parallel
echo '### cmake --install ${{ env.CRYSFML_BUILD }}'
cmake --install ${{ env.CRYSFML_BUILD }}
- name: Build CrysFML using CMake on Windows
if: matrix.build_system == 'cmake' && runner.os == 'windows'
run: |
cmake -G "NMake Makefiles" -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }}
cd ${{ env.CRYSFML_BUILD }}
nmake
nmake install
- name: Build CrysFML using FPM
if: matrix.build_system == 'fpm'
run: |
echo '# python -m pip install fpm'
python -m pip install fpm
echo '# fpm --version'
fpm --version
echo '# cd ${{ env.CRYSFML_REPO }}'
cd ${{ env.CRYSFML_REPO }}
echo '# ./make_CrysFML_fpm.sh ${{ matrix.compiler }}'
./make_CrysFML_fpm.sh ${{ matrix.compiler }}
echo '# mv ${{ matrix.compiler }}_release ${{ env.CRYSFML_DIST }}'
mv ${{ matrix.compiler }}_release ${{ env.CRYSFML_DIST }}
- name: Download PyCrysFML (develop branch)
run: git clone --single-branch --branch develop https://code.ill.fr/scientific-software/pycrysfml08.git ${{ env.PYCRYSFML_REPO }}
- name: Build PyCrysFML modules one by one (Linux/macos)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
echo '### mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}'
mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}
echo '### cd ${{ env.PYCRYSFML_REPO }}/src'
cd ${{ env.PYCRYSFML_REPO }}/src
for name in py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom; do
echo "### ${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $name.f90 -I ${{ env.CRYSFML_DIST }}/include"
${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $name.f90 -I ${{ env.CRYSFML_DIST }}/include
echo "### ${{ matrix.compiler }} -shared -o $name.so $name.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}"
${{ matrix.compiler }} -shared -o $name.so $name.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}
echo "### mv $name.so ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}"
mv $name.so ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}
echo '### ls -l ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}'
ls -l ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}
done
echo "### rm *.o *.*mod"
rm *.o *.*mod
- name: Build PyCrysFML modules one by one (Windows)
if: runner.os == 'windows'
shell: cmd
run: |
mkdir -p ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}
cd ${{ env.PYCRYSFML_REPO }}/src
for %%n in (py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom) do (
${{ matrix.compiler }} -shared -o %%n.pyd %%n.f90 ${{ env.COMPILER_OPTIONS }} -I ${{ env.CRYSFML_DIST }}/include -L ${{ env.CRYSFML_DIST }}/lib -lCrysFML08 ${{ env.LIBPYTHON }}
cp %%n.pyd ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}
)
rm *.smod *.*mod
- name: Make PyCrysFML python wheel
run: |
python -m pip install build
echo '### touch ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}/__init__.py'
touch ${{ env.PYCRYSFML_DIST }}/${{ env.DIST_PACKAGE_NAME }}/__init__.py
echo '### python3 -m build --wheel --outdir ${{ env.PYCRYSFML_WHEEL }}'
python3 -m build --wheel --outdir ${{ env.PYCRYSFML_WHEEL }}
echo '### ls - l ${{ env.PROJECTS_DIR }}'
ls -l ${{ env.PROJECTS_DIR }}
echo '### ls -l ${{ env.PYCRYSFML_DIST }}'
ls -l ${{ env.PYCRYSFML_DIST }}
echo '### ls - l ${{ env.PYCRYSFML_WHEEL }}'
ls -l ${{ env.PYCRYSFML_WHEEL }}
- name: Install PyCrysFML from local wheel (with dev extras)
run: |
echo '### python3 -m pip install "${{ env.DIST_PACKAGE_NAME }}[dev]" --find-links=${{ env.PYCRYSFML_WHEEL }}'
python3 -m pip install "${{ env.DIST_PACKAGE_NAME }}[dev]" --find-links=${{ env.PYCRYSFML_WHEEL }}
- name: Run tests
run: pytest tests/ -vv