diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 14d4918..241cda5 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -1,122 +1,70 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI -on: - push: - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 +on: [push] + # tags: + # - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 jobs: build-n-publish_linux: name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-12 ] + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install twine flake8 + python -m pip install --upgrade pip flake8 cibuildwheel + - name: Lint with flake8 for syntax errors run: | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Autobump version - run: | - # from refs/tags/v1.2.3 get 1.2.3 - VERSION=$(echo $GITHUB_REF | sed 's#.*/v##') - PLACEHOLDER='version = 0.0.0a0' - VERSION_FILE='setup.cfg' - # ensure the placeholder is there. If grep doesn't find the placeholder - # it exits with exit code 1 and github actions aborts the build. - grep "$PLACEHOLDER" "$VERSION_FILE" - sed -i "s/$PLACEHOLDER/version = ${VERSION}/g" "$VERSION_FILE" - shell: bash - - - name: Build manylinux Python wheels - uses: RalfG/python-wheels-manylinux-build@v0.2-manylinux1_x86_64 - with: - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39' - build-requirements: '' - package-path: '' - - uses: actions/upload-artifact@v1 - with: - name: wheelhouse - path: wheelhouse + + # - name: Autobump version + # run: | + # # from refs/tags/v1.2.3 get 1.2.3 + # VERSION=$(echo $GITHUB_REF | sed 's#.*/v##') + # PLACEHOLDER='version = 0.0.0a0' + # VERSION_FILE='setup.cfg' + # # ensure the placeholder is there. If grep doesn't find the placeholder + # # it exits with exit code 1 and github actions aborts the build. + # grep "$PLACEHOLDER" "$VERSION_FILE" + # sed -i "" "s/$PLACEHOLDER/version = ${VERSION}/g" "$VERSION_FILE" + # shell: bash - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} + - name: build wheels run: | - echo "$GITHUB_CONTEXT" - echo ${{ github.event.base_ref }} - - - name: Publish wheels to PyPI - if: github.event.base_ref == 'refs/heads/master' + python -m cibuildwheel --output-dir wheelhouse env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_GLOBAL_PASSWORD }} - run: | - twine upload -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} wheelhouse/gripy*-manylinux*.whl + CIBW_BUILD: '{cp,pp}3*-*' + CIBW_SKIP: '*35-* pp??-macosx_x86_64' + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_24 + CIBW_ARCHS_LINUX: 'x86_64' + CIBW_BEFORE_ALL_MACOS: brew reinstall gcc + CIBW_TEST_REQUIRES: pytest hypothesis pupygrib + CIBW_TEST_COMMAND: pytest {project}/tests/ - build-n-publish_macos: - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - strategy: - matrix: - python: [3.6,3.7, 3.8] - runs-on: macos-latest - steps: - - - uses: actions/checkout@v2 + - name: purge old _linux_wheels + run: | + mkdir wheelupload + cp wheelhouse/*gripy* wheelupload/ - - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v2 + - uses: actions/upload-artifact@v3 with: - python-version: ${{ matrix.python }} - - - name: Autobump version - run: | - # from refs/tags/v1.2.3 get 1.2.3 - VERSION=$(echo $GITHUB_REF | sed 's#.*/v##') - PLACEHOLDER='version = 0.0.0a0' - VERSION_FILE='setup.cfg' - # ensure the placeholder is there. If grep doesn't find the placeholder - # it exits with exit code 1 and github actions aborts the build. - grep "$PLACEHOLDER" "$VERSION_FILE" - sed -i "" "s/$PLACEHOLDER/version = ${VERSION}/g" "$VERSION_FILE" - shell: bash + name: wheelhouse + path: wheelupload - - name: Fix Conda permissions on macOS - run: | - sudo chown -R $UID $CONDA - echo $SHELL - $CONDA/bin/conda init bash - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: | - echo "$GITHUB_CONTEXT" - echo ${{ github.event.base_ref }} - - name: macos install dependencies - env: - DELOCATE_LIBRARY_PATH: /usr/local/miniconda/lib - run: | - $CONDA/bin/conda install python=${{ matrix.python }} gfortran_osx-64 - $CONDA/bin/python -m pip install git+https://github.com/abrammer/delocate.git - $CONDA/bin/python --version - ln -s $CONDA/bin/gfortran /usr/local/bin/gfortran - $CONDA/bin/python -m pip install . - $CONDA/bin/python -m pip install -r requirements-test.txt - $CONDA/bin/python setup.py bdist_wheel - echo "Start delocate" - $CONDA/bin/delocate-wheel -w fixed_wheels -v dist/gripy-* - - name: Publish wheels to PyPI + - name: Publish a Python distribution to PyPI if: github.event.base_ref == 'refs/heads/master' - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_GLOBAL_PASSWORD }} - run: | - pip install twine - twine upload -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} fixed_wheels/gripy*-macosx*.whl + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_GLOBAL_PASSWORD }} + packages_dir: wheelupload/ diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 24aba96..7521998 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -8,13 +8,13 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-10.15 ] - python: [3.7, 3.8, 3.9] + os: [ ubuntu-latest, macos-12 ] + python: [3.7, 3.8, 3.9, "3.10"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} @@ -22,27 +22,11 @@ jobs: run: sudo apt install gfortran if: matrix.os == 'ubuntu-latest' - - name: Fix Conda permissions on macOS + - name: macos install fortran run: | - sudo chown -R $UID $CONDA - echo $SHELL - $CONDA/bin/conda init bash - if: matrix.os == 'macos-10.15' - - - name: macos install dependencies - run: | - $CONDA/bin/conda install python=${{matrix.python}} - $CONDA/bin/python --version - $CONDA/bin/conda install gfortran_osx-64 - ln -s $CONDA/bin/gfortran /usr/local/bin/gfortran - $CONDA/bin/python -m pip install . - $CONDA/bin/python -m pip install -r requirements-test.txt - - if: matrix.os == 'macos-10.15' - - - name: macos run tests - run: $CONDA/bin/pytest tests/ - if: matrix.os == 'macos-10.15' + brew reinstall gcc + # reinstalling gcc installs gfortran which is missing by default + if: matrix.os == 'macos-12' - name: windows install fortran run: | @@ -55,10 +39,8 @@ jobs: python -m pip install --upgrade pip pip install . pip install -r requirements-test.txt - if: matrix.os != 'macos-10.15' - name: Test with pytest run: | pip install pytest pytest tests/ - if: matrix.os != 'macos-10.15' diff --git a/gripy/libg2.f90 b/gripy/libg2.f90 index 388f991..7c75490 100644 --- a/gripy/libg2.f90 +++ b/gripy/libg2.f90 @@ -129,10 +129,11 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) integer,intent(in) :: idrstmpl(*) real,intent(out) :: fld(ndpts) + integer:: ival1(1), ival2(1), isign(1), minsd(1) integer,allocatable :: ifld(:),ifldmiss(:) - integer(4) :: ieee + integer,allocatable :: gref(:),gwidth(:),glen(:) - real :: ref,bscale,dscale,rmiss1,rmiss2 + real :: ref,bscale,dscale,rmiss1(1),rmiss2(1) ! real :: fldo(6045) integer :: totBit, totLen, non !f2py intent(in) cpack @@ -145,8 +146,8 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) ier=0 ! print *,'IDRSTMPL: ',(idrstmpl(j),j=1,16) - ieee = idrstmpl(1) - call rdieee(ieee, ref, 1) + ref = real(idrstmpl(1)) + ! call rdieee(ieee, ref, 1) bscale = 2.0**real(idrstmpl(2)) dscale = 10.0**real(-idrstmpl(3)) nbitsgref = idrstmpl(4) @@ -211,7 +212,7 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) iofst=iofst+1 call gbytes(cpack,minsd,iofst,nbitsd-1, 0, 1) iofst=iofst+nbitsd-1 - if (isign.eq.1) minsd=-minsd + if (isign(1).eq.1) minsd=-minsd else ival1=0 ival2=0 @@ -273,6 +274,7 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) ! Test to see if the group widths and lengths are consistent with number of ! values, and length of section 7. ! + non=1 totBit = 0 totLen = 0 do j=1,ngroups @@ -363,26 +365,26 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) ! print*,' idrstmpl(17)', idrstmpl(17) if (idrsnum.eq.3) then ! spatial differencing if (idrstmpl(17).eq.1) then ! first order - ifld(1)=ival1 + ifld(1)=ival1(1) if ( idrstmpl(7).eq.0 ) then ! no missing values itemp=ndpts else itemp=non-1 endif do n=2,itemp - ifld(n)=ifld(n)+minsd + ifld(n)=ifld(n)+minsd(1) ifld(n)=ifld(n)+ifld(n-1) enddo elseif (idrstmpl(17).eq.2) then ! second order - ifld(1)=ival1 - ifld(2)=ival2 + ifld(1)=ival1(1) + ifld(2)=ival2(1) if ( idrstmpl(7).eq.0 ) then ! no missing values itemp=ndpts else itemp=non-1 endif do n=3,itemp - ifld(n)=ifld(n)+minsd + ifld(n)=ifld(n)+minsd(1) ifld(n)=ifld(n)+(2*ifld(n-1))-ifld(n-2) enddo endif @@ -407,9 +409,9 @@ subroutine comunpack(cpack,len,lensec,idrsnum,idrstmpl,ndpts, fld) !print *,'SAG ',n,fld(n),ifld(non),bscale,ref,dscale non=non+1 elseif ( ifldmiss(n).eq.1 ) then - fld(n)=rmiss1 + fld(n)=rmiss1(1) elseif ( ifldmiss(n).eq.2 ) then - fld(n)=rmiss2 + fld(n)=rmiss2(1) endif enddo if ( allocated(ifldmiss) ) deallocate(ifldmiss) @@ -454,7 +456,7 @@ subroutine rdieee(rieee, a, num) ! !$$$ - real(4),intent(in) :: rieee(num) + integer(4),intent(in) :: rieee(num) real,intent(out) :: a(num) integer,intent(in) :: num