Skip to content

Commit

Permalink
Merge pull request #5 from SunyongKwon/main
Browse files Browse the repository at this point in the history
CICD with GitHub action
  • Loading branch information
SunyongKwon authored Jul 18, 2024
2 parents e42d609 + 093f053 commit af31db9
Show file tree
Hide file tree
Showing 26 changed files with 30,702 additions and 7 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Build

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest,ubuntu-latest,macos-12]
include:
- os: ubuntu-latest
python-version: '3.12'
toolchain: {compiler: gcc, version: 13}
- os: macos-12
python-version: '3.12'
toolchain: {compiler: gcc, version: 13}
- os: windows-latest
python-version: '3.11'
toolchain: {compiler: gcc, version: 13}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Fortran compiler for Unix
if: runner.os != 'Windows'
uses: awvwgk/setup-fortran@v1
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Install Fortran compiler on Windows
if: runner.os == 'Windows'
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install gcc
choco install make
shell: pwsh

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
env:
PYTHONIOENCODING: utf-8
CIBW_ARCHS_WINDOWS: x86 auto64
CIBW_ARCHS_MACOS: x86_64
with:
package-dir: .
output-dir: wheelhouse
config-file: "./pyproject.toml"

- name: Install Wheel
env:
PYTHONIOENCODING: utf-8
run: |
python -m venv venv
if [ $RUNNER_OS = 'Windows' ]; then
.\\venv\\Scripts\\activate
else
source venv/bin/activate
fi
for wheel in wheelhouse/*.whl; do
if ! pip install "$wheel"; then
echo "Failed to install $wheel, skipping..."
fi
done
shell: bash

- name: Run tests
env:
PYTHONIOENCODING: utf-8
run: |
if [ $RUNNER_OS = 'Windows' ]; then
.\\venv\\Scripts\\activate
else
source venv/bin/activate
fi
cd test
for test in Test*.py; do
python "$test"
done
shell: bash

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[tool.cibuildwheel]
# before-all = ["conda install conda-forge::libpng -y"]
build-verbosity = 1
build-frontend = "pip"
build = "cp39* cp310* cp311* cp312*"
skip = ["*-musllinux*","cp312-win*"]

[build-system]
requires = ["setuptools>=42", "wheel", "numpy>=1.21", "meson", "ninja", "cibuildwheel"]
requires = ["setuptools>=42", "wheel", "numpy>=1.21,<2.0", "meson", "ninja", "cibuildwheel"]
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def run(self):

# Copy the shared object file to the build directory
if sys.platform.startswith('win'):
os.system(f'cd equilipy&& f2py -c {self.slist} -m equilifort --backend distutils --fcompiler=gnu95')
os.system(f'cd equilipy&& f2py -c {self.slist} -m equilifort --backend distutils')
else:
os.system(f'cd equilipy; f2py -c {self.slist} -m equilifort --backend meson --fcompiler=gnu95')
os.system(f'cd equilipy; f2py -c {self.slist} -m equilifort --backend meson')

lib_name = self.get_ext_filename('equilipy/equilifort')

Expand Down Expand Up @@ -79,17 +79,17 @@ def compile_fortran(self, ext):
license='BSD-3',
packages=find_packages(),
install_requires=[
'numpy',
'numpy>=1.21,<2.0',
"glob2",
"regex",
"numba",
"dataclasses",
"meson",
"ninja",
"polars",
"polars>=0.20.15",
"xlsx2csv",
"matplotlib",
"tqdm",
"tqdm"
],
ext_modules=[f2py_Extension('equilipy',['equilipy/fsrc'])], # Include the Fortran extension
entry_points={
Expand Down
Loading

0 comments on commit af31db9

Please sign in to comment.