Skip to content

Commit

Permalink
Use sysconfig module instead of distutils.sysconfig for python >= 3.9 (
Browse files Browse the repository at this point in the history
  • Loading branch information
matusvalo authored Oct 30, 2023
1 parent fd96443 commit f697dec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
17 changes: 15 additions & 2 deletions Cython/Build/BuildExecutable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@

import sys
import os
from distutils import sysconfig
if sys.version_info < (3, 9):
from distutils import sysconfig as _sysconfig

class sysconfig(object):

@staticmethod
def get_path(name):
assert name == 'include'
return _sysconfig.get_python_inc()

get_config_var = staticmethod(_sysconfig.get_config_var)
else:
# sysconfig can be trusted from cpython >= 3.8.7
import sysconfig


def get_config_var(name, default=''):
return sysconfig.get_config_var(name) or default

INCDIR = sysconfig.get_python_inc()
INCDIR = sysconfig.get_path('include')
LIBDIR1 = get_config_var('LIBDIR')
LIBDIR2 = get_config_var('LIBPL')
PYLIB = get_config_var('LIBRARY')
Expand Down
16 changes: 14 additions & 2 deletions Cython/Parser/ConcreteSyntaxTree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ cdef extern from "parsetok.h":
perrdetail * err_ret,
int * flags)

import distutils.sysconfig
if sys.version_info < (3, 9):
from distutils import sysconfig as _sysconfig

class sysconfig(object):

@staticmethod
def get_path(name):
assert name == 'include'
return _sysconfig.get_python_inc()
else:
# sysconfig can be trusted from cpython >= 3.8.7
import sysconfig

import os
import re

Expand All @@ -47,7 +59,7 @@ cdef dict type_names = {}
cdef print_tree(node* n, indent=""):
if not type_names:
type_names.update(extract_names(
os.path.join(distutils.sysconfig.get_python_inc(), 'token.h')))
os.path.join(sysconfig.get_path('include'), 'token.h')))
type_names.update(extract_names(
os.path.join(os.path.dirname(__file__), 'graminit.h')))

Expand Down

0 comments on commit f697dec

Please sign in to comment.