New build script #92
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [macos-12, ubuntu-22.04, 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: cmake | |
compiler: ifx | |
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: 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 | |
if [[ '${{ runner.os }}' == 'Linux' ]]; then | |
echo "SEP=/" >> $GITHUB_ENV | |
elif [[ '${{ runner.os }}' == 'macOS' ]]; then | |
echo "SEP=/" >> $GITHUB_ENV | |
elif [[ '${{ runner.os }}' == 'Windows' ]]; then | |
echo "SEP=\\" >> $GITHUB_ENV | |
fi | |
- name: Declare env variables (dependent) | |
shell: bash | |
run: | | |
echo "CRYSFML_REPO=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.CRYSFML_PROJECT }}_repo" >> $GITHUB_ENV | |
echo "PYCRYSFML_REPO=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.PYCRYSFML_PROJECT }}_repo" >> $GITHUB_ENV | |
echo "CRYSFML_BUILD=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.CRYSFML_PROJECT }}_build" >> $GITHUB_ENV | |
echo "PYCRYSFML_BUILD=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.PYCRYSFML_PROJECT }}_build" >> $GITHUB_ENV | |
echo "CRYSFML_DIST=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.CRYSFML_PROJECT }}_dist" >> $GITHUB_ENV | |
echo "PYCRYSFML_DIST=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.PYCRYSFML_PROJECT }}_dist" >> $GITHUB_ENV | |
echo "PYCRYSFML_WHEEL=${{ env.PROJECTS_DIR }}${{ env.SEP }}${{ env.PYCRYSFML_PROJECT }}_wheel" >> $GITHUB_ENV | |
if [[ '${{ runner.os }}' == 'Linux' ]]; then | |
echo "CMAKE_GENERATOR=-G 'Unix Makefiles'" >> $GITHUB_ENV | |
echo "SITE_PACKAGES=/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages" >> $GITHUB_ENV | |
elif [[ '${{ runner.os }}' == 'macOS' ]]; then | |
echo "CMAKE_GENERATOR=-G 'Unix Makefiles'" >> $GITHUB_ENV | |
echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)" >> $GITHUB_ENV # needed because of `brew reinstall gcc` | |
echo "LIBPYTHON=-L/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -lpython3.11" >> $GITHUB_ENV | |
echo "SITE_PACKAGES=/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages" >> $GITHUB_ENV | |
elif [[ '${{ runner.os }}' == 'Windows' ]]; then | |
echo "CMAKE_GENERATOR=-G 'NMake Makefiles'" >> $GITHUB_ENV | |
echo "LIBPYTHON=${{ env.Python_ROOT_DIR }}\\libs\\python311.lib" >> $GITHUB_ENV | |
echo "SITE_PACKAGES=c:/hostedtoolcache/windows/python/3.11.8/x64/lib/site-packages" >> $GITHUB_ENV | |
fi | |
if [[ '${{ matrix.compiler }}' == 'gfortran' ]]; then | |
#echo "COMPILER_OPTIONS=-cpp -std=f2008 -ffree-line-length-none -fPIC" >> $GITHUB_ENV | |
echo "COMPILER_OPTIONS=-cpp -ffree-line-length-none -fPIC" >> $GITHUB_ENV | |
elif [[ '${{ matrix.compiler }}' == 'ifort' || '${{ matrix.compiler }}' == 'ifx' ]]; then | |
echo "COMPILER_OPTIONS=-fpp -fPIC" >> $GITHUB_ENV | |
fi | |
- name: Install OS-specific dependences (Windows) | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Install OS-specific dependences (macOS + gfortran) | |
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/ifx) | |
if: runner.os == 'Linux' && (matrix.compiler == 'ifort' || matrix.compiler == 'ifx') | |
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 | |
ifx --version | |
- name: Download CrysFML (powder_mod_fix branch) | |
run: git clone --single-branch --branch powder_mod_fix https://code.ill.fr/rodriguez-carvajal/crysfml2008.git ${{ env.CRYSFML_REPO }} | |
- name: Build CrysFML using CMake | |
run: | | |
echo '::::: cmake ${{ env.CMAKE_GENERATOR }} -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_POSITION_INDEPENDENT_CODE=ON -D CMAKE_Fortran_COMPILER=${{ matrix.compiler }} -D CMAKE_INSTALL_PREFIX=${{ env.CRYSFML_DIST }} -S ${{ env.CRYSFML_REPO }} -B ${{ env.CRYSFML_BUILD }}' | |
cmake ${{ env.CMAKE_GENERATOR }} -D ARCH32=OFF -D PYTHON_API=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_POSITION_INDEPENDENT_CODE=ON -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: Download PyCrysFML (master branch) | |
run: git clone --single-branch --branch master https://code.ill.fr/scientific-software/pycrysfml08.git ${{ env.PYCRYSFML_REPO }} | |
- name: Copy powder_mod.f90 to PyCrysFML src folder | |
run: | | |
echo '::::: cp ${{ env.CRYSFML_REPO }}${{ env.SEP }}Testing${{ env.SEP }}Powder${{ env.SEP }}Test_2${{ env.SEP }}fortran${{ env.SEP }}src${{ env.SEP }}powder_mod.f90 ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src${{ env.SEP }}powder_mod.F90' | |
cp ${{ env.CRYSFML_REPO }}${{ env.SEP }}Testing${{ env.SEP }}Powder${{ env.SEP }}Test_2${{ env.SEP }}fortran${{ env.SEP }}src${{ env.SEP }}powder_mod.f90 ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src${{ env.SEP }}powder_mod.F90 | |
- name: Build some PyCrysFML modules one by one (Linux + macOS) | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
run: | | |
echo '::::: mkdir -p ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
mkdir -p ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
echo '::::: cd ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src' | |
cd ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src | |
#for n in py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom powder_mod; do | |
for n in py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom powder_mod; do | |
echo "::::: ${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $n.F90 -I ${{ env.CRYSFML_DIST }}/include" | |
${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c $n.F90 -I ${{ env.CRYSFML_DIST }}/include | |
echo "::::: ${{ matrix.compiler }} -shared -o $n.so $n.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}" | |
${{ matrix.compiler }} -shared -o $n.so $n.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }} | |
echo "::::: mv $n.so ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}" | |
mv $n.so ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
done | |
echo '::::: ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
- name: Build some PyCrysFML modules one by one (Windows) | |
if: runner.os == 'Windows' | |
shell: cmd | |
run: | | |
echo '::::: mkdir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
mkdir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
echo '::::: cd ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src' | |
cd ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}src | |
for %%n in (py_cfml_metrics py_cfml_profiles py_cfml_sxtal_geom powder_mod) do ( | |
echo "::::: ${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c %%n.f90 -I ${{ env.CRYSFML_DIST }}/include" | |
${{ matrix.compiler }} ${{ env.COMPILER_OPTIONS }} -c %%n.f90 -I ${{ env.CRYSFML_DIST }}/include | |
echo "::::: ${{ matrix.compiler }} -shared -o %%n.pyd %%n.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }}" | |
${{ matrix.compiler }} -shared -o %%n.pyd %%n.o -L ${{ env.CRYSFML_DIST }}/lib -l CrysFML08 ${{ env.LIBPYTHON }} | |
echo "::::: move %%n.pyd ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}" | |
move %%n.pyd ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
) | |
echo '::::: dir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
dir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
- name: Add required system DLLs (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
cp ${{ env.Python_ROOT_DIR }}\\python311.dll ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
cp c:\\mingw64\\bin\\libgcc_s_seh-1.dll ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
cp c:\\mingw64\\bin\\libgfortran-5.dll ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
cp c:\\mingw64\\bin\\libquadmath-0.dll ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
cp c:\\mingw64\\bin\\libwinpthread-1.dll ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
echo '::::: dir ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }}' | |
ls -l ${{ env.PYCRYSFML_DIST }}\\${{ env.DIST_PACKAGE_NAME }} | |
- name: Add magnetic_data.txt database | |
run: | | |
echo '::::: mkdir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases' | |
mkdir ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases | |
echo '::::: cp ${{ env.CRYSFML_REPO }}${{ env.SEP }}Src${{ env.SEP }}Databases${{ env.SEP }}magnetic_data.txt ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases' | |
cp ${{ env.CRYSFML_REPO }}${{ env.SEP }}Src${{ env.SEP }}Databases${{ env.SEP }}magnetic_data.txt ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases | |
echo '::::: ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases' | |
ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases | |
#- name: Make PyCrysFML python wheel | |
# run: | | |
# python -m pip install build | |
# echo '::::: touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py' | |
# touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__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: Copy extra files (__init__.py, pyproject.toml) | |
run: | | |
#echo '::::: touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py' | |
#touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py | |
echo '::::: cp ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
cp ${{ env.PYCRYSFML_REPO }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
echo '::::: cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}pyproject.toml ${{ env.PYCRYSFML_DIST }}' | |
cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}pyproject.toml ${{ env.PYCRYSFML_DIST }} | |
echo '::::: cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}LICENSE ${{ env.PYCRYSFML_DIST }}' | |
cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}LICENSE ${{ env.PYCRYSFML_DIST }} | |
echo '::::: cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}README.md ${{ env.PYCRYSFML_DIST }}' | |
cp ${{ env.PROJECTS_DIR }}${{ env.SEP }}README.md ${{ env.PYCRYSFML_DIST }} | |
echo '::::: ls -l ${{ env.PYCRYSFML_DIST }}' | |
ls -l ${{ env.PYCRYSFML_DIST }} | |
echo '::::: ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}' | |
ls -l ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
#- name: Build PyCrysFML python wheel | |
# uses: pypa/cibuildwheel@v2.16.5 | |
# env: | |
# CIBW_BUILD_VERBOSITY: 1 | |
# with: | |
# package-dir: ${{ env.PYCRYSFML_DIST }} | |
# output-dir: ${{ env.PYCRYSFML_WHEEL }} | |
- name: Build PyCrysFML python wheel | |
run: | | |
python -m pip install build | |
#echo '::::: touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__init__.py' | |
#touch ${{ env.PYCRYSFML_DIST }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}__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 "::::: ls -l ${{ env.PYCRYSFML_WHEEL }}" | |
ls -l ${{ env.PYCRYSFML_WHEEL }} | |
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: Debug | |
run: | | |
echo "::::: ls -l ${{ env.SITE_PACKAGES }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}" | |
ls -l ${{ env.SITE_PACKAGES }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }} | |
echo "::::: ls -l ${{ env.SITE_PACKAGES }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases" | |
ls -l ${{ env.SITE_PACKAGES }}${{ env.SEP }}${{ env.DIST_PACKAGE_NAME }}${{ env.SEP }}Databases | |
echo '::::: python tests/test_powder_mod.py' | |
python tests${{ env.SEP }}test_powder_mod.py | |
- name: Run tests | |
run: pytest tests/ -vv |