I'm trying to understand the dependency structure of pandas' cython extensions in setup.py.
distutils.extension.Extension
has arguments sources
, depends
, and include_dirs
, and I can't figure out the difference between these. In particular, there are a bunch of places in the pandas case where I can delete entries in depends
(or pxdfiles
) without breaking the build.
What is the distinction between these three arguments?
Update following answer from @phd: I appreciate the thought, will try to better communicate the source of my confusion.
In the pandas setup.py file linked above, the pandas._libs.tslib
extension is passed to distutils.extension.Extension
with the args/kwargs:
ext = Extension('pandas._libs.tslib',
sources=['pandas/_libs/tslib.pyx',
'pandas/_libs/src/util.pxd',
'pandas/_libs/src/datetime/np_datetime.c',
'pandas/_libs/src/datetime/np_datetime_strings.c',
'pandas/_libs/src/period_helper.c'],
depends=['pandas/_libs/src/datetime/np_datetime.h',
'pandas/_libs/src/datetime/np_datetime_strings.h',
'pandas/_libs/src/period_helper.h',
'pandas/_libs/src/datetime.pxd'],
include_dirs=['pandas/_libs/src/klib', 'pandas/_libs/src'])
Take e.g. util.pxd
in the sources
entry. Is this not redundant with the presence of pandas/_libs/src
in the include_dirs
entry? tslib
imports directly from datetime.pxd
which has "imports" of the form cdef extern from "datetime/np_datetime.h"
and cdef extern from "datetime/np_datetime_strings.h"
. Are those "allowed" because of the presence of the "*.c" files in the sources
or the "*.h" files in the depends
or both or...
I've tried a whole bunch of permutations of removing subsets of these dependencies, have not seen many patterns in terms of which break the build.
See the detailed docs and the source code for
build_ext
command.sources
is a list of source files (*.c
) to compile the extension.depends
— a list of additional files the extensions is required to compile.include_dirs
— a list of directories where a compiler will look for include (header) files (*.h
).pxdfiles
are Cython-specific.