Skip to content

Commit

Permalink
Added Build&Deploy for mac-os (#229)
Browse files Browse the repository at this point in the history
* First commit to test an unified build_deploy for all the OS

* Fixed indentation error

* Adding OS dependecies install

* changed command orders

* Reverted the build process for linux, new build applying only for windos and macos, added static linking to all platforms

* cannot use - inside github action

* wrong name for action

* Need to keep the if statement because removing it breaks the manylinux build

* Adding back the upload to PyPI and artifact

* Resolved comments raised by @dalonsoa

Removed too many blank lines

Inverting the order to see it runs

Rolling back

* Added push only to specific branches
  • Loading branch information
Abelarm committed Oct 21, 2022
1 parent a5e0dae commit 3173f25
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/build_deploy_wheels.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Upload Python Package

on: push
on:
push:
branches:
- main
- develop

jobs:

deploy_wheels_linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -15,7 +20,6 @@ jobs:
- name: Deploy wheels - Install dependencies
run: |
python -m pip install --upgrade setuptools wheel pip twine numpy
- name: Deploy wheels - Build manylinux2014 binary wheels - py3.x - x86_64
uses: RalfG/python-wheels-manylinux-build@v0.3.1-manylinux2014_x86_64
with:
Expand Down Expand Up @@ -45,12 +49,14 @@ jobs:
name: linux_wheels
path: dist/

deploy_wheels_windows:
runs-on: windows-latest
deploy_wheels_macos_windows:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
name: Building for windows ${{ matrix.python-version }}
name: Building for ${{ matrix.os }} - python ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -59,11 +65,17 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install system dependencies in MacOS
if: matrix.os == 'macos-latest'
run: |
brew reinstall gfortran
- name: Install python dependencies
run: |
python -m pip install --upgrade setuptools wheel pip twine numpy==1.21.4
- name: Build Solcore Windows
if: matrix.os == 'windows-latest'
env:
FC: gfortran
CC: gcc
Expand All @@ -73,15 +85,25 @@ jobs:
python setup.py sdist bdist_wheel
shell: powershell

- name: Build Solcore MacOS
if: matrix.os != 'windows-latest'
env:
FC: gfortran
CC: gcc
SOLCORE_WITH_PDD: 1
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
python setup.py sdist bdist_wheel
- name: Publish wheels to PyPI
if: startsWith(github.ref, 'refs/tags')
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*-win_amd64*.whl --skip-existing
twine upload dist/*.whl --skip-existing
- uses: actions/upload-artifact@v3
with:
name: windows_wheels
path: dist/
name: ${{ matrix.os }}_wheels
path: dist/
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ def gen_data_files(*dirs):
(os.environ['SOLCORE_WITH_PDD'] == "1"))):
sources = os.path.join("solcore", "poisson_drift_diffusion",
"DDmodel-current.f95")

os_static_linking = ["darwin", "win32"]
link_args = ["-static", "-static-libgfortran", "-static-libgcc"] if sys.platform in os_static_linking else None

ext = [
Extension(
name="solcore.poisson_drift_diffusion.ddModel",
sources=[sources],
f2py_options=["--quiet"],
extra_link_args=["-static", "-static-libgfortran", "-static-libgcc"] if sys.platform == "win32" else None
extra_link_args=link_args
)
]
if "--with_pdd" in sys.argv:
Expand Down

0 comments on commit 3173f25

Please sign in to comment.