Skip to content

Commit

Permalink
Added namespace support for toolkits.
Browse files Browse the repository at this point in the history
Added some python2.2 compatibility changes.  Some issues still exist.

svn path=/trunk/matplotlib/; revision=1973
  • Loading branch information
cmoad committed Jan 20, 2006
1 parent 1f07302 commit 0f3dc16
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/mpl_with_glade.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def buttonpress(widget, event):
def onselect(xmin, xmax):
print xmin, xmax

#span = HorizontalSpanSelector(self.axis, onselect, useblit=False,
# rectprops=dict(alpha=0.5, facecolor='red') )
span = HorizontalSpanSelector(self.axis, onselect, useblit=False,
rectprops=dict(alpha=0.5, facecolor='red') )


self['vboxMain'].pack_start(self.canvas, True, True)
Expand Down
20 changes: 17 additions & 3 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@
import sys, os, warnings, shutil, md5
import distutils.sysconfig

# Needed for toolkit setuptools support
try:
__import__('pkg_resources').declare_namespace(__name__)
print __name__, __file__
except ImportError:
pass # must not have setuptools


if not hasattr(sys, 'argv'): # for modpython
sys.argv = ['modpython']

Expand Down Expand Up @@ -181,10 +189,16 @@
except ImportError: _havedate = False
else: _havedate = True

#try:
# import pkg_resources # pkg_resources is part of setuptools
#except ImportError: _have_pkg_resources = False
#else: _have_pkg_resources = True

try:
import pkg_resources # pkg_resources is part of setuptools
except ImportError: _have_pkg_resources = False
else: _have_pkg_resources = True
__import__('pkg_resources').declare_namespace(__name__)
print __name__, __file__
except ImportError:
pass # must not have setuptools

if not _python23:
def enumerate(seq):
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/toolkits/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
try:
__import__('pkg_resources').declare_namespace(__name__)
print __name__, __file__
except ImportError:
pass # must not have setuptools
27 changes: 15 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""


rc = dict(backend='PS', numerix='Numeric')
rc = dict({'backend':'PS', 'numerix':'Numeric'})

# build the image support module - requires agg and Numeric or
# numarray. You can build the image module with either Numeric or
Expand Down Expand Up @@ -60,13 +60,11 @@
try:
# check if we have a reasonably recent copy of setuptools
from setuptools.command import bdist_egg
from setuptools import setup
has_setuptools = True
except ImportError:
from distutils.core import setup
has_setuptools = False

if has_setuptools:
from setuptools import setup

import sys,os
import glob
Expand Down Expand Up @@ -157,13 +155,14 @@
# jdh
packages = [
'matplotlib',
'matplotlib/backends',
'matplotlib/numerix',
'matplotlib/numerix/mlab',
'matplotlib/numerix/ma',
'matplotlib/numerix/linear_algebra',
'matplotlib/numerix/random_array',
'matplotlib/numerix/fft',
'matplotlib.backends',
'matplotlib.toolkits',
'matplotlib.numerix',
'matplotlib.numerix.mlab',
'matplotlib.numerix.ma',
'matplotlib.numerix.linear_algebra',
'matplotlib.numerix.random_array',
'matplotlib.numerix.fft',
]


Expand Down Expand Up @@ -283,7 +282,9 @@ def add_dateutil():
template = file('matplotlibrc.template').read()
file('matplotlibrc', 'w').write(template%rc)


additional_params = {}
if has_setuptools:
additional_params['namespace_packages'] = ['matplotlib.toolkits']

distrib = setup(name="matplotlib",
version= __version__,
Expand All @@ -303,4 +304,6 @@ def add_dateutil():
ext_modules = ext_modules,
data_files = data_files,
package_dir = {'': 'lib'},
**additional_params
)

12 changes: 12 additions & 0 deletions src/cntr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,11 @@ static PyMethodDef module_methods[] = {


#ifdef NUMARRAY
#if PY_MINOR_VERSION > 2
PyMODINIT_FUNC
#else
DL_EXPORT(void)
#endif
init_na_cntr(void)
{
PyObject* m;
Expand All @@ -1721,7 +1725,11 @@ init_na_cntr(void)
}
#endif
#ifdef NUMERIC
#if PY_MINOR_VERSION > 2
PyMODINIT_FUNC
#else
DL_EXPORT(void)
#endif
init_nc_cntr(void)
{
PyObject* m;
Expand All @@ -1742,7 +1750,11 @@ init_nc_cntr(void)
#endif

#ifdef SCIPY
#if PY_MINOR_VERSION > 2
PyMODINIT_FUNC
#else
DL_EXPORT(void)
#endif
init_ns_cntr(void)
{
PyObject* m;
Expand Down

0 comments on commit 0f3dc16

Please sign in to comment.