From 3161cf48f292be7b0ee8991795e5786aa43a29f8 Mon Sep 17 00:00:00 2001 From: Margriet Palm Date: Thu, 15 Feb 2024 13:49:54 +0100 Subject: [PATCH 1/6] Another attempt at python3.12 --- .github/workflows/test.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54e4511e..8bbbfc84 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: # 2018 - python: 3.7 os: ubuntu-20.04 + setuptools: setuptools==63.* numpy: numpy==1.15.* display_name: "2018" pins: "h5py==2.9.* sqlalchemy==1.4.1 shapely==2.0.* pyproj==3.0.*" @@ -25,6 +26,7 @@ jobs: # 2019 - python: 3.8 os: ubuntu-20.04 + setuptools: setuptools==63.* numpy: numpy==1.17.* display_name: "2019" pins: "h5py==2.10.* sqlalchemy==1.4.10 shapely==2.0.* pyproj==3.0.*" @@ -32,6 +34,7 @@ jobs: # 2020 - python: 3.9 os: ubuntu-20.04 + setuptools: setuptools==63.* numpy: numpy==1.19.* display_name: "2020" pins: "h5py==3.1.* sqlalchemy==1.4.20 shapely==2.0.* pyproj==3.0.*" @@ -39,6 +42,7 @@ jobs: # 2021 - python: 3.9 os: ubuntu-20.04 + setuptools: setuptools==63.* numpy: numpy==1.21.* display_name: "2021" pins: "h5py==3.3.* sqlalchemy==1.4.30 shapely==2.0.* pyproj==3.2.*" @@ -46,14 +50,24 @@ jobs: # 2022 - python: '3.10' os: ubuntu-22.04 + setuptools: setuptools==63.* numpy: numpy==1.23.* display_name: "2022" pins: "h5py==3.7.* sqlalchemy==1.4.40 shapely==2.0.* pyproj==3.4.*" extras: "[test,gridadmin]" - # current + # 2023 - python: '3.11' - os: ubuntu-latest + os: ubuntu-22.04 + setuptools: setuptools==63.* numpy: numpy==1.24.* + pins: "h5py==3.10.* sqlalchemy==2.0.* shapely==2.0.* pyproj==3.6.*" + display_name: "2023" + extras: "[test,gridadmin]" + # current (still using 3.11 because 3.12 breaks; see issue 348) + - python: '3.12' + os: ubuntu-latest + setuptools: setuptools==69.* + numpy: numpy==1.26.* pins: "" display_name: "latest" extras: "[test,gridadmin]" @@ -82,9 +96,10 @@ jobs: - name: Install python dependencies shell: bash run: | - pip install --disable-pip-version-check --upgrade pip setuptools==63.* wheel scikit-build + pip install --disable-pip-version-check --upgrade pip wheel scikit-build + pip install ${{ matrix.setuptools }} pip install ${{ matrix.numpy }} - pip install -e .${{ matrix.extras }} --no-build-isolation ${{ matrix.pins }} "pygdal==$(gdal-config --version).*" + pip install -v -e .${{matrix.extras }} --no-build-isolation ${{ matrix.pins }} "pygdal==$(gdal-config --version).*" pip list - name: Run unittests From 9814be7b2bc8986d0f6de2ae6cf50add812f4976 Mon Sep 17 00:00:00 2001 From: Margriet Palm Date: Thu, 15 Feb 2024 13:53:30 +0100 Subject: [PATCH 2/6] Allow numpy 1.26 in project.toml and setup.py --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1d3d76e3..770d24b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,6 @@ requires = [ "numpy==1.21.3; python_version=='3.10'", "numpy==1.24.2; python_version=='3.11'", # do not pin numpy on future versions of python to avoid incompatible numpy and python versions - "numpy; python_version>='3.11'", + "numpy==1.26.*; python_version=='3.12'", "ninja; platform_system!='Windows'" ] diff --git a/setup.py b/setup.py index af4a7fd0..8d7f88cf 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def get_version(): install_requires = [ - "numpy>=1.15,<1.25.0", + "numpy>=1.15", "threedi-schema==0.219.*", "shapely>=2", "pyproj>=3", From 8824fd795ed2118ed58c62a0d76dcb5eec06cc3d Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Mon, 19 Feb 2024 10:59:25 +0100 Subject: [PATCH 3/6] run setup.py for 3.12 --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8bbbfc84..4cf76138 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,6 +101,11 @@ jobs: pip install ${{ matrix.numpy }} pip install -v -e .${{matrix.extras }} --no-build-isolation ${{ matrix.pins }} "pygdal==$(gdal-config --version).*" pip list + + - name: run setup.py for python 3.12 + if: matrix.python == '3.12' + run: | + python setup.py develop - name: Run unittests shell: bash From 75a39bb50d41ae13a8e9950d138da8cb2a33e4cf Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Mon, 19 Feb 2024 16:08:56 +0100 Subject: [PATCH 4/6] fix 3.12 build --- .github/workflows/test.yml | 2 +- CMakeLists.txt | 5 ++-- libthreedigrid/_fgrid.pyf | 50 -------------------------------------- pyproject.toml | 1 + setup.py | 3 ++- 5 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 libthreedigrid/_fgrid.pyf diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4cf76138..35371a70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,7 +99,7 @@ jobs: pip install --disable-pip-version-check --upgrade pip wheel scikit-build pip install ${{ matrix.setuptools }} pip install ${{ matrix.numpy }} - pip install -v -e .${{matrix.extras }} --no-build-isolation ${{ matrix.pins }} "pygdal==$(gdal-config --version).*" + pip install -e .${{matrix.extras }} --no-build-isolation ${{ matrix.pins }} "pygdal==$(gdal-config --version).*" pip list - name: run setup.py for python 3.12 diff --git a/CMakeLists.txt b/CMakeLists.txt index 34e4f6b1..eff442cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ cmake_path(SET F2PY_INCLUDE_DIR ${F2PY_INCLUDE_DIR}) # Compiler flags set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -s -ffree-line-length-none -ffree-form -fimplicit-none -fbackslash --param max-unroll-times=4 -O3") -set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -s -ffree-line-length-none -ffree-form -fimplicit-none -fbounds-check -ffpe-trap=zero,overflow,underflow,invalid -fall-intrinsics -fbackslash --param max-unroll-times=4 -g -O0 -Wconversion -Wmaybe-uninitialized") +set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -s -fPIC -ffree-line-length-none -ffree-form -fimplicit-none -ffpe-trap=zero,overflow,underflow -fall-intrinsics -fbackslash --param max-unroll-times=4 -g -O0 -Wconversion -Wmaybe-uninitialized -fcheck=all -fimplicit-none -Wextra") # Prepping the module set(f2py_module_name "_fgrid") @@ -99,7 +99,6 @@ set(fortran_src_file "${fortran_src_dir}/parameters.f90" "${fortran_src_dir}/geo_utils.f90" "${fortran_src_dir}/cells.f90" "${fortran_src_dir}/quadtree.f90" - "${fortran_src_dir}/_fgrid.pyf" ) set(generated_module_file ${f2py_module_name}${PYTHON_EXTENSION_MODULE_SUFFIX}) set(f2py_module_c "${f2py_module_name}module.c") @@ -119,7 +118,7 @@ add_custom_command( -m "numpy.f2py" -m ${f2py_module_name} --lower - ${fortran_src_file} + "${fortran_src_dir}/cells.f90 ${fortran_src_dir}/quadtree.f90" #only: make_quadtree set_2d_computational_nodes_lines WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${fortran_src_file} diff --git a/libthreedigrid/_fgrid.pyf b/libthreedigrid/_fgrid.pyf deleted file mode 100644 index e4622656..00000000 --- a/libthreedigrid/_fgrid.pyf +++ /dev/null @@ -1,50 +0,0 @@ -! -*- f90 -*- -! Note: the context of this file is case sensitive. - -python module _fgrid ! in - interface ! in :_fgrid - module m_quadtree ! in :_fgrid:quadtree.f90 - subroutine make_quadtree(kmax,mmax,nmax,lgrmin,use_2d_flow,area_mask,lg,quad_idx,n_cells,n_line_u,n_line_v) ! in :_fgrid:quadtree.f90:m_quadtree - use parameters, only : NODATA - integer intent(in) :: kmax - integer dimension(:),intent(in) :: mmax - integer dimension(:),intent(in) :: nmax - integer intent(in) :: lgrmin - integer intent(in) :: use_2d_flow - integer*1 dimension(:,:),intent(in) :: area_mask - integer dimension(:,:),intent(inout) :: lg - integer dimension(:,:),intent(inout) :: quad_idx - integer intent(inout) :: n_cells - integer intent(inout) :: n_line_u - integer intent(inout) :: n_line_v - end subroutine make_quadtree - end module m_quadtree - module m_cells ! in :_fgrid:cells.f90 - subroutine set_2d_computational_nodes_lines(origin,lgrmin,kmax,mmax,nmax,dx,lg,nodk,nodm,nodn,quad_idx,bounds,coords,pixel_coords,area_mask,line,cross_pix_coords,n_line_u,n_line_v) ! in :_fgrid:cells.f90:m_cells - use m_grid_utils, only: get_lg_corners,get_cell_bbox,get_pix_corners,pad_area_mask - double precision dimension(2),intent(in) :: origin - integer intent(in) :: lgrmin - integer intent(in) :: kmax - integer dimension(:),intent(in) :: mmax - integer dimension(:),intent(in) :: nmax - double precision dimension(:),intent(in) :: dx - integer dimension(:,:),intent(inout) :: lg - integer dimension(:),intent(inout) :: nodk - integer dimension(:),intent(inout) :: nodm - integer dimension(:),intent(inout) :: nodn - integer dimension(:,:),intent(inout) :: quad_idx - double precision dimension(:,:),intent(inout) :: bounds - double precision dimension(:,:),intent(inout) :: coords - integer dimension(:,:),intent(inout) :: pixel_coords - integer*1 dimension(:,:),intent(inout) :: area_mask - integer dimension(:,:),intent(inout) :: line - integer dimension(:,:),intent(inout) :: cross_pix_coords - integer intent(in) :: n_line_u - integer intent(in) :: n_line_v - end subroutine set_2d_computational_nodes_lines - end module m_cells - end interface -end python module _fgrid - -! This file was auto-generated with f2py (version:1.21.4). -! See http://cens.ioc.ee/projects/f2py2e/ diff --git a/pyproject.toml b/pyproject.toml index 770d24b8..5c2aadb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,4 @@ requires = [ "numpy==1.26.*; python_version=='3.12'", "ninja; platform_system!='Windows'" ] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 8d7f88cf..39ace7cd 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ print("removing build folder") if os.path.isdir(p / "_skbuild"): shutil.rmtree(p / "_skbuild") + sys.exit() if sys.platform == "win32": cmake_args = ["-G", "MSYS Makefiles", "-DCMAKE_GNUtoMS=ON"] @@ -84,7 +85,7 @@ def get_version(): "gpkg": ["geopandas"], "cli": ["typer"], }, - python_requires=">=3.7", + python_requires=">=3.8", include_package_data=True, classifiers=[ "Programming Language :: Python :: 3", From d4ed5753b8db91bd5a2874ac9910d13a7d2606d1 Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Mon, 19 Feb 2024 16:36:53 +0100 Subject: [PATCH 5/6] filepath fixes --- .github/workflows/release.yml | 4 ++-- CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1421f7ce..363cc7dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,10 +50,10 @@ jobs: if: matrix.os == 'windows-2019' - name: Build wheels - uses: pypa/cibuildwheel@v2.12.0 + uses: pypa/cibuildwheel@v2.16.5 # to supply options, put them in 'env', like: env: - CIBW_SKIP: "pp* *musllinux*" # skips pypy and musllinux + CIBW_SKIP: "pp* *musllinux* cp312" # skips pypy, musllinux and python3.12 CIBW_ARCHS: auto64 # only 64-bit (convincing CMAKE of 32-bit is a TODO) CIBW_ENVIRONMENT_MACOS: FC=gfortran-12 diff --git a/CMakeLists.txt b/CMakeLists.txt index eff442cb..f339ec29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,8 +118,8 @@ add_custom_command( -m "numpy.f2py" -m ${f2py_module_name} --lower - "${fortran_src_dir}/cells.f90 ${fortran_src_dir}/quadtree.f90" - #only: make_quadtree set_2d_computational_nodes_lines + "${fortran_src_dir}/cells.f90" + "${fortran_src_dir}/quadtree.f90" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${fortran_src_file} ) From cd050b70ae469edca65a196ee3a33309c0302bf2 Mon Sep 17 00:00:00 2001 From: Margriet Palm Date: Tue, 20 Feb 2024 08:07:30 +0100 Subject: [PATCH 6/6] Fix ubuntu version to 22.04 in latest and correct comment --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 512a3982..33490989 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,9 +55,9 @@ jobs: pins: "h5py==3.10.* sqlalchemy==2.0.* shapely==2.0.* pyproj==3.6.*" display_name: "2023" extras: "[test,gridadmin]" - # current (still using 3.11 because 3.12 breaks; see issue 348) + # current (using ubuntu 22.04 because latest will change to 24.04 with gdal 3.8 at some moment) - python: '3.12' - os: ubuntu-latest + os: ubuntu-22.04 setuptools: setuptools==69.* numpy: numpy==1.26.* pins: ""