From 40efd8013a28ff0b20806f1b6f8a70ef919a5c48 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 10 Dec 2024 03:00:39 +0530 Subject: [PATCH] Drop dependence on `wheel` at build time (#4652) Co-authored-by: Eric G. Kratz --- .github/workflows/publish_pypi.yml | 4 ++-- pyproject.toml | 8 +------- scripts/Dockerfile | 2 +- setup.py | 14 +++++++------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 90401a5277..a55510f42f 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -77,7 +77,7 @@ jobs: CMAKE_GENERATOR_PLATFORM=x64 CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.get_num_cores.outputs.count }} CIBW_ARCHS: AMD64 - CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake + CIBW_BEFORE_BUILD: python -m pip install setuptools delvewheel # skip CasADi and CMake # Fix access violation because GHA runners have modified PATH that picks wrong # msvcp140.dll, see https://github.com/adang1345/delvewheel/issues/54 CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel} @@ -243,7 +243,7 @@ jobs: # 10.13 for Intel (macos-13), 11.0 for Apple Silicon (macos-14 and macos-latest) MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '11.0' || '10.13' }} CIBW_ARCHS_MACOS: auto - CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel delocate + CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools delocate CIBW_REPAIR_WHEEL_COMMAND: | if [[ $(uname -m) == "x86_64" ]]; then delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} diff --git a/pyproject.toml b/pyproject.toml index 7eb35293e3..923f72438d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] requires = [ - "setuptools>=64", - "wheel", + "setuptools>=70.1.1", # On Windows, use the CasADi vcpkg registry and CMake bundled from MSVC "casadi>=3.6.7; platform_system!='Windows'", # Note: the version of CasADi as a build-time dependency should be matched @@ -271,11 +270,6 @@ log_date_format = "%Y-%m-%d %H:%M:%S" source = ["src/pybamm"] concurrency = ["multiprocessing"] -[tool.repo-review] -ignore = [ - "PP003" # list wheel as a build-dep -] - [tool.mypy] ignore_missing_imports = true allow_redefinition = true diff --git a/scripts/Dockerfile b/scripts/Dockerfile index e6fac122ff..a742a51caf 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -28,7 +28,7 @@ RUN uv venv $VIRTUAL_ENV RUN #!/bin/bash && source /home/pybamm/venv/bin/activate; ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN uv pip install --upgrade setuptools wheel wget cmake +RUN uv pip install --upgrade setuptools wget cmake RUN python scripts/install_KLU_Sundials.py && \ rm -rf pybind11 && \ diff --git a/setup.py b/setup.py index 8a49bfd715..35f9487aca 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,11 @@ from multiprocessing import cpu_count from pathlib import Path from platform import system -import wheel.bdist_wheel as orig from setuptools import setup, Extension from setuptools.command.install import install from setuptools.command.build_ext import build_ext +from setuptools.command.bdist_wheel import bdist_wheel default_lib_dir = ( @@ -230,29 +230,29 @@ def run(self): # ---------- Custom class for building wheels ------------------------------------------ -class bdist_wheel(orig.bdist_wheel): +class PyBaMMWheel(bdist_wheel): """A custom install command to add 2 build options""" user_options = [ - *orig.bdist_wheel.user_options, + *bdist_wheel.user_options, ("suitesparse-root=", None, "suitesparse source location"), ("sundials-root=", None, "sundials source location"), ] def initialize_options(self): - orig.bdist_wheel.initialize_options(self) + bdist_wheel.initialize_options(self) self.suitesparse_root = None self.sundials_root = None def finalize_options(self): - orig.bdist_wheel.finalize_options(self) + bdist_wheel.finalize_options(self) if not self.suitesparse_root: self.suitesparse_root = default_lib_dir if not self.sundials_root: self.sundials_root = default_lib_dir def run(self): - orig.bdist_wheel.run(self) + bdist_wheel.run(self) def compile_KLU(): @@ -342,7 +342,7 @@ def compile_KLU(): ext_modules=ext_modules, cmdclass={ "build_ext": CMakeBuild, - "bdist_wheel": bdist_wheel, + "bdist_wheel": PyBaMMWheel, "install": CustomInstall, }, )