Hi, many GNU/Linux distributions discourage to bundle other software like matplotlib does with PyCXX. It is understandable you may not want additionally support each new version of the bundled software. But you should give the distribution package maintainers an easy way to use the version available in the system should they wish to do so.
With the current build system this is not possible without rather large
modifications.
To allow maintainers to use the system files the bundled CXX must be moved from
the
matplotlib root to a subfolder, e.g. CXX -> external/CXX, so gcc will not
unintentionally use the bundled headers.
Attached patch makes use of this move and modifies setupext.py to search for
the PyCXX
sources in a list of possible folder pairs. The first folder where files are
found is chosen.
The found sources and include path have been added to all CXX uses I found.
To prefer the system installed version put the paths to the front of the lists
and
it will fall back to the bundled version if they are unavailable.
E.g. for debian:
_pycxx_src_paths = ["/usr/share/python{0}.{1}/".format(*sys.version_info[:2]),
"external/"]
_pycxx_h_paths = ["/usr/include/python{0}.{1}/".format(*sys.version_info[:2]),
"external/"]
Btw, I also saw you patched CXX for sparc
http://sourceforge.net/tracker/?func=detail&aid=3022815&group_id=80706&atid=560720
has this bug and patch been forwarded to pycxx?
It is not been applied to trunk yet, was it rejected?
PS: please CC me I'm not subscribed to the list.
Best Regards,
Julian Taylor
Index: setupext.py
===================================================================
--- setupext.py (revision 8988)
+++ setupext.py (working copy)
@@ -136,6 +136,21 @@
('PY_ARRAY_UNIQUE_SYMBOL', 'MPL_ARRAY_API'),
('PYCXX_ISO_CPP_LIB', '1')]
+# list of search paths for the CXX headers and sources
+# first folder where the files are found sets
+# pycxx_inc_path, pycxx_sources and pycxx_headers
+_pycxx_src_paths = ["external/"]
+_pycxx_h_paths = ["external/"]
+for s, h in zip(_pycxx_src_paths, _pycxx_h_paths):
+ if os.path.isdir(h) and os.path.isdir(s):
+ pycxx_sources = glob.glob(os.path.join(s, "CXX", "*.c"))
+ pycxx_sources.extend(glob.glob(os.path.join(s, "CXX", "*.cxx")))
+ pycxx_headers = glob.glob(os.path.join(h, "CXX", "*.h"))
+ pycxx_headers.extend(glob.glob(os.path.join(h, "CXX", "*.hxx")))
+ if len(pycxx_sources) > 0 and len(pycxx_headers) > 0:
+ pycxx_inc_path = h
+ break
+
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
# Based on the contents of setup.cfg, determine the build options
if os.path.exists(setup_cfg):
@@ -1038,11 +1053,10 @@
global BUILT_FT2FONT
if BUILT_FT2FONT: return # only build it if you you haven't already
deps = ['src/ft2font.cpp', 'src/mplutils.cpp']
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension('matplotlib.ft2font', deps,
- define_macros=defines)
+ define_macros=defines, include_dirs=[pycxx_inc_path])
add_ft2font_flags(module)
ext_modules.append(module)
BUILT_FT2FONT = True
@@ -1065,12 +1079,12 @@
global BUILT_GTKAGG
if BUILT_GTKAGG: return # only build it if you you haven't already
deps = ['src/agg_py_transforms.cpp', 'src/_gtkagg.cpp', 'src/mplutils.cpp']
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension('matplotlib.backends._gtkagg',
deps,
- define_macros=defines
+ define_macros=defines,
+ include_dirs=[pycxx_inc_path]
)
# add agg flags before pygtk because agg only supports freetype1
@@ -1088,12 +1102,12 @@
global BUILT_TKAGG
if BUILT_TKAGG: return # only build it if you you haven't already
deps = ['src/agg_py_transforms.cpp', 'src/_tkagg.cpp']
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension('matplotlib.backends._tkagg',
deps,
- define_macros=defines
+ define_macros=defines,
+ include_dirs=[pycxx_inc_path]
)
add_tk_flags(module) # do this first
@@ -1108,16 +1122,14 @@
global BUILT_MACOSX
if BUILT_MACOSX: return # only build it if you you haven't already
deps = ['src/_macosx.m',
- 'CXX/cxx_extensions.cxx',
- 'CXX/cxxextensions.c',
- 'CXX/cxxsupport.cxx',
- 'CXX/IndirectPythonInterface.cxx',
'src/agg_py_transforms.cpp',
'src/path_cleanup.cpp']
+ deps.extend(pycxx_sources)
module = Extension('matplotlib.backends._macosx',
deps,
extra_link_args = ['-framework','Cocoa'],
- define_macros=defines
+ define_macros=defines,
+ include_dirs=[pycxx_inc_path]
)
add_numpy_flags(module)
add_agg_flags(module)
@@ -1129,13 +1141,12 @@
if BUILT_PNG: return # only build it if you you haven't already
deps = ['src/_png.cpp', 'src/mplutils.cpp']
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension(
'matplotlib._png',
deps,
- include_dirs=numpy_inc_dirs,
+ include_dirs=numpy_inc_dirs + [pycxx_inc_path],
define_macros=defines
)
@@ -1160,14 +1171,13 @@
deps = ['%s/src/%s'%(AGG_VERSION, name) for name in agg]
deps.extend(['src/mplutils.cpp', 'src/agg_py_transforms.cpp'])
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
temp_copy('src/_backend_agg.cpp', 'src/backend_agg.cpp')
deps.append('src/backend_agg.cpp')
module = Extension(
'matplotlib.backends._backend_agg',
deps,
- include_dirs=numpy_inc_dirs,
+ include_dirs=numpy_inc_dirs + [pycxx_inc_path],
define_macros=defines
)
@@ -1190,8 +1200,7 @@
)
deps = ['%s/src/%s'%(AGG_VERSION, name) for name in agg]
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
temp_copy('src/_path.cpp', 'src/path.cpp')
deps.extend(['src/agg_py_transforms.cpp',
@@ -1200,7 +1209,7 @@
module = Extension(
'matplotlib._path',
deps,
- include_dirs=numpy_inc_dirs,
+ include_dirs=numpy_inc_dirs + [pycxx_inc_path],
define_macros=defines
)
@@ -1223,13 +1232,12 @@
temp_copy('src/_image.cpp', 'src/image.cpp')
deps = ['src/image.cpp', 'src/mplutils.cpp']
deps.extend(['%s/src/%s'%(AGG_VERSION,name) for name in agg])
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension(
'matplotlib._image',
deps,
- include_dirs=numpy_inc_dirs,
+ include_dirs=numpy_inc_dirs + [pycxx_inc_path],
define_macros=defines
)
@@ -1319,11 +1327,10 @@
if BUILT_TRI: return # only build it if you you haven't already
deps = ['lib/matplotlib/tri/_tri.cpp', 'src/mplutils.cpp']
- deps.extend(glob.glob('CXX/*.cxx'))
- deps.extend(glob.glob('CXX/*.c'))
+ deps.extend(pycxx_sources)
module = Extension('matplotlib._tri', deps,
- define_macros=defines)
+ define_macros=defines, include_dirs=[pycxx_inc_path])
add_numpy_flags(module)
add_base_flags(module)
ext_modules.append(module)
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
