Skip to content

Commit

Permalink
Add support for apple silicon (#18)
Browse files Browse the repository at this point in the history
* adjusted max pts to clang

* fix arch def in ci

* lets see...

* try 2

* remove changes

* set env different way

* sanity check

* try again

...

* try again 16

* restore things to the way they were

* give cirrus ci a try

* limit pythons

* remove mcmodel link flags

* remove imagebase link flags

* attempt 1

* update file name line length to 120

* update fortran strings convertion for 120

* revert macos-arm changes to github actions

* remove cp312

* test mac arm upload

* other pythons causing issue?

* try with 2 pythons

* try with 39 and 310 pythons

* try with 39+ pythons

* try with 39+ pythons, fix yaml

* try new token

* check token

* check upload of linux wheels

* check upload of cirrus wheels with new variable

* actually configure cirrus right?

* cirrus ci try2

* add condition for cirrus ci"

* flip if sign

* added flag

---------

Co-authored-by: Josh Anibal <[email protected]>
  • Loading branch information
joanibal and Josh Anibal authored Dec 12, 2023
1 parent 9bfc45a commit 663888d
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 50 deletions.
70 changes: 70 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
build_and_store_wheels: &BUILD_AND_STORE_WHEELS
install_cibuildwheel_script:
- python -m pip install cibuildwheel==2.15.0
cibuildwheel_script:
- cibuildwheel
wheels_artifacts:
path: "wheelhouse/*"


######################################################################
# Build macosx_arm64 natively
######################################################################

cirrus_wheels_macos_arm64_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-xcode:14
matrix:
- env:
# building all four wheels in a single task takes ~45 mins
CIBW_BUILD: cp39-* cp310-* cp311-*
# - env:
# # building all four wheels in a single task takes ~45 mins
# # CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
# CIBW_BUILD: cp310-*
env:
PYPI_TOKEN_TEST: ENCRYPTED[3a78537243c7e38cd58853cc4caf77a2e6b2f3a06511952347677300620f6d61f650fd45142d02788b00492b5e6de49f]
PYPI_TOKEN: ENCRYPTED[b27e8f130f21bdd930757077153317e14140a0bac98261a4279e3107ce5c4d859b1f64e304aa52ecbc267727660d354b]
CIBW_ARCHS: arm64
CIBW_ARCHS_MACOS: arm64
PATH: /opt/homebrew/opt/[email protected]/bin:$PATH
CIBW_PRERELEASE_PYTHONS: True
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET=12.0
_PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
CIBW_BEFORE_BUILD_MACOS: "bash {project}/tools/wheels/cibw_before_build_macos.sh {project}"
PKG_CONFIG_PATH: /opt/arm64-builds/lib/pkgconfig
# assumes that the cmake config is in /usr/local/lib/cmake
CMAKE_PREFIX_PATH: /opt/arm64-builds/
REPAIR_PATH: /usr/local/gfortran/lib:/opt/arm64-builds/lib
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-listdeps {wheel} &&
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
install_pre_requirements_script:
- brew install [email protected]
- ln -s python3 /opt/homebrew/opt/[email protected]/bin/python

build_script:
- which python
# needed for submodules
- git submodule update --init
- uname -m
- python -c "import platform;print(platform.python_version());print(platform.system());print(platform.machine())"
- clang --version
<<: *BUILD_AND_STORE_WHEELS

upload_pypi_script: |
#!/usr/bin/env bash
echo ${CIRRUS_RELEASE}
echo $CIRRUS_TAG
echo ${CIRRUS_TAG}
# deploy source distribution to PyPI using 'twine'
python -m pip install twine
if [[ "${CIRRUS_RELEASE}" == "" ]]; then
python -m twine upload --verbose --skip-existing --repository-url https://test.pypi.org/legacy/ --username __token__ --password ${PYPI_TOKEN_TEST} wheelhouse/*
else
echo "would have uploaded"
# python -m twine upload --verbose --skip-existing --username __token__ --password ${PYPI_TOKEN_TEST} wheelhouse/*
fi
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: MkDocs

on:
push:
branches:
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Wheel builder
name: Wheel builder and tester

on:
push:
Expand All @@ -13,21 +13,22 @@ on:

jobs:
build_wheels:
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
matrix:
buildplat:
# should also be able to do multi-archs on a single entry, e.g.
# [windows-2019, win*, "AMD64 x86"]. However, those two require a different compiler setup
# so easier to separate out here.
- [ubuntu-22.04, manylinux, x86_64]
# Not supported for now
# - [ubuntu-22.04, musllinux, x86_64]
# - [windows-2019, win, AMD64]
# - [macos-12, macosx, arm64]

# working
- [ubuntu-22.04, manylinux, x86_64]
- [macos-11, macosx, x86_64]
# - [windows-2019, win, AMD64]

python: [ ["cp38", "3.8"],["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11.0-alpha - 3.11.0"]]
python: [["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"]]
# python: [["cp310", "3.10"]]


env:
Expand Down Expand Up @@ -80,9 +81,6 @@ jobs:
path: ./wheelhouse/*.whl
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}




upload_all:
name: upload the wheels to PYPI
needs: [build_wheels]
Expand Down Expand Up @@ -112,16 +110,18 @@ jobs:
- name: Move wheels to dist
run: bash tools/wheels/move_wheels.sh

# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# # packages-dir: wheelhouse/
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# packages-dir: wheelhouse/
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true
repository-url: https://test.pypi.org/legacy/

# - name: Publish distribution 📦 to PyPI
# if: startsWith(github.ref, 'refs/tags')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# # packages-dir: wheelhouse/
# skip-existing: true
# password: ${{ secrets.PYPI_API_TOKEN }}
7 changes: 7 additions & 0 deletions find_cross_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Find the .ini file in the specified directory pattern
file_path=$(find /Users/runner/work/pyAVL/pyAVL -name 'meson-python-cross-file.ini' -print -quit)

# Output the found file path
echo $file_path
7 changes: 7 additions & 0 deletions find_native_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Find the .ini file in the specified directory pattern
file_path=$(find /Users/runner/work/pyAVL/pyAVL -name 'meson-python-native-file.ini' -print -quit)

# Output the found file path
echo $file_path
5 changes: 3 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ endif

# _linker_script = meson.project_source_root() / '_build_utils/link-version-pyinit.map'
# link_args = ['-Wl,--version-script=' + _linker_script]
link_args = ['-Wl,--image-base,0x10000000']
link_args = ['-mcmodel=medium']
# link_args = ['-Wl,--image-base,0x10000000']
# link_args = ['-mcmodel=medium']
link_args = []

# https://mesonbuild.com/Python-module.html
py_mod = import('python')
Expand Down
5 changes: 4 additions & 1 deletion pyavl/pyAVL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,8 @@ def __decodeFortranString(self, fort_string) -> str:
py_string = fort_string.decode().strip()
elif fort_string.dtype == np.dtype("|S80"):
py_string = fort_string.decode().strip()
elif fort_string.dtype == np.dtype("|S120"):
py_string = fort_string.decode().strip()
else:
raise TypeError(f"Unable to convert {fort_string} of type {fort_string.dtype} to string")

Expand Down Expand Up @@ -1288,7 +1290,8 @@ def clear_ad_seeds(self):
def clear_ad_seeds_fast(self):
# Only clear the seeds that are used in Make_tapenade file
num_vor = self.get_mesh_size()
num_vor_max = 6000 # HACK: hardcoded value from AVL.inc
gam = self.get_avl_fort_arr("VRTX_R", "GAM")
num_vor_max = gam.size

for att in dir(self.avl):
if att.endswith(self.ad_suffix):
Expand Down
2 changes: 1 addition & 1 deletion src/ainput.f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SUBROUTINE INPUT(LUN,FNAME,FERR)
LOGICAL FERR
C
CHARACTER*4 KEYWD
CHARACTER*80 CNAME, ANAME
CHARACTER*120 CNAME, ANAME
CHARACTER*128 LINE
LOGICAL LHINGE
C
Expand Down
2 changes: 1 addition & 1 deletion src/airutil.f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SUBROUTINE READBL(FNAME,IBX,NBX,XB,YB,IIB,NBL,
C Reads in blade.xxx dataset
C----------------------------------------------
C
CHARACTER*80 LINE
CHARACTER*120 LINE
LOGICAL ERROR
C
DIMENSION AINPUT(20)
Expand Down
2 changes: 1 addition & 1 deletion src/amass.f
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SUBROUTINE MASGET(LU,FNAME,ERROR)
REAL Ixx , Iyy , Izz , Ixy , Ixz , Iyz
REAL Ixxi, Iyyi, Izzi, Ixyi, Ixzi, Iyzi
C
CHARACTER*80 CASE
CHARACTER*120 CASE
CHARACTER*256 LINE, LINEU
C
CHARACTER*32 UNCHGEE, UNCHRHO, UNCH
Expand Down
6 changes: 3 additions & 3 deletions src/amode.f
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ SUBROUTINE MODE
CHARACTER*1 ITEM, ANS, CHKEY
CHARACTER*2 OPT, CHPLOT
CHARACTER*4 COMAND, ITEMC
CHARACTER*80 FNOUT, FNNEW, FNSYS
CHARACTER*80 LINE, FNVB, COMARG, PROMPT, RTNEW
CHARACTER*120 FNOUT, FNNEW, FNSYS
CHARACTER*120 LINE, FNVB, COMARG, PROMPT, RTNEW
CHARACTER SATYPE*50, ROTTYPE*50
C
LOGICAL LPROOT(JEMAX,NRMAX),
Expand Down Expand Up @@ -1722,7 +1722,7 @@ SUBROUTINE PARMOD(IRE)
CHARACTER*2 CNUM
C
CHARACTER*4 COM
CHARACTER*80 CARG, PROMPT, RTNEW
CHARACTER*120 CARG, PROMPT, RTNEW
LOGICAL ERROR, REPKEY
C
INTEGER IINP(10)
Expand Down
8 changes: 4 additions & 4 deletions src/aoper.f
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ SUBROUTINE OPER
CHARACTER*1 ANS
CHARACTER*2 OPT
CHARACTER*4 COMAND, COMAND_TEST, ITEMC
CHARACTER*80 FNOUT, FNDER, FNNEW
CHARACTER*80 LINE, FNVB, COMARG, COMARG_TEST, CRUN, PROMPT, RTNEW
CHARACTER*120 FNOUT, FNDER, FNNEW
CHARACTER*120 LINE, FNVB, COMARG, COMARG_TEST, CRUN, PROMPT, RTNEW
CHARACTER*50 SATYPE, ROTTYPE
C
LOGICAL LOWRIT
Expand Down Expand Up @@ -787,7 +787,7 @@ SUBROUTINE CONSET(COMAND,COMARG) !,LMATCH,IR)
CHARACTER*(*) COMAND, COMARG
LOGICAL LMATCH
INTEGER IR
CHARACTER*80 PROMPT
CHARACTER*120 PROMPT
CHARACTER*4 ARROW
REAL RINP(20)
INTEGER IINP(20)
Expand Down Expand Up @@ -1387,7 +1387,7 @@ SUBROUTINE OPTGET
C-------------------------------------------------
INCLUDE 'AVL.INC'
CHARACTER*4 ITEMC
CHARACTER*80 COMARG
CHARACTER*120 COMARG
CHARACTER*50 SATYPE, ROTTYPE
LOGICAL ERROR
C
Expand Down
2 changes: 1 addition & 1 deletion src/aoutput.f
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ SUBROUTINE OUTCNC(LUN)
C
INCLUDE 'AVL.INC'
CHARACTER*1 ANS
CHARACTER*80 FNAM
CHARACTER*120 FNAM
SAVE FNAM
DATA FNAM /' '/
C
Expand Down
2 changes: 1 addition & 1 deletion src/atrim.f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SUBROUTINE TRMSET(COMAND,COMARG,COM,CARG)
CHARACTER*2 CNUM
C
CHARACTER*4 COM
CHARACTER*80 CARG, PROMPT, RTNEW
CHARACTER*120 CARG, PROMPT, RTNEW
LOGICAL ERROR, REPKEY
C
INTEGER IINP(10)
Expand Down
8 changes: 4 additions & 4 deletions src/avl.f
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SUBROUTINE AVL

CHARACTER*4 COMAND
CHARACTER*128 COMARG
CHARACTER*80 FNNEW
CHARACTER*120 FNNEW
C
REAL RINPUT(20)
INTEGER IINPUT(20)
Expand Down Expand Up @@ -464,7 +464,7 @@ SUBROUTINE AVL

SUBROUTINE loadGEO(FILDEF)
INCLUDE 'AVL.INC'
CHARACTER*80 FILDEF
CHARACTER*120 FILDEF
LOGICAL ERROR
C LOGICAL LAIC
C LOGICAL LSRD
Expand Down Expand Up @@ -508,7 +508,7 @@ SUBROUTINE loadGEO(FILDEF)

SUBROUTINE loadMASS(FMSDEF)
INCLUDE 'AVL.INC'
CHARACTER*80 FMSDEF
CHARACTER*120 FMSDEF
LOGICAL ERROR
C LOGICAL LSOL
C LOGICAL LSEN
Expand Down Expand Up @@ -1167,7 +1167,7 @@ SUBROUTINE RUNGET(LU,FNAME,ERROR)
CHARACTER*(*) FNAME
LOGICAL ERROR
C
CHARACTER*80 LINE, REST
CHARACTER*120 LINE, REST
CHARACTER*12 VARN, CONN
CHARACTER*8 PARN
C
Expand Down
2 changes: 1 addition & 1 deletion src/dtest.f
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROGRAM DTEST
C---------------------------------------------------------------------------
IMPLICIT REAL(A-H,O-Z)

CHARACTER*80 ARGP1, ARGP2
CHARACTER*120 ARGP1, ARGP2
CHARACTER*128 LINE
C
PI = 4.0*ATAN(1.0)
Expand Down
6 changes: 3 additions & 3 deletions src/f2py/libavl.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ python module libavl ! in
end subroutine aero_b

subroutine loadgeo(fildef) ! in :libavl:avl.f
character*80 :: fildef
character*120 :: fildef
end subroutine loadgeo

subroutine loadmass(fmsdef) ! in :libavl:avl.f
character*80 :: fmsdef
character*120 :: fmsdef
end subroutine loadmass


Expand All @@ -51,7 +51,7 @@ python module libavl ! in
subroutine trmset(comand, comarg, com, carg) ! in :libavl:aoper.f
character*(*) comand, comarg
character*4 com
character*80 carg
character*120 carg
end subroutine trmset


Expand Down
8 changes: 4 additions & 4 deletions src/includes/AVL.INC
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ C NRMAX number of stored run cases
C NTMAX number of stored time levels
C
C ICONX max number of control or design variable declaration lines per section (20)
PARAMETER (NVMAX=6000,
PARAMETER (NVMAX=5550,
& NSMAX=400,
& NFMAX=30,
& NLMAX=500,
Expand Down Expand Up @@ -54,10 +54,10 @@ C---- unit values, names, and namelengths
COMMON /UN_C/UNCHL,UNCHM,UNCHT,UNCHF,UNCHS,UNCHV,UNCHA,UNCHI,UNCHD
COMMON /UN_I/NUL ,NUM ,NUT ,NUF ,NUS ,NUV ,NUA ,NUI ,NUD
C
CHARACTER*80 FRNDEF, FPRDEF, FEVDEF
CHARACTER*80 TITLE
CHARACTER*120 FRNDEF, FPRDEF, FEVDEF
CHARACTER*120 TITLE
CHARACTER*40 STITLE, BTITLE, RTITLE
CHARACTER*80 AFILES
CHARACTER*120 AFILES

CHARACTER*16 DNAME, GNAME
CHARACTER*12 VARNAM, CONNAM
Expand Down
Loading

0 comments on commit 663888d

Please sign in to comment.