mirror of
https://github.com/python/cpython.git
synced 2025-11-15 16:09:29 +00:00
Configure Modules/_ctypes/libffi just before building the _ctypes extension.
This avoids configuring it when it is not build by setup.py.
This commit is contained in:
parent
6e3a66de91
commit
eba43c157b
1 changed files with 13 additions and 2 deletions
15
setup.py
15
setup.py
|
|
@ -180,6 +180,9 @@ class PyBuildExt(build_ext):
|
||||||
|
|
||||||
def build_extension(self, ext):
|
def build_extension(self, ext):
|
||||||
|
|
||||||
|
if ext.name == '_ctypes':
|
||||||
|
self.configure_ctypes(ext)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
build_ext.build_extension(self, ext)
|
build_ext.build_extension(self, ext)
|
||||||
except (CCompilerError, DistutilsError), why:
|
except (CCompilerError, DistutilsError), why:
|
||||||
|
|
@ -1264,7 +1267,7 @@ class PyBuildExt(build_ext):
|
||||||
# *** Uncomment these for TOGL extension only:
|
# *** Uncomment these for TOGL extension only:
|
||||||
# -lGL -lGLU -lXext -lXmu \
|
# -lGL -lGLU -lXext -lXmu \
|
||||||
|
|
||||||
def detect_ctypes(self):
|
def configure_ctypes(self, ext):
|
||||||
(srcdir,) = sysconfig.get_config_vars('srcdir')
|
(srcdir,) = sysconfig.get_config_vars('srcdir')
|
||||||
ffi_builddir = os.path.join(self.build_temp, 'libffi')
|
ffi_builddir = os.path.join(self.build_temp, 'libffi')
|
||||||
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
|
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
|
||||||
|
|
@ -1296,12 +1299,20 @@ class PyBuildExt(build_ext):
|
||||||
include_dirs = [os.path.join(ffi_builddir, 'include'),
|
include_dirs = [os.path.join(ffi_builddir, 'include'),
|
||||||
ffi_builddir, ffi_srcdir]
|
ffi_builddir, ffi_srcdir]
|
||||||
extra_compile_args = fficonfig['ffi_cflags'].split()
|
extra_compile_args = fficonfig['ffi_cflags'].split()
|
||||||
|
|
||||||
|
ext.sources.extend(fficonfig['ffi_sources'])
|
||||||
|
ext.include_dirs.extend(include_dirs)
|
||||||
|
ext.extra_compile_args.extend(extra_compile_args)
|
||||||
|
|
||||||
|
def detect_ctypes(self):
|
||||||
|
include_dirs = []
|
||||||
|
extra_compile_args = []
|
||||||
sources = ['_ctypes/_ctypes.c',
|
sources = ['_ctypes/_ctypes.c',
|
||||||
'_ctypes/callbacks.c',
|
'_ctypes/callbacks.c',
|
||||||
'_ctypes/callproc.c',
|
'_ctypes/callproc.c',
|
||||||
'_ctypes/stgdict.c',
|
'_ctypes/stgdict.c',
|
||||||
'_ctypes/cfield.c',
|
'_ctypes/cfield.c',
|
||||||
'_ctypes/malloc_closure.c'] + fficonfig['ffi_sources']
|
'_ctypes/malloc_closure.c']
|
||||||
depends = ['_ctypes/ctypes.h']
|
depends = ['_ctypes/ctypes.h']
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue