diff --git a/README.md b/README.md index c2b6e89b..c4945f83 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ Now, `cmake --version` should be at version 3.20.0 or newer. Or go: ```bash -# optional: --user -python3 -m pip install -U pip setuptools wheel +python3 -m pip install -U pip +python3 -m pip install -U build packaging setuptools wheel python3 -m pip install -U cmake ``` diff --git a/pyproject.toml b/pyproject.toml index d7096f82..f53522b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ requires = [ "setuptools>=42", "wheel", - "cmake>=3.20.0,<4.0.0" + "cmake>=3.20.0,<4.0.0", + "packaging>=23", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 964c83a5..b41451ed 100644 --- a/setup.py +++ b/setup.py @@ -5,9 +5,6 @@ # Authors: Axel Huebl # License: BSD-3-Clause-LBNL # -from distutils.command.build import build -from distutils.command.clean import clean -from distutils.version import LooseVersion import os import platform import re @@ -16,6 +13,7 @@ import sys from setuptools import Extension, setup +from setuptools.command.build import build from setuptools.command.build_ext import build_ext @@ -33,10 +31,8 @@ def run(self): # by default, this stays around. We want to make sure generated # files like amrex_*d_pybind.*.(so|pyd) are always only the # ones we want to package and not ones from an earlier wheel's stage - c = clean(self.distribution) - c.all = True - c.finalize_options() - c.run() + if os.path.exists(self.build_base): + shutil.rmtree(self.build_base) # call superclass build.run(self) @@ -54,6 +50,8 @@ def __init__(self, name, sourcedir=""): class CMakeBuild(build_ext): def run(self): + from packaging.version import parse + try: out = subprocess.check_output(["cmake", "--version"]) except OSError: @@ -63,10 +61,8 @@ def run(self): + ", ".join(e.name for e in self.extensions) ) - cmake_version = LooseVersion( - re.search(r"version\s*([\d.]+)", out.decode()).group(1) - ) - if cmake_version < "3.20.0": + cmake_version = parse(re.search(r"version\s*([\d.]+)", out.decode()).group(1)) + if cmake_version < parse("3.20.0"): raise RuntimeError("CMake >= 3.20.0 is required") for ext in self.extensions: