diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5965ff3..c8e9917 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -14,9 +14,9 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] env: - USERNAME: GWmodel-Lab - FEED_URL: https://nuget.pkg.github.com/GWmodel-Lab/index.json - VCPKG_BINARY_SOURCES: "clear;nuget,github,readwrite" + USERNAME: ${{ github.repository_owner }} + FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite" VCPKG_USE_NUGET_CACHE: 1 permissions: contents: read @@ -41,7 +41,7 @@ jobs: shell: pwsh run: | cd "$env:VCPKG_INSTALLATION_ROOT" - git fetch + git fetch --tags git switch 2026.04.27 --detach - name: Setup NuGet Credentials @@ -50,36 +50,52 @@ jobs: run: | $VCPKG_EXE="$env:VCPKG_INSTALLATION_ROOT/vcpkg.exe" $NUGET_EXE="$(.$VCPKG_EXE fetch nuget)" + .$NUGET_EXE sources remove -Name github -NonInteractive 2>$null .$NUGET_EXE sources add -Source ${{ env.FEED_URL }} -Name github -UserName ${{ env.USERNAME }} -Password ${{ secrets.GITHUB_TOKEN }} -StorePasswordInClearText .$NUGET_EXE setapikey ${{ secrets.GITHUB_TOKEN }} -Source "${{ env.FEED_URL }}" + - name: Install native dependencies + if: runner.os == 'Windows' + shell: pwsh + run: | + $vcpkg = "$env:VCPKG_INSTALLATION_ROOT/vcpkg.exe" + & $vcpkg install armadillo gsl openblas[threads] --triplet x64-windows + + - name: Configure Vcpkg path + if: runner.os == 'Windows' + shell: pwsh + run: | + $vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT -replace '\\', '/' + "VCPKG_ROOT_FWD=$vcpkgRoot" >> $env:GITHUB_ENV + - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: "cp312-*" CIBW_SKIP: "pp* *-musllinux* *-manylinux_i686* *-win32 *-macosx_x86_64" CIBW_BEFORE_ALL_LINUX: > - apt-get update -qq && - apt-get install -qq libarmadillo-dev libopenblas-dev libgsl-dev + if command -v apt-get >/dev/null; then + apt-get update -qq && apt-get install -qq libarmadillo-dev libopenblas-dev libgsl-dev; + elif command -v dnf >/dev/null; then + dnf install -y armadillo-devel openblas-devel gsl-devel; + elif command -v yum >/dev/null; then + yum install -y armadillo-devel openblas-devel gsl-devel; + else + echo "No supported package manager found" && exit 1; + fi CIBW_ENVIRONMENT_LINUX: > CMAKE_ARGS="-DWITH_TESTS=OFF" - PYGW_TEST_DATA="{project}/tests/londonhp100.csv" CIBW_BEFORE_ALL_MACOS: brew install armadillo gsl openblas CIBW_ENVIRONMENT_MACOS: > CMAKE_ARGS="-DWITH_TESTS=OFF" - PYGW_TEST_DATA="{project}/tests/londonhp100.csv" - MACOSX_DEPLOYMENT_TARGET="10.14" - CIBW_BEFORE_ALL_WINDOWS: | - $vcpkg = "$env:VCPKG_INSTALLATION_ROOT/vcpkg.exe" - & $vcpkg install armadillo gsl openblas --triplet x64-windows + MACOSX_DEPLOYMENT_TARGET="15.0" CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel CIBW_ENVIRONMENT_WINDOWS: > - PATH="C:/vcpkg/installed/x64-windows/bin" - CMAKE_ARGS="-DWITH_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" - PYGW_TEST_DATA="{project}/tests/londonhp100.csv" + PATH="$VCPKG_ROOT_FWD/installed/x64-windows/bin;$PATH" + CMAKE_ARGS="-DWITH_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT_FWD/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_PREFIX_PATH=$VCPKG_ROOT_FWD/installed/x64-windows" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > python "${{ github.workspace }}/tools/repair_windows_wheel.py" {wheel} {dest_dir} - CIBW_TEST_COMMAND: "pytest {project}/tests -v" + CIBW_TEST_COMMAND: "pytest {project}/test -v" CIBW_TEST_REQUIRES: pytest - name: Upload wheels @@ -93,6 +109,9 @@ jobs: needs: build-wheels runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') + environment: + name: pypi + url: https://pypi.org/project/pygwmodel/ permissions: id-token: write diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aad475..139a065 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,9 +54,9 @@ jobs: name: windows-latest runs-on: windows-latest env: - USERNAME: GWmodel-Lab - FEED_URL: https://nuget.pkg.github.com/GWmodel-Lab/index.json - VCPKG_BINARY_SOURCES: "clear;nuget,github,readwrite" + USERNAME: ${{ github.repository_owner }} + FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite" VCPKG_USE_NUGET_CACHE: 1 permissions: contents: read @@ -80,6 +80,7 @@ jobs: run: | $VCPKG_EXE="$env:VCPKG_INSTALLATION_ROOT/vcpkg.exe" $NUGET_EXE="$(.$VCPKG_EXE fetch nuget)" + .$NUGET_EXE sources remove -Name github -NonInteractive 2>$null .$NUGET_EXE sources add -Source ${{ env.FEED_URL }} -Name github -UserName ${{ env.USERNAME }} -Password ${{ secrets.GITHUB_TOKEN }} -StorePasswordInClearText .$NUGET_EXE setapikey ${{ secrets.GITHUB_TOKEN }} -Source "${{ env.FEED_URL }}" diff --git a/.gitignore b/.gitignore index 25ef0cb..d0519ec 100644 --- a/.gitignore +++ b/.gitignore @@ -233,3 +233,4 @@ cython_debug/ # Sphinx !/doc/Makefile _build/ +.tmp* diff --git a/CMakeLists.txt b/CMakeLists.txt index dc488f1..30b4d1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module) +find_package(Python 3.12 REQUIRED COMPONENTS Interpreter Development.Module Development.SABIModule) # Detect the installed nanobind package and import it into CMake execute_process( @@ -49,6 +49,11 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif(MSVC) +if(WIN32) + # Prefer package config files (e.g. vcpkg-provided Armadillo config) over CMake modules. + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +endif() + add_subdirectory(libgwmodel) add_subdirectory(src) @@ -57,4 +62,3 @@ if(WITH_PYTESTS) enable_testing() add_subdirectory(test) endif(WITH_PYTESTS) - diff --git a/pyproject.toml b/pyproject.toml index 6ab204e..bd65bd4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,17 @@ build-backend = "scikit_build_core.build" [project] name = "pygwmodel" -version = "0.1.0" +version = "0.0.1" description = "A Python binding for GWmodel" readme = "README.md" +requires-python = ">=3.12" authors = [ { name = "Yigong Hu", email = "yigong.hu@outlook.com" } ] +dependencies = [ + "numpy", + "geopandas", +] [project.urls] Homepage = "https://github.com/GWmodel-Lab/pygwmodel" @@ -28,7 +33,7 @@ wheel.py-api = "cp312" build-verbosity = 1 build = "cp312-*" skip = "pp* *-musllinux* *-manylinux_i686* *-win32 *-macosx_x86_64" -test-command = "pytest {project}/tests -v" +test-command = "pytest {project}/test -v" test-requires = "pytest" [tool.cibuildwheel.macos.environment]