diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index 2fd910a..cf2f6f9 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -3,9 +3,9 @@ name: Build, test, package on: [push,pull_request] env: - itk-git-tag: "v5.3.0" - itk-wheel-tag: "v5.3.0" - itk-python-package-tag: "03391ad738438661fff40bfe37a7cfabd171b9b1" + itk-git-tag: "v5.4rc04" + itk-wheel-tag: "v5.4rc04" + itk-python-package-tag: "v5.4rc04" jobs: build-test-cxx: @@ -13,9 +13,9 @@ jobs: strategy: max-parallel: 3 matrix: - os: [ubuntu-20.04, windows-2022, macos-11] + os: [ubuntu-22.04, windows-2022, macos-12] include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 c-compiler: "gcc" cxx-compiler: "g++" cmake-build-type: "MinSizeRel" @@ -23,18 +23,18 @@ jobs: c-compiler: "cl.exe" cxx-compiler: "cl.exe" cmake-build-type: "Release" - - os: macos-11 + - os: macos-12 c-compiler: "clang" cxx-compiler: "clang++" cmake-build-type: "MinSizeRel" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" - name: Install build dependencies run: | @@ -43,7 +43,7 @@ jobs: python -m pip install cookiecutter - name: Get specific version of CMake, Ninja - uses: lukka/get-cmake@v3.24.2 + uses: lukka/get-cmake@v3.29.0 - name: Download ITK run: | @@ -139,7 +139,7 @@ jobs: shell: cmd build-linux-python-packages: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: max-parallel: 2 matrix: @@ -163,13 +163,13 @@ jobs: sudo apt install zstd unzstd --version - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" - name: Get specific version of CMake, Ninja - uses: lukka/get-cmake@v3.24.2 + uses: lukka/get-cmake@v3.29.0 - name: Evaluate template shell: bash @@ -202,31 +202,31 @@ jobs: path: Evaluated/ITKModuleTemplate/dist build-macos-python-packages: - runs-on: macos-11 + runs-on: macos-12 strategy: max-parallel: 2 matrix: python-version: ["38", "39", "310", "311"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Specific XCode version' run: | sudo xcode-select -s "/Applications/Xcode_13.2.1.app" - name: Get specific version of CMake, Ninja - uses: lukka/get-cmake@v3.24.2 + uses: lukka/get-cmake@v3.29.0 - name: 'Fetch build script' run: | curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/${{ env.itk-python-package-tag }}/scripts/macpython-download-cache-and-build-module-wheels.sh -O chmod u+x macpython-download-cache-and-build-module-wheels.sh - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" - name: Evaluate template shell: bash @@ -270,12 +270,12 @@ jobs: python-version: '3.x' - name: Get specific version of CMake, Ninja - uses: lukka/get-cmake@v3.24.2 + uses: lukka/get-cmake@v3.29.0 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.11" - name: Evaluate template shell: bash diff --git a/README.md b/README.md index 209df35..9113dd7 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ documentation, and Python package documentation. The output of the cookiecutter is a buildable ITK external module with example classes. Remove or replace the classes with your new classes. -Push your new module to GitHub, and enable builds on -[CircleCI](https://circleci.com/), [TravisCI](https://travis-ci.org/), -and [AppVeyor](https://www.appveyor.com/). +Push your new module to GitHub. Cross-platform C++ testing and Python +packaging is provided via the [ITKRemoteModuleBuildTestPackageAction] +reusable GitHub Action. Documentation on [how to populate the module](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html#x50-1430009) @@ -106,10 +106,21 @@ CI Testing and Python Packages Continuous integration service configurations are included to build and test the C++ core of packages across platforms and build binary -Python packages for Linux, macOS, and Windows. These packages can be -[downloaded](https://itkpythonpackage.readthedocs.io/en/master/Build_ITK_Module_Python_packages.html#github-automated-ci-package-builds) -and [uploaded to the Python Package Index -(PyPI)](https://itkpythonpackage.readthedocs.io/en/master/Build_ITK_Module_Python_packages.html#upload-the-packages-to-pypi). +Python packages for Linux, macOS, and Windows. For more information, see +the [ITKRemoteModuleBuildTestPackageAction] documentation. + +pyproject.toml migration +------------------------ + +ITK 5.4 added support for [scikit-build-core](https://scikit-build-core.readthedocs.io/en/latest/), +an update to scikit-build classic that supports [PEP +517](https://peps.python.org/pep-0517/) and other modern Python packaging +standards configured in the declarative *pyproject.toml* file. While the +*setup.py* file is still supported in ITK 5.4, migration to *pyproject.toml* +is encouraged. One important advantage is the generation of Stable ABI wheels +for Python 3.11+; these packages work with Python 3.11, 3.12, +3.13, 3.14, etc. To migrate to scikit-build-core, use the pyproject.toml +template in this repository and remove the *setup.py* file. ITKv4 Branch ------------ @@ -134,3 +145,5 @@ Authors - Bradley Lowekamp - Matt McCormick - Jean-Baptiste VIMORT + +[ITKRemoteModuleBuildTestPackageAction]: https://github.com/InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction diff --git a/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml b/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml index a2ae621..619e88e 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/build-test-package.yml @@ -4,9 +4,9 @@ on: [push,pull_request] jobs: cxx-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@246883ef3828fc00219145aeec9efa67b9889d0b + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@df1df6398389fa1a99d169b1264b9647d2164dd0 python-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@246883ef3828fc00219145aeec9efa67b9889d0b + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@df1df6398389fa1a99d169b1264b9647d2164dd0 secrets: pypi_password: ${{ "{{" }} secrets.pypi_password {{ "}}" }} diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml new file mode 100644 index 0000000..622f8e5 --- /dev/null +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -0,0 +1,108 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "{{ cookiecutter.python_package_name }}" +version = "0.1.0" +description = "{{ cookiecutter.project_short_description }}" +readme = "README.rst" +license = {file = "LICENSE"} +authors = [ + { name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" }, +] +keywords = [ + "itk", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Healthcare Industry", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Operating System :: Android", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: C++", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Medical Science Apps.", + "Topic :: Software Development :: Libraries", +] +requires-python = ">=3.8" +dependencies = [ + "itk>=5.4rc4", +] + +[project.urls] +Download = "{{ cookiecutter.download_url }}" +Homepage = "{{ cookiecutter.download_url }}" + +[tool.scikit-build] +# The versions of CMake to allow. If CMake is not present on the system or does +# not pass this specifier, it will be downloaded via PyPI if possible. An empty +# string will disable this check. +cmake.version = ">=3.16.3" + +# A list of args to pass to CMake when configuring the project. Setting this in +# config or envvar will override toml. See also ``cmake.define``. +cmake.args = [] + +# A table of defines to pass to CMake when configuring the project. Additive. +cmake.define = {} + +# Verbose printout when building. +cmake.verbose = true + +# The build type to use when building the project. Valid options are: "Debug", +# "Release", "RelWithDebInfo", "MinSizeRel", "", etc. +cmake.build-type = "Release" + +# The source directory to use when building the project. Currently only affects +# the native builder (not the setuptools plugin). +cmake.source-dir = "." + +# The versions of Ninja to allow. If Ninja is not present on the system or does +# not pass this specifier, it will be downloaded via PyPI if possible. An empty +# string will disable this check. +ninja.version = ">=1.11" + +# The logging level to display, "DEBUG", "INFO", "WARNING", and "ERROR" are +# possible options. +logging.level = "INFO" + +# Files to include in the SDist even if they are skipped by default. Supports +# gitignore syntax. +sdist.include = [] + +# Files to exclude from the SDist even if they are included by default. Supports +# gitignore syntax. +sdist.exclude = [] + +# A list of license files to include in the wheel. Supports glob patterns. +wheel.license-files = ["LICEN[CS]E*",] + +# Target the platlib or the purelib. If not set, the default is to target the +# platlib if wheel.cmake is true, and the purelib otherwise. +wheel.platlib = "false" + +# If CMake is less than this value, backport a copy of FindPython. Set to 0 +# disable this, or the empty string. +backport.find-python = "3.26.1" + +# Select the editable mode to use. Can be "redirect" (default) or "inplace". +editable.mode = "redirect" + +# Rebuild the project when the package is imported. The build-directory must be +# set. +editable.rebuild = false + +# If set, this will provide a method for scikit-build-core backward compatibility. +minimum-version = "0.8.2" + +# The build directory. Defaults to a temporary directory, but can be set. +build-dir = "build/{wheel_tag}" diff --git a/{{cookiecutter.project_name}}/setup.py b/{{cookiecutter.project_name}}/setup.py deleted file mode 100644 index 48d1e97..0000000 --- a/{{cookiecutter.project_name}}/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -from os import sys - -try: - from skbuild import setup -except ImportError: - print('scikit-build is required to build from source.', file=sys.stderr) - print('Please run:', file=sys.stderr) - print('', file=sys.stderr) - print(' python -m pip install scikit-build') - sys.exit(1) - -setup( - name='{{ cookiecutter.python_package_name }}', - version='0.1.0', - author='{{ cookiecutter.full_name }}', - author_email='{{ cookiecutter.email }}', - packages=['itk'], - package_dir={'itk': 'itk'}, - download_url=r'{{ cookiecutter.download_url }}', - description=r'{{ cookiecutter.project_short_description }}', - long_description='{{ cookiecutter.project_long_description }}', - classifiers=[ - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: C++", - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Healthcare Industry", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Medical Science Apps.", - "Topic :: Scientific/Engineering :: Information Analysis", - "Topic :: Software Development :: Libraries", - "Operating System :: Android", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS" - ], - license='Apache', - keywords='ITK InsightToolkit', - url=r'https://itk.org/', - install_requires=[ - r'itk>=5.3.0' - ] - )