Skip to content

Commit

Permalink
feat: Stop using distutils (removed in Python 3.12)
Browse files Browse the repository at this point in the history
distutils is being removed from the Python standard library. A copy
exists in setuptools. Use that.

Closes #573
  • Loading branch information
riddell-stan authored and ahartikainen committed Oct 3, 2022
1 parent 511f71f commit 6bf3736
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.py
@@ -1,4 +1,4 @@
from distutils.extension import Extension
from setuptools.extension import Extension

# empty extension module so build machinery recognizes package as platform-specific
extensions = [
Expand Down
14 changes: 7 additions & 7 deletions httpstan/build_ext.py
Expand Up @@ -7,8 +7,8 @@
# background: https://bugs.python.org/issue23102
import setuptools # noqa: F401

import distutils.command.build_ext
import distutils.core
import setuptools._distutils.command.build_ext as build_ext
import setuptools._distutils.core
import io
import os
import sys
Expand All @@ -18,18 +18,18 @@
from httpstan.config import HTTPSTAN_DEBUG


def _get_build_extension() -> distutils.command.build_ext.build_ext: # type: ignore
def _get_build_extension() -> build_ext.build_ext: # type: ignore
if HTTPSTAN_DEBUG: # pragma: no cover
distutils.log.set_verbosity(distutils.log.DEBUG) # type: ignore
dist = distutils.core.Distribution()
setuptools._distutils.log.set_verbosity(setuptools._distutils.log.DEBUG) # type: ignore
dist = setuptools._distutils.core.Distribution()
# Make sure build respects distutils configuration
dist.parse_config_files(dist.find_config_files()) # type: ignore
build_extension = distutils.command.build_ext.build_ext(dist) # type: ignore
build_extension = build_ext.build_ext(dist) # type: ignore
build_extension.finalize_options()
return build_extension


def run_build_ext(extensions: List[distutils.core.Extension], build_lib: str) -> str:
def run_build_ext(extensions: List[setuptools._distutils.core.Extension], build_lib: str) -> str:
"""Configure and call `build_ext.run()`, capturing stderr.
Compiled extension module will be placed in `build_lib`.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -31,7 +31,7 @@ include = [

[tool.poetry.dependencies]
python = "^3.8"
setuptools = ">=41.0"
setuptools = ">=48.0"
aiohttp = "^3.7"
appdirs = "^1.4"
webargs = "^8.0"
Expand Down

0 comments on commit 6bf3736

Please sign in to comment.