From 4f08af2018206628db924e807b83330bc7851afb Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 5 Nov 2022 08:24:42 +0100 Subject: [PATCH 01/27] chore(build): move to scikitbuild-core --- .github/workflows/build.yml | 6 +- .gitignore | 1 + CMakeLists.txt | 11 ++- constraints-ci.txt | 2 - pyproject.toml | 73 +++++++++++---- requirements-deploy.txt | 6 -- requirements-dev.txt | 3 - requirements-test.txt | 12 --- setup.py | 171 ------------------------------------ src/cmake/__init__.py | 19 +--- 10 files changed, 69 insertions(+), 235 deletions(-) delete mode 100644 constraints-ci.txt delete mode 100644 requirements-deploy.txt delete mode 100644 requirements-dev.txt delete mode 100644 requirements-test.txt delete mode 100755 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3954c7648..76e76313b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -167,7 +167,7 @@ jobs: strategy: fail-fast: false matrix: - python: ["2.7", "3.6", "3.11"] + python: ["2.7", "3.6", "3.7", "3.11"] steps: - uses: actions/checkout@v3 @@ -180,7 +180,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libssl-dev - pip install -r requirements-dev.txt + pip install pytest pytest-virtualenv virtualenv - uses: actions/download-artifact@v3 with: @@ -189,7 +189,7 @@ jobs: - name: Install SDist env: - SKBUILD_CONFIGURE_OPTIONS: "-DBUILD_CMAKE_FROM_SOURCE:BOOL=OFF" + CMAKE_ARGS: "-DBUILD_CMAKE_FROM_SOURCE:BOOL=OFF" run: | pip install dist/*.tar.gz rm -rf dist diff --git a/.gitignore b/.gitignore index 18f666f1c..1f1e78141 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ develop-eggs .installed.cfg lib lib64 +wheelhouse # Installer logs pip-log.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a1ace243..7b9397f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,7 +372,11 @@ else() # Install CMakeProject install(CODE " message(STATUS \"Install CMake project\") +set(CMAKE_INSTALL_PREFIX_BACKUP \"\${CMAKE_INSTALL_PREFIX}\") +set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/cmake/data\") include\(\"${CMakeProject_BINARY_DIR}/cmake_install.cmake\") +set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX_BACKUP}\") +unset(CMAKE_INSTALL_PREFIX_BACKUP) ") #----------------------------------------------------------------------------- @@ -424,8 +428,11 @@ include\(\"${CMakeProject_BINARY_DIR}/cmake_install.cmake\") WORLD_READ WORLD_EXECUTE ) endif() - install(${type} ${file} DESTINATION "${relative_directory}" ${_permissions}) + install(${type} ${file} DESTINATION "cmake/data/${relative_directory}" ${_permissions}) endforeach() endif() - + install(FILES src/cmake/__init__.py DESTINATION "cmake") + install(FILES src/cmake/__init__.pyi DESTINATION "cmake") + install(FILES src/cmake/_version.py DESTINATION "cmake") + install(FILES src/cmake/py.typed DESTINATION "cmake") endif() diff --git a/constraints-ci.txt b/constraints-ci.txt deleted file mode 100644 index 0f2e50971..000000000 --- a/constraints-ci.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake==3.24.3 -ninja==1.11.1 diff --git a/pyproject.toml b/pyproject.toml index ad0717088..9bf79b441 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,59 @@ [build-system] -requires = [ - "scikit-build>=0.12", - "setuptools>=42", +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "cmake" +version = "0.0.1" +description = "CMake is an open-source, cross-platform family of tools designed to build, test and package software" +keywords = ["CMake", "build", "c++", "fortran", "cross-platform", "cross-compilation"] +readme = "README.rst" +license = {text = "Apache 2.0"} +authors = [ + {name = "Jean-Christophe Fillion-Robin", email = "jchris.fillionr@kitware.com"}, +] +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "License :: OSI Approved :: BSD License", + "Programming Language :: C", + "Programming Language :: C++", + "Programming Language :: Fortran", + "Programming Language :: Python", + "Operating System :: OS Independent", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "Typing :: Typed" +] +requires-python = ">=3.7" + +[project.urls] +Homepage = "https://cmake.org" +Documentation = "https://cmake-python-distributions.readthedocs.io" +Source = "ttps://github.com/scikit-build/cmake-python-distributions" +"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build" +"Bug Tracker" = "https://github.com/scikit-build/cmake-python-distributions/issues" + +[project.optional-dependencies] +test = [ + "codecov>=2.0.5", + "coverage>=4.2", + "flake8>=3.0.4", + "path.py>=11.5.0", + "pytest>=3.0.3", + "pytest-cov>=2.4.0", + "pytest-runner>=2.9", + "pytest-virtualenv>=1.7.0", + "virtualenv>=15.0.3" ] -build-backend = "setuptools.build_meta" + +[project.scripts] +cmake = "cmake:cmake" +cpack = "cmake:cpack" +ctest = "cmake:ctest" [tool.cibuildwheel] build = "cp39-*" -before-all = [ - 'pipx install -f --pip-args="-c {project}/constraints-ci.txt" cmake', - 'cmake --version', - 'pipx install -f --pip-args="-c {project}/constraints-ci.txt" ninja', - 'ninja --version', -] before-build = "pip install -r requirements-repair.txt" repair-wheel-command = "python scripts/repair_wheel.py -w {dest_dir} {wheel}" test-extras = "test" @@ -21,30 +62,26 @@ build-verbosity = "1" [tool.cibuildwheel.linux] before-all = [ - 'pipx install -f --pip-args="-c {project}/constraints-ci.txt" cmake', - 'cmake --version', - 'pipx install -f --pip-args="-c {project}/constraints-ci.txt" ninja', - 'ninja --version', './scripts/manylinux-build-and-install-openssl.sh', ] -environment = { SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DCMAKE_CXX_STANDARD:STRING=11" } +environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DCMAKE_CXX_STANDARD:STRING=11" } [[tool.cibuildwheel.overrides]] select = ["*-manylinux_aarch64", "*-manylinux_ppc64le", "*-manylinux_s390x"] # disable tests on those platforms, QEMU is taking to long for jobs to pass on GHA -environment = { SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DCMAKE_CXX_STANDARD:STRING=11 -DRUN_CMAKE_TEST:BOOL=OFF" } +environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DCMAKE_CXX_STANDARD:STRING=11 -DRUN_CMAKE_TEST:BOOL=OFF" } [[tool.cibuildwheel.overrides]] select = ["*-musllinux_x86_64", "*-musllinux_i686"] # disable some tests # - BootstrapTest fails with custom OpenSSL and probably does not make much sense for this project # - ExportImport|RunCMake.install|RunCMake.file-GET_RUNTIME_DEPENDENCIES: c.f. https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064 -environment = { SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DRUN_CMAKE_TEST_EXCLUDE:STRING='BootstrapTest|ExportImport|RunCMake.install|RunCMake.file-GET_RUNTIME_DEPENDENCIES'" } +environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DRUN_CMAKE_TEST_EXCLUDE:STRING='BootstrapTest|ExportImport|RunCMake.install|RunCMake.file-GET_RUNTIME_DEPENDENCIES'" } [[tool.cibuildwheel.overrides]] select = ["*-musllinux_aarch64", "*-musllinux_ppc64le", "*-musllinux_s390x"] # disable tests on those platforms, QEMU is taking to long for jobs to pass on GHA -environment = { SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DRUN_CMAKE_TEST:BOOL=OFF" } +environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1 -DRUN_CMAKE_TEST:BOOL=OFF" } [tool.cibuildwheel.macos.environment] MACOSX_DEPLOYMENT_TARGET = "10.10" diff --git a/requirements-deploy.txt b/requirements-deploy.txt deleted file mode 100644 index 9806d5685..000000000 --- a/requirements-deploy.txt +++ /dev/null @@ -1,6 +0,0 @@ - -# need to pin cryptography for s390x/ppc64le builds: -# cryptography never provided wheels for those architectures and the -# requirements to build from sources are relaxed when building the 3.3 series -cryptography~=3.3.2 ; sys_platform=="linux" and platform_machine in "s390x, ppc64le" -twine diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index cc4b63fa1..000000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ --r requirements-test.txt --r requirements-repair.txt --r requirements-deploy.txt diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index c6b5a67ea..000000000 --- a/requirements-test.txt +++ /dev/null @@ -1,12 +0,0 @@ -codecov>=2.0.5 -coverage>=4.2 -flake8>=3.0.4 -path.py>=11.5.0 -pytest>=3.0.3 -pytest-cov>=2.4.0 -pytest-runner>=2.9 -pytest-virtualenv>=1.7.0 -scikit-build>=0.10.0 -setuptools>=28.0.0 -virtualenv>=15.0.3 -wheel diff --git a/setup.py b/setup.py deleted file mode 100755 index 706e0a9eb..000000000 --- a/setup.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -from distutils.text_file import TextFile - -from skbuild import setup - -# Add current folder to path -# This is required to import versioneer in an isolated pip build -# Prepending allows not to break on a non-isolated build when versioneer -# is already installed (c.f. https://github.com/scikit-build/cmake-python-distributions/issues/171) -sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) - -import versioneer # noqa: E402 - -with open('README.rst', 'r') as fp: - readme = fp.read() - -with open('HISTORY.rst', 'r') as fp: - history = fp.read().replace('.. :changelog:', '') - - -def parse_requirements(filename): - with open(filename, 'r') as file: - return TextFile(filename, file).readlines() - - -test_requirements = parse_requirements('requirements-test.txt') - -try: # noqa: C901 - setup( - name='cmake', - - version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), - - author='Jean-Christophe Fillion-Robin', - author_email='jchris.fillionr@kitware.com', - - package_dir={'': 'src'}, - packages=['cmake'], - package_data={"cmake": ["py.typed"]}, - - cmake_install_dir='src/cmake/data', - - entry_points={ - 'console_scripts': [ - 'cmake=cmake:cmake', 'cpack=cmake:cpack', 'ctest=cmake:ctest' - ] - }, - - url='https://cmake.org/', - download_url='https://cmake.org/download', - project_urls={ - "Documentation": "https://cmake-python-distributions.readthedocs.io/", - "Source Code": "https://github.com/scikit-build/cmake-python-distributions", - "Mailing list": "https://groups.google.com/forum/#!forum/scikit-build", - "Bug Tracker": "https://github.com/scikit-build/cmake-python-distributions/issues", - }, - - - description='CMake is an open-source, cross-platform family of ' - 'tools designed to build, test and package software', - - long_description=readme + '\n\n' + history, - long_description_content_type='text/x-rst', - - classifiers=[ - 'License :: OSI Approved :: Apache Software License', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: C', - 'Programming Language :: C++', - 'Programming Language :: Fortran', - 'Programming Language :: Python', - 'Operating System :: OS Independent', - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Build Tools', - 'Typing :: Typed', - ], - - license='Apache 2.0', - - keywords='CMake build c++ fortran cross-platform cross-compilation', - - extras_require={"test": test_requirements}, - ) -except BaseException: - # Note: This is a bare exception that re-raises so that we don't interfere - # with anything the installation machinery might want to do. Because we - # print this for any exception this msg can appear (e.g. in verbose logs) - # even if there's no failure. For example, SetupRequirementsError is raised - # during PEP517 building and prints this text. setuptools raises SystemExit - # when compilation fails right now, but it's possible this isn't stable - # or a public API commitment so we'll remain ultra conservative. - import platform - import subprocess - try: - import pkg_resources - except ImportError: - pass - - print( - """ - =============================DEBUG ASSISTANCE============================= - If you are seeing a compilation error please try the following steps to - successfully install cmake: - 1) Upgrade to the latest pip and try again. This will fix errors for most - users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip - 2) If on Linux, with glibc < 2.12, you can set PIP_ONLY_BINARY=cmake in - order to retrieve the last manylinux1 compatible wheel. - 3) If on Linux, with glibc < 2.12, you can cap "cmake<3.23" in your - requirements in order to retrieve the last manylinux1 compatible wheel. - 4) Open an issue with the debug information that follows at - https://github.com/scikit-build/cmake-python-distributions/issues - """ - ) - print(" Python: %s" % '.'.join(str(v) for v in sys.version_info[:3])) - print(" platform: %s" % platform.platform()) - if sys.platform.startswith("linux"): - try: - print(" glibc: %s" % os.confstr("CS_GNU_LIBC_VERSION")) - except BaseException: - try: - import ctypes - process_namespace = ctypes.CDLL(None) - gnu_get_libc_version = process_namespace.gnu_get_libc_version - gnu_get_libc_version.restype = ctypes.c_char_p - glibc_version = gnu_get_libc_version() - if not isinstance(glibc_version, str): - glibc_version = glibc_version.decode("ascii") - print(" glibc: %s" % glibc_version) - except BaseException: - pass - if sys.platform.startswith("darwin"): - try: - macos_ver = subprocess.check_output( - [ - sys.executable, - "-sS", - "-c", - "import platform; print(platform.mac_ver()[0])", - ], - universal_newlines=True, - env={"SYSTEM_VERSION_COMPAT": "0"}, - ).strip() - print(" macos: %s" % macos_ver) - except BaseException: - try: - print(" macos: %s" % platform.mac_ver()[0]) - except BaseException: - pass - print(" machine: %s" % platform.machine()) - print(" bits: %d" % (64 if sys.maxsize > 2**32 else 32)) - for dist in ["pip", "setuptools", "scikit-build"]: - try: - version = pkg_resources.get_distribution(dist).version - except BaseException: - version = "n/a" - print(" {}: {}".format(dist, version)) - for key in ["PEP517_BUILD_BACKEND"]: - if key in os.environ: - print(" {}={}".format(key, os.environ[key])) - print( - """\ - =============================DEBUG ASSISTANCE============================= - """ - ) - raise diff --git a/src/cmake/__init__.py b/src/cmake/__init__.py index c4b717f1b..f701ad174 100644 --- a/src/cmake/__init__.py +++ b/src/cmake/__init__.py @@ -11,24 +11,7 @@ CMAKE_DATA = os.path.join(os.path.dirname(__file__), 'data') -# Support running tests from the source tree -if not os.path.exists(CMAKE_DATA): - from skbuild.constants import CMAKE_INSTALL_DIR as SKBUILD_CMAKE_INSTALL_DIR - from skbuild.constants import set_skbuild_plat_name - - if sys.platform.startswith("darwin"): - # Since building the project specifying --plat-name or CMAKE_OSX_* variables - # leads to different SKBUILD_DIR, the code below attempt to guess the most - # likely plat-name. - _skbuild_dirs = os.listdir(os.path.join(os.path.dirname(__file__), '..', '..', '_skbuild')) - if _skbuild_dirs: - _likely_plat_name = '-'.join(_skbuild_dirs[0].split('-')[:3]) - set_skbuild_plat_name(_likely_plat_name) - - _cmake_data = os.path.abspath(os.path.join( - os.path.dirname(__file__), '..', '..', SKBUILD_CMAKE_INSTALL_DIR(), 'src/cmake/data')) - if os.path.exists(_cmake_data): - CMAKE_DATA = _cmake_data +assert os.path.exists(CMAKE_DATA) CMAKE_BIN_DIR = os.path.join(CMAKE_DATA, 'bin') CMAKE_DOC_DIR = os.path.join(CMAKE_DATA, 'doc') From 162cc1b88250f4505aba620725db62a16cc37497 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 5 Nov 2022 12:07:39 +0100 Subject: [PATCH 02/27] debug sdist build --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76e76313b..53e039579 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -191,6 +191,7 @@ jobs: env: CMAKE_ARGS: "-DBUILD_CMAKE_FROM_SOURCE:BOOL=OFF" run: | + pip -V pip install dist/*.tar.gz rm -rf dist From 7d1193de2a5eaa4931c71ef15bdc58f01fdd7a27 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sun, 6 Nov 2022 00:19:24 -0400 Subject: [PATCH 03/27] tests: missing dep --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53e039579..3be58b9a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -180,7 +180,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libssl-dev - pip install pytest pytest-virtualenv virtualenv + pip install pytest pytest-virtualenv virtualenv pytest-cov - uses: actions/download-artifact@v3 with: From ffb30f129a8a80e7c0d4a851a504952e928e0d7f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 7 Nov 2022 16:42:58 -0500 Subject: [PATCH 04/27] fix: more logging Update pyproject.toml Apply suggestions from code review Update pyproject.toml WIP: try branch of skbc Update pyproject.toml WIP: right before repro builds Signed-off-by: Henry Schreiner --- CMakeLists.txt | 4 ---- pyproject.toml | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b9397f5a..fbee877f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -431,8 +431,4 @@ unset(CMAKE_INSTALL_PREFIX_BACKUP) install(${type} ${file} DESTINATION "cmake/data/${relative_directory}" ${_permissions}) endforeach() endif() - install(FILES src/cmake/__init__.py DESTINATION "cmake") - install(FILES src/cmake/__init__.pyi DESTINATION "cmake") - install(FILES src/cmake/_version.py DESTINATION "cmake") - install(FILES src/cmake/py.typed DESTINATION "cmake") endif() diff --git a/pyproject.toml b/pyproject.toml index 9bf79b441..f1beffdff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core"] +requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core@73ce73a9967d1bf6932522ba6af9f2c881e17f3a"] build-backend = "scikit_build_core.build" [project] @@ -52,6 +52,9 @@ cmake = "cmake:cmake" cpack = "cmake:cpack" ctest = "cmake:ctest" +# [tool.scikit-build] +# sdist.reproducible = false + [tool.cibuildwheel] build = "cp39-*" before-build = "pip install -r requirements-repair.txt" From a4be5aa86eed8640cd284a5d7f8ee194f4958b2d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 15 Nov 2022 17:03:25 -0500 Subject: [PATCH 05/27] fix: avoid make fallback Signed-off-by: Henry Schreiner --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1beffdff..0d3a5042b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core@73ce73a9967d1bf6932522ba6af9f2c881e17f3a"] +requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core@main"] build-backend = "scikit_build_core.build" [project] @@ -52,8 +52,8 @@ cmake = "cmake:cmake" cpack = "cmake:cpack" ctest = "cmake:ctest" -# [tool.scikit-build] -# sdist.reproducible = false +[tool.scikit-build] +ninja.make-fallback = false [tool.cibuildwheel] build = "cp39-*" From 8ae06872e43d1747a3abd596a1eb6b4716586b6d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 16 Nov 2022 18:23:13 -0500 Subject: [PATCH 06/27] fix: use more scikit-build-core options Signed-off-by: Henry Schreiner Update pyproject.toml --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 6 +- pyproject.toml | 9 +- requirements-repair.txt | 1 - scripts/convert_to_generic_platform_wheel.py | 209 ------------------- scripts/repair_wheel.py | 92 -------- 6 files changed, 7 insertions(+), 312 deletions(-) delete mode 100644 requirements-repair.txt delete mode 100644 scripts/convert_to_generic_platform_wheel.py delete mode 100755 scripts/repair_wheel.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be58b9a9..3a747981c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,7 @@ jobs: build: "" use_qemu: false - os: macos-11 - arch: "x86_64" + arch: "universal2" build: "" use_qemu: false diff --git a/CMakeLists.txt b/CMakeLists.txt index fbee877f3..75b84d033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,11 +372,7 @@ else() # Install CMakeProject install(CODE " message(STATUS \"Install CMake project\") -set(CMAKE_INSTALL_PREFIX_BACKUP \"\${CMAKE_INSTALL_PREFIX}\") -set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX}/cmake/data\") include\(\"${CMakeProject_BINARY_DIR}/cmake_install.cmake\") -set(CMAKE_INSTALL_PREFIX \"\${CMAKE_INSTALL_PREFIX_BACKUP}\") -unset(CMAKE_INSTALL_PREFIX_BACKUP) ") #----------------------------------------------------------------------------- @@ -428,7 +424,7 @@ unset(CMAKE_INSTALL_PREFIX_BACKUP) WORLD_READ WORLD_EXECUTE ) endif() - install(${type} ${file} DESTINATION "cmake/data/${relative_directory}" ${_permissions}) + install(${type} ${file} DESTINATION "${relative_directory}" ${_permissions}) endforeach() endif() endif() diff --git a/pyproject.toml b/pyproject.toml index 0d3a5042b..8c49e4ec6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core@main"] +requires = ["scikit-build-core"] build-backend = "scikit_build_core.build" [project] name = "cmake" -version = "0.0.1" +version = "3.25.0" description = "CMake is an open-source, cross-platform family of tools designed to build, test and package software" keywords = ["CMake", "build", "c++", "fortran", "cross-platform", "cross-compilation"] readme = "README.rst" @@ -54,11 +54,12 @@ ctest = "cmake:ctest" [tool.scikit-build] ninja.make-fallback = false +wheel.py-api = "py2.py3" +wheel.expand-macos-universal-tags = true +wheel.install-dir = "cmake/data" [tool.cibuildwheel] build = "cp39-*" -before-build = "pip install -r requirements-repair.txt" -repair-wheel-command = "python scripts/repair_wheel.py -w {dest_dir} {wheel}" test-extras = "test" test-command = "pytest --ignore={project}/tests/test_distribution.py {project}/tests" build-verbosity = "1" diff --git a/requirements-repair.txt b/requirements-repair.txt deleted file mode 100644 index 6a357b865..000000000 --- a/requirements-repair.txt +++ /dev/null @@ -1 +0,0 @@ -wheeltools @ git+https://github.com/jcfr/wheeltools.git@wheeltools-2018-10-28-a2f174d0e#egg=wheeltools diff --git a/scripts/convert_to_generic_platform_wheel.py b/scripts/convert_to_generic_platform_wheel.py deleted file mode 100644 index 0a0598d5c..000000000 --- a/scripts/convert_to_generic_platform_wheel.py +++ /dev/null @@ -1,209 +0,0 @@ -# -*- coding: utf-8 -*- -import argparse -import logging -import os -import sys -from itertools import product -from os.path import abspath, basename, dirname, isfile -from os.path import join as pjoin -from os.path import splitext - -try: - from wheel.install import WheelFile -except ImportError: # As of Wheel 0.32.0 - from wheel.wheelfile import WheelFile - -from wheel.pkginfo import read_pkg_info, write_pkg_info -from wheeltools.tools import unique_by_index -from wheeltools.wheeltools import InWheelCtx - -logger = logging.getLogger(splitext(basename(__file__))[0]) - - -def _get_wheelinfo_name(wheelfile): - # Work round wheel API compatibility - try: - return wheelfile.wheelinfo_name - except AttributeError: - return wheelfile.dist_info_path + "/WHEEL" - - -def _to_generic_pyver(pyver_tags): - """Convert from CPython implementation to generic python version tags - - Convert each CPython version tag to the equivalent generic tag. - - For example:: - - cp35 -> py3 - cp27 -> py2 - - See https://www.python.org/dev/peps/pep-0425/#python-tag - """ - return ['py%s' % tag[2] if tag.startswith('cp') else tag for tag in pyver_tags] - - -def _convert_to_generic_platform_wheel(wheel_ctx, py2_py3, additional_platforms): - """Switch to generic python tags and remove ABI tags from a wheel - - Convert implementation specific python tags to their generic equivalent and - remove all ABI tags from wheel_ctx's filename and ``WHEEL`` file. - - Parameters - ---------- - wheel_ctx : InWheelCtx - An open wheel context - py2_py3: Bool - Wether the pyver tag shall be py2.py3 or just the one inferred from the wheel name - additional_platforms : Optional[Iterable[str]] - An optional iterable of additional platform to add to the wheel - """ - - abi_tags = ['none'] - - wf = WheelFile(wheel_ctx.in_wheel) - info_fname = _get_wheelinfo_name(wf) - info = read_pkg_info(info_fname) - - # Check what tags we have - if wheel_ctx.out_wheel is not None: - out_dir = dirname(wheel_ctx.out_wheel) - wheel_fname = basename(wheel_ctx.out_wheel) - else: - out_dir = '.' - wheel_fname = basename(wheel_ctx.in_wheel) - - # Update wheel filename - fparts = wf.parsed_filename.groupdict() - platform_tags = fparts['plat'].split('.') - logger.debug('Previous platform tags: %s', ', '.join(platform_tags)) - if additional_platforms: - platform_tags = list(sorted(set(platform_tags + [p for p in additional_platforms]))) - fparts['plat'] = '.'.join(platform_tags) - logger.debug('New platform tags ....: %s', ', '.join(platform_tags)) - else: - logger.debug('No platform tags change needed.') - - original_abi_tags = fparts['abi'].split('.') - logger.debug('Previous ABI tags: %s', ', '.join(original_abi_tags)) - if abi_tags != original_abi_tags: - logger.debug('New ABI tags ....: %s', ', '.join(abi_tags)) - fparts['abi'] = '.'.join(abi_tags) - else: - logger.debug('No ABI tags change needed.') - - original_pyver_tags = fparts['pyver'].split('.') - logger.debug('Previous pyver tags: %s', ', '.join(original_pyver_tags)) - pyver_tags = _to_generic_pyver(original_pyver_tags) - if py2_py3: - if len({"py2", "py3"} & set(pyver_tags)) == 0: - raise ValueError("pyver_tags does not contain py2 nor py3") - pyver_tags = list(sorted(set(pyver_tags + ["py2", "py3"]))) - if pyver_tags != original_pyver_tags: - logger.debug('New pyver tags ....: %s', ', '.join(pyver_tags)) - fparts['pyver'] = '.'.join(pyver_tags) - else: - logger.debug('No pyver change needed.') - - _, ext = splitext(wheel_fname) - fparts['ext'] = ext - out_wheel_fname = "{namever}-{pyver}-{abi}-{plat}{ext}".format(**fparts) - - logger.info('Previous filename: %s', wheel_fname) - if out_wheel_fname != wheel_fname: - logger.info('New filename ....: %s', out_wheel_fname) - else: - logger.info('No filename change needed.') - - out_wheel = pjoin(out_dir, out_wheel_fname) - - # Update wheel tags - in_info_tags = [tag for name, tag in info.items() if name == 'Tag'] - logger.info('Previous WHEEL info tags: %s', ', '.join(in_info_tags)) - - # Python version, C-API version combinations - pyc_apis = [] - for py_ver in pyver_tags: - abi = 'none' - pyc_apis.append('-'.join([py_ver, abi])) - # unique Python version, C-API version combinations - pyc_apis = unique_by_index(pyc_apis) - - # Set tags for each Python version, C-API combination - updated_tags = ['-'.join(tup) for tup in product(pyc_apis, platform_tags)] - - if updated_tags != in_info_tags: - del info['Tag'] - for tag in updated_tags: - info.add_header('Tag', tag) - - logger.info('New WHEEL info tags ....: %s', ', '.join(info.get_all('Tag'))) - write_pkg_info(info_fname, info) - else: - logger.info('No WHEEL info change needed.') - return out_wheel - - -def convert_to_generic_platform_wheel(wheel_path, out_dir='./dist/', remove_original=False, verbose=0, - py2_py3=False, additional_platforms=None): - logging.disable(logging.NOTSET) - if verbose >= 1: - logging.basicConfig(level=logging.DEBUG) - else: - logging.basicConfig(level=logging.INFO) - - wheel_fname = basename(wheel_path) - out_dir = abspath(out_dir) - - with InWheelCtx(wheel_path) as ctx: - ctx.out_wheel = pjoin(out_dir, wheel_fname) - ctx.out_wheel = _convert_to_generic_platform_wheel(ctx, py2_py3, additional_platforms) - - if remove_original: - logger.info('Removed original wheel %s' % wheel_path) - os.remove(wheel_path) - - -def main(): - p = argparse.ArgumentParser(description='Convert wheel to be independent of python implementation and ABI') - p.set_defaults(prog=basename(sys.argv[0])) - p.add_argument("-v", - "--verbose", - action='count', - dest='verbose', - default=0, - help='Give more output. Option is additive') - - p.add_argument('WHEEL_FILE', help='Path to wheel file.') - p.add_argument('-w', - '--wheel-dir', - dest='WHEEL_DIR', - type=abspath, - help='Directory to store updated wheels (default: "dist/")', - default='dist/') - p.add_argument("-r", - "--remove-original", - dest='remove_original', - action='store_true', - help='Remove original wheel') - p.add_argument("--py2-py3", - dest='py2_py3', - action='store_true', - help='Remove original wheel') - p.add_argument("-p", - "--add-platform", - dest='additional_platforms', - action="append", - help='Add a platform tag') - - args = p.parse_args() - - if not isfile(args.WHEEL_FILE): - p.error('cannot access %s. No such file' % args.WHEEL_FILE) - - convert_to_generic_platform_wheel(args.WHEEL_FILE, args.WHEEL_DIR, args.remove_original, args.verbose, - args.py2_py3, args.additional_platforms) - - -if __name__ == '__main__': - main() diff --git a/scripts/repair_wheel.py b/scripts/repair_wheel.py deleted file mode 100755 index 703a0e8f6..000000000 --- a/scripts/repair_wheel.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import argparse -import re -import shutil -import subprocess -import sys -import tempfile -from pathlib import Path - -from convert_to_generic_platform_wheel import convert_to_generic_platform_wheel - - -def main(): - if sys.platform.startswith("linux"): - os_ = "linux" - elif sys.platform.startswith("darwin"): - os_ = "macos" - elif sys.platform.startswith("win32"): - os_ = "windows" - else: - raise NotImplementedError("sys.platform '{}' is not supported yet.".format(sys.platform)) - - p = argparse.ArgumentParser(description="Convert wheel to be independent of python implementation and ABI") - p.set_defaults(prog=Path(sys.argv[0]).name) - p.add_argument("WHEEL_FILE", help="Path to wheel file.") - p.add_argument( - "-w", - "--wheel-dir", - dest="WHEEL_DIR", - help=('Directory to store delocated wheels (default: "wheelhouse/")'), - default="wheelhouse/", - ) - - args = p.parse_args() - - file = Path(args.WHEEL_FILE).resolve(strict=True) - wheelhouse = Path(args.WHEEL_DIR).resolve() - wheelhouse.mkdir(parents=True, exist_ok=True) - - with tempfile.TemporaryDirectory() as tmpdir_: - tmpdir = Path(tmpdir_) - # use the platform specific repair tool first - if os_ == "linux": - subprocess.run(["auditwheel", "repair", "-w", str(tmpdir), str(file)], check=True, stdout=subprocess.PIPE) - elif os_ == "macos": - # delocate does not pass for now: https://github.com/matthew-brett/delocate/issues/105 - # subprocess.run( - # ["delocate-wheel", "--require-archs", "arm64,x86_64", "-w", str(tmpdir), str(file)], - # check=True, - # stdout=subprocess.PIPE, - # ) - shutil.copyfile(file, tmpdir / file.name) - elif os_ == "windows": - # no specific tool, just copy - shutil.copyfile(file, tmpdir / file.name) - (file,) = tmpdir.glob("*.whl") - - # we need to handle macOS universal2 & arm64 here for now, let's use additional_platforms for this. - additional_platforms = [] - if os_ == "macos": - # first, get the target macOS deployment target from the wheel - match = re.match(r"^.*-macosx_(\d+)_(\d+)_x86_64\.whl$", file.name) - assert match is not None - target = tuple(map(int, match.groups())) - - # let's add universal2 platform for this wheel. - additional_platforms = ["macosx_{}_{}_universal2".format(*target)] - - # given pip support for universal2 was added after arm64 introduction - # let's also add arm64 platform. - arm64_target = target - if arm64_target < (11, 0): - arm64_target = (11, 0) - additional_platforms.append("macosx_{}_{}_arm64".format(*arm64_target)) - - if target < (11, 0): - # They're were also issues with pip not picking up some universal2 wheels, tag twice - additional_platforms.append("macosx_11_0_universal2") - - # make this a py2.py3 wheel - convert_to_generic_platform_wheel( - str(file), - out_dir=str(wheelhouse), - py2_py3=True, - additional_platforms=additional_platforms, - ) - - -if __name__ == "__main__": - main() From 55ab1914efc169bc5e42f5495fa7293ca345abea Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 17 Nov 2022 00:30:11 -0500 Subject: [PATCH 07/27] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8c49e4ec6..c3b3e6a5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core"] +requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core"] build-backend = "scikit_build_core.build" [project] From deb808449e4f7f7ff153eaea7c0b556e2ad136b4 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 17 Nov 2022 10:33:50 -0500 Subject: [PATCH 08/27] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c3b3e6a5d..8c49e4ec6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core @ git+https://github.com/scikit-build/scikit-build-core"] +requires = ["scikit-build-core"] build-backend = "scikit_build_core.build" [project] From 46e26bc5a145d21e6e1ee59c2a5477abd577a93b Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 12:54:26 -0500 Subject: [PATCH 09/27] fix: Remove unneeded MANIFEST.in file See https://scikit-build-core.readthedocs.io/en/latest/migration_guide.html#config-changes --- MANIFEST.in | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e060c63b0..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,15 +0,0 @@ -include CMakeLists.txt -include CMakeUrls.cmake -include requirements-test.txt -include HISTORY.rst -include README.rst -include LICENSE_Apache_20 -include LICENSE_BSD_3 - -recursive-exclude _skbuild * -recursive-exclude CMake-src * - -include src/cmake/_version.py -include src/cmake/_version.pyi -include src/cmake/__init__.pyi -include src/cmake/py.typed From 29de4a9a1ac25960217931526a5a84d24954f6f7 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 12:56:20 -0500 Subject: [PATCH 10/27] fix: Remove unneeded setup.cfg file Test command is already specified in pyproject.toml --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0cd99068b..000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[tool:pytest] -testpaths = tests -addopts = -v --cov --cov-report xml From 8a9654e2514cf062c7869fc73f0237af023e8f65 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:00:03 -0500 Subject: [PATCH 11/27] fix: Add missing sdist.include for _version.py --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 1ff2ab7d9..daea7a636 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ ctest = "cmake:ctest" [tool.scikit-build] ninja.make-fallback = false +sdist.include = ["src/cmake/_version.py"] wheel.py-api = "py2.py3" wheel.expand-macos-universal-tags = true wheel.install-dir = "cmake/data" From 38da55b773e0a8f8dc782d2df3c78d3c30203563 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:00:34 -0500 Subject: [PATCH 12/27] fix: Add missing metadata.version.provider --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index daea7a636..98c494c73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ cpack = "cmake:cpack" ctest = "cmake:ctest" [tool.scikit-build] +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" ninja.make-fallback = false sdist.include = ["src/cmake/_version.py"] wheel.py-api = "py2.py3" From 5b1ad88e6f557b4d60c15e99e1a11609eb1c9ba2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:03:19 -0500 Subject: [PATCH 13/27] fix: Set scikit-build `minimum-version` and `build-dir` --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 98c494c73..6ae65adc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ cpack = "cmake:cpack" ctest = "cmake:ctest" [tool.scikit-build] +minimum-version = "0.4" +build-dir = "build/{wheel_tag}" metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" ninja.make-fallback = false sdist.include = ["src/cmake/_version.py"] From c4fe12c22a99b5d3396d691153080ba0a6a9cf23 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:12:28 -0500 Subject: [PATCH 14/27] fix: Drop support for building sdist on Python 2.7 and 3.6 From https://github.com/scikit-build/cmake-python-distributions/pull/312#discussion_r1034288054 > If we build from SDist, I think it's already much slower, more likely > to fail, etc - it's really supposed to be a wheel distribution. So not > supporting building from SDist on <=3.6 doesn't seem too bad. And a user > can always either use Python 3.7+ to build a wheel then install it on > 2.7-3.6, or use an older version. --- .github/workflows/build.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdd39edad..58532cc39 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -173,31 +173,19 @@ jobs: test_sdist: name: Test SDist with python ${{ matrix.python }} needs: [build_sdist] - # 22.04 doesn't have 2.7 or 3.6 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - python: ["2.7", "3.6", "3.7", "3.12"] + python: ["3.7", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - if: matrix.python != '2.7' name: Install Python ${{ matrix.python }} with: python-version: ${{ matrix.python }} - - name: Install Ubuntu Python 2.7 - if: matrix.python == '2.7' - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends python2 python3-virtualenv - virtualenv -p python2 ${HOME}/cp27 - ${HOME}/cp27/bin/python -m pip install -U pip - ${HOME}/cp27/bin/python -m pip install -U setuptools wheel - echo "${HOME}/cp27/bin" >> $GITHUB_PATH - - name: Install dependencies run: | sudo apt-get update From 3da2d85fc2c43d61180bd8e4ad913b68b1103ca2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:22:36 -0500 Subject: [PATCH 15/27] fix(ci): Fix 3.12 sdist test removing unneeded install of pytest-virtualenv The use of the `virtualenv` pytest fixture become obsolete following commit 280260d ("chore(ci): bump `test_sdist` python from 3.11 to 3.12 (#423)", 2023-12-02) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58532cc39..0cc4eae24 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -190,7 +190,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libssl-dev - pip install pytest pytest-virtualenv virtualenv pytest-cov + pip install pytest pytest-cov - uses: actions/download-artifact@v4 with: From 641b73834b5e80c6ccaf33198ee788e4f5155c60 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 15 Feb 2024 13:43:43 -0500 Subject: [PATCH 16/27] fix: Update test_cmake to support Python 3.12 See https://learn.scientific-python.org/development/patterns/backports/ --- pyproject.toml | 2 +- tests/test_cmake.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6ae65adc7..a80f9148c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ Source = "ttps://github.com/scikit-build/cmake-python-distributions" [project.optional-dependencies] test = [ "coverage>=4.2", - "importlib_metadata>=2.0", + "importlib_metadata>=4.6; python_version<'3.10'", "pytest>=3.0.3", "pytest-cov>=2.4.0", ] diff --git a/tests/test_cmake.py b/tests/test_cmake.py index 3781e286c..142529fa6 100644 --- a/tests/test_cmake.py +++ b/tests/test_cmake.py @@ -1,11 +1,16 @@ # -*- coding: utf-8 -*- import os import subprocess +import sys import sysconfig import textwrap import pytest -from importlib_metadata import distribution + +if sys.version_info < (3, 10): + from importlib_metadata import distribution +else: + from importlib.metadata import distribution import cmake From 1ef08eee6736ff7060a09777a6cc5950f6fc75b2 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 18 Feb 2024 09:53:33 +0100 Subject: [PATCH 17/27] chore(CI): bump runners Use `ubuntu-latest` for ubuntu builds, `macos-14` for macOS build. --- .github/workflows/build.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cc4eae24..cb9001f16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ env: jobs: lint: name: Lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -44,43 +44,43 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "x86_64" build: "manylinux_" use_qemu: false - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "x86_64" build: "musllinux_" use_qemu: false - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "i686" build: "manylinux_" use_qemu: false - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "i686" build: "musllinux_" use_qemu: false - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "aarch64" build: "manylinux_" use_qemu: true - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "aarch64" build: "musllinux_" use_qemu: true - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "ppc64le" build: "manylinux_" use_qemu: true - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "ppc64le" build: "musllinux_" use_qemu: true - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "s390x" build: "manylinux_" use_qemu: true - - os: ubuntu-22.04 + - os: ubuntu-latest arch: "s390x" build: "musllinux_" use_qemu: true @@ -96,7 +96,7 @@ jobs: arch: "x86" build: "" use_qemu: false - - os: macos-11 + - os: macos-14 arch: "universal2" build: "" use_qemu: false @@ -127,7 +127,7 @@ jobs: build_manylinux2010_wheels: name: Build ${{ matrix.arch }} manylinux2010 wheels needs: [lint] - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -156,7 +156,7 @@ jobs: build_sdist: name: Build source distribution needs: [lint] - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -173,7 +173,7 @@ jobs: test_sdist: name: Test SDist with python ${{ matrix.python }} needs: [build_sdist] - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -211,7 +211,7 @@ jobs: check_dist: name: Check dist needs: [build_wheels, build_manylinux2010_wheels, build_sdist, test_sdist] - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 with: From dac29e687b306b47081a6b275a7ec97d744ec44d Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 18 Feb 2024 10:10:46 +0100 Subject: [PATCH 18/27] chore(ci): test with python 2.7 & 3.5 --- .github/workflows/build.yml | 47 +++++++++++++++++++++++++++++++++++-- pyproject.toml | 4 ++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb9001f16..4736acc68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,7 +121,7 @@ jobs: - uses: actions/upload-artifact@v4 if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) with: - name: Wheel-${{ matrix.os }}-${{ matrix.build }}${{ matrix.arch }} + name: Wheel-${{ runner.os }}-${{ matrix.build }}${{ matrix.arch }} path: ./wheelhouse/*.whl build_manylinux2010_wheels: @@ -153,6 +153,49 @@ jobs: name: Wheel-manylinux2010-${{ matrix.arch }} path: ./wheelhouse/*.whl + test_old_pythons: + name: Test wheel with python ${{ matrix.python }} + needs: [build_wheels] + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python: ["2.7", "3.5"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + if: matrix.python != '2.7' + name: Install Python ${{ matrix.python }} + with: + python-version: ${{ matrix.python }} + + - name: Install Python ${{ matrix.python }} + if: matrix.python == '2.7' + shell: bash + run: | + nuget install python2 -Version 2.7.18 -OutputDirectory '${{ runner.temp }}' + echo '${{ runner.temp }}\python2.2.7.18\tools' >> $GITHUB_PATH + + - name: Install dependencies + shell: bash + run: | + python -m pip install -U pip + python -m pip install pytest pytest-cov + + - uses: actions/download-artifact@v4 + with: + name: Wheel-Windows-AMD64 + path: wheelhouse + + - name: Install wheel + shell: bash + run: | + python -m pip -V + python -m pip install "$(find wheelhouse -name '*.whl')[test]" + + - name: Test installed SDist + run: python -m pytest ./tests + build_sdist: name: Build source distribution needs: [lint] @@ -210,7 +253,7 @@ jobs: check_dist: name: Check dist - needs: [build_wheels, build_manylinux2010_wheels, build_sdist, test_sdist] + needs: [build_wheels, build_manylinux2010_wheels, test_old_pythons, build_sdist, test_sdist] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 diff --git a/pyproject.toml b/pyproject.toml index a80f9148c..c74480474 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Typing :: Typed" ] dynamic = ["version"] -requires-python = ">=3.7" +# requires-python = ">=3.7" this is only required to build the wheel. We're still compatible with python 2.7 [project.urls] Homepage = "https://cmake.org" @@ -37,7 +37,7 @@ Source = "ttps://github.com/scikit-build/cmake-python-distributions" [project.optional-dependencies] test = [ "coverage>=4.2", - "importlib_metadata>=4.6; python_version<'3.10'", + "importlib_metadata>=2.0; python_version<'3.10'", "pytest>=3.0.3", "pytest-cov>=2.4.0", ] From 02d6827ac3e7bb95fde184e377e9fc77cccc243e Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 18 Feb 2024 11:45:56 +0100 Subject: [PATCH 19/27] fix: version template --- pyproject.toml | 1 + src/cmake/__init__.pyi | 2 +- src/cmake/_version.pyi | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c74480474..04d1a018c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,7 @@ wheel.install-dir = "cmake/data" [tool.setuptools_scm] write_to = "src/cmake/_version.py" +write_to_template = "version = '{version}'" [tool.cibuildwheel] build = "cp39-*" diff --git a/src/cmake/__init__.pyi b/src/cmake/__init__.pyi index 7bb53539f..ffa3ffe93 100644 --- a/src/cmake/__init__.pyi +++ b/src/cmake/__init__.pyi @@ -1,6 +1,6 @@ from typing import Iterator, NoReturn -__version__: tuple[int, int, int] | tuple[int, int, int, str, str] +__version__: str CMAKE_DATA: str diff --git a/src/cmake/_version.pyi b/src/cmake/_version.pyi index 91744f983..c2ee2cab4 100644 --- a/src/cmake/_version.pyi +++ b/src/cmake/_version.pyi @@ -1,4 +1 @@ -from __future__ import annotations - version: str -version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str] From 92431eb2168a5d9fed9a0a06808d710765bb57d6 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 18 Feb 2024 11:55:12 +0100 Subject: [PATCH 20/27] fix: tests with python 3.5 --- tests/test_cmake.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cmake.py b/tests/test_cmake.py index 142529fa6..865b21f32 100644 --- a/tests/test_cmake.py +++ b/tests/test_cmake.py @@ -61,7 +61,9 @@ def _get_scripts(): scripts = [] for file in dist.files: if os.path.abspath(str(file.locate().parent)) in scripts_paths: - scripts.append(file.locate().resolve(strict=True)) + script = file.locate().resolve() + assert script.exists() + scripts.append(script) return scripts From 9e9a28a46970dcc4213dbe020dccdbd46ebf4e37 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Mon, 19 Feb 2024 07:28:29 +0100 Subject: [PATCH 21/27] Update tests/test_cmake.py Co-authored-by: Jean-Christophe Fillion-Robin --- tests/test_cmake.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_cmake.py b/tests/test_cmake.py index 865b21f32..596d50aab 100644 --- a/tests/test_cmake.py +++ b/tests/test_cmake.py @@ -61,9 +61,11 @@ def _get_scripts(): scripts = [] for file in dist.files: if os.path.abspath(str(file.locate().parent)) in scripts_paths: - script = file.locate().resolve() - assert script.exists() - scripts.append(script) + if sys.version_info < (3, 6): + # pre-3.6 behavior is strict + scripts.append(file.locate().resolve()) + else: + scripts.append(file.locate().resolve(strict=True)) return scripts From 7ee8a27ede2e3155fa59c5ae47fb07dd8da06b52 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 19 Feb 2024 15:14:23 -0500 Subject: [PATCH 22/27] feat: Update scikit-build-core minimum version from 0.4 to 0.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 04d1a018c..3e34278ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ cpack = "cmake:cpack" ctest = "cmake:ctest" [tool.scikit-build] -minimum-version = "0.4" +minimum-version = "0.8" build-dir = "build/{wheel_tag}" metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" ninja.make-fallback = false From b054ef2ecedb958cb24df3a058719cbb273e1c9c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 19 Feb 2024 16:30:36 -0500 Subject: [PATCH 23/27] fix: Set DOWNLOAD_EXTRACT_TIMESTAMP to 1 if build with CMake >= 3.24 See https://cmake.org/cmake/help/latest/policy/CMP0135.html This will avoid warnings like the following: CMake Warning (dev) at /path/to/cmake-3.28.1-linux-x86_64/share/cmake-3.28/Modules/ExternalProject.cmake:3198 (message): The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is not set. The policy's OLD behavior will be used. When using a URL download, the timestamps of extracted files should preferably be that of the time of extraction, otherwise code that depends on the extracted contents might not be rebuilt if the URL changes. The OLD behavior preserves the timestamps from the archive instead, but this is usually not what you want. Update your project to the NEW behavior or specify the DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this robustness issue. Adapted from dff357a ("ExternalProjectDependency: Set DOWNLOAD_EXTRACT_TIMESTAMP to 1 if CMake >= 3.24", 2023-07-29) --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd4bff915..6c7b32a05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,12 @@ if(CMakePythonDistributions_SUPERBUILD) ) endif() + set(ep_download_extract_timestamp_arg) + if(CMAKE_VERSION VERSION_EQUAL "3.24" OR CMAKE_VERSION VERSION_GREATER "3.24") + # See https://cmake.org/cmake/help/latest/policy/CMP0135.html + set(ep_download_extract_timestamp_arg DOWNLOAD_EXTRACT_TIMESTAMP 1) + endif() + # # CMakeProject_SOURCE_DIR: Always expect the sources (needed for `sdist`) # @@ -145,6 +151,7 @@ if(CMakePythonDistributions_SUPERBUILD) BUILD_COMMAND "" BUILD_IN_SOURCE 1 INSTALL_COMMAND "" + ${ep_download_extract_timestamp_arg} ${ep_download_no_progress_args} ) message(STATUS "SuperBuild - CMakeProject-src-download") @@ -338,6 +345,7 @@ set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\ BUILD_COMMAND "" BUILD_IN_SOURCE 1 INSTALL_COMMAND "" + ${ep_download_extract_timestamp_arg} ${ep_download_no_progress_args} ) message(STATUS "SuperBuild - CMakeProject-binary-download") From 2d6f1dc4cdffa080d2730dc5b4629c99ab32f089 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 19 Feb 2024 16:33:23 -0500 Subject: [PATCH 24/27] fix: Ensure inner project is always re-configured Function `cpd_ExternalProject_AlwaysConfigure` copied from `ExternalProjectDependency.cmake` (commontk/Artichoke@613e3739a) --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c7b32a05..0c0673469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,20 @@ if(CMakePythonDistributions_SUPERBUILD) ) endfunction() + # Add an external project step named `forceconfigure` to `project_name` ensuring + # the project will always be reconfigured. + # + # Copied from ExternalProjectDependency.cmake (commontk/Artichoke@613e3739a) + function(cpd_ExternalProject_AlwaysConfigure proj) + _ep_get_step_stampfile(${proj} "configure" stampfile) + ExternalProject_Add_Step(${proj} forceconfigure + COMMAND ${CMAKE_COMMAND} -E remove ${stampfile} + COMMENT "Forcing configure step for '${proj}'" + DEPENDEES build + ALWAYS 1 + ) + endfunction() + # Note: To minimize confusion between variables defined by CMake and # variables used in this project. The following convention applies: # CMakeProject_xxx : Variables defined in this project @@ -376,6 +390,8 @@ set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\ ) message(STATUS "SuperBuild - ${PROJECT_NAME}") + cpd_ExternalProject_AlwaysConfigure(${PROJECT_NAME}) + # This adds an "install" target in the top-level directory. The # target will simply include the install rules associated with the # inner build From 0e0d94dcbc10d9b5d33748ae8e89a497fe9ba707 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 19 Feb 2024 17:46:45 -0500 Subject: [PATCH 25/27] fix: Support default "redirect" mode for editable install with Python >= 3.4 Add support for editable install using Python 3.4 (first version with built-in pathlib support) --- src/cmake/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/cmake/__init__.py b/src/cmake/__init__.py index 6b2aa4a06..2b1950862 100644 --- a/src/cmake/__init__.py +++ b/src/cmake/__init__.py @@ -3,6 +3,12 @@ import subprocess import sys +if sys.version_info >= (3, 4): + if sys.version_info < (3, 10): + from importlib_metadata import distribution + else: + from importlib.metadata import distribution + from ._version import version as __version__ __all__ = ["__version__", "CMAKE_DATA", "CMAKE_BIN_DIR", "CMAKE_DOC_DIR", "CMAKE_SHARE_DIR", "cmake", "cpack", "ctest"] @@ -12,9 +18,22 @@ def __dir__(): return __all__ -CMAKE_DATA = os.path.join(os.path.dirname(__file__), 'data') - - +if sys.version_info >= (3, 4): + cmake_executable_path = None + for script in distribution("cmake").files: + if str(script).startswith("cmake/data/bin/cmake"): + if sys.version_info < (3, 6): + # pre-3.6 behavior is strict + resolved_script = script.locate().resolve() + else: + resolved_script = script.locate().resolve(strict=True) + cmake_executable_path = resolved_script.parents[1] + break + CMAKE_DATA = cmake_executable_path if cmake_executable_path else None +else: + CMAKE_DATA = os.path.join(os.path.dirname(__file__), "data") + +assert CMAKE_DATA is not None assert os.path.exists(CMAKE_DATA) CMAKE_BIN_DIR = os.path.join(CMAKE_DATA, 'bin') From 5acd447910fca8d65cef0913805918a777bd5f2e Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sun, 25 Feb 2024 16:39:10 -0500 Subject: [PATCH 26/27] fix: Set CMAKE_DATA as a string to support Python 3.5 Fixes the following error: ``` tests\test_cmake.py:15: in import cmake C:\hostedtoolcache\windows\Python\3.5.4\x64\lib\site-packages\cmake\__init__.py:37: in assert os.path.exists(CMAKE_DATA) C:\hostedtoolcache\windows\Python\3.5.4\x64\lib\genericpath.py:19: in exists os.stat(path) E TypeError: argument should be string, bytes or integer, not WindowsPath ``` --- src/cmake/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmake/__init__.py b/src/cmake/__init__.py index 2b1950862..35bc96994 100644 --- a/src/cmake/__init__.py +++ b/src/cmake/__init__.py @@ -29,7 +29,7 @@ def __dir__(): resolved_script = script.locate().resolve(strict=True) cmake_executable_path = resolved_script.parents[1] break - CMAKE_DATA = cmake_executable_path if cmake_executable_path else None + CMAKE_DATA = str(cmake_executable_path) if cmake_executable_path else None else: CMAKE_DATA = os.path.join(os.path.dirname(__file__), "data") From dada88406daf38bb56e24afb161fc4ee8fae9082 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Mar 2024 14:32:00 -0500 Subject: [PATCH 27/27] Update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3e34278ee..d2e45baed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,7 @@ wheel.install-dir = "cmake/data" [tool.setuptools_scm] write_to = "src/cmake/_version.py" +# Setuptools-scm includes type annotations in the default template write_to_template = "version = '{version}'" [tool.cibuildwheel]