Skip to content

Commit

Permalink
[Draft] Remove distutils
Browse files Browse the repository at this point in the history
Distutils is gone in Python 3.12+.
  • Loading branch information
ax3l committed Aug 28, 2023
1 parent b8e39ab commit fb438bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,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
```

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.version import LooseVersion
import os
import platform
import re
Expand Down Expand Up @@ -54,6 +53,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:
Expand All @@ -63,10 +64,10 @@ def run(self):
+ ", ".join(e.name for e in self.extensions)
)

cmake_version = LooseVersion(
cmake_version = parse(
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
)
if cmake_version < "3.20.0":
if cmake_version < parse("3.20.0"):
raise RuntimeError("CMake >= 3.20.0 is required")

for ext in self.extensions:
Expand Down

0 comments on commit fb438bf

Please sign in to comment.