Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93733c2

Browse files
committed
move configobj.py to lib/, install in site-packages only if required
svn path=/trunk/matplotlib/; revision=4155
1 parent f1f49f4 commit 93733c2

5 files changed

Lines changed: 71 additions & 20 deletions

File tree

examples/rc_traits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# below.
88

99
import sys, os, re
10-
import matplotlib.enthought.traits as traits
10+
import matplotlib.enthought.traits.api as traits
1111
from matplotlib.cbook import is_string_like
1212
from matplotlib.artist import Artist
1313

lib/matplotlib/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@
5555
"""
5656
from __future__ import generators
5757

58-
NEWCONFIG = False
59-
6058
__version__ = '0.90.1'
6159
__revision__ = '$Revision$'
6260
__date__ = '$Date$'
6361

6462
import md5, os, re, shutil, sys, warnings
6563
import distutils.sysconfig
6664

65+
66+
NEWCONFIG = True
67+
# TODO: remove this when we stop shipping
68+
# enthought.traits as an internal package:
69+
#sys.path.append(os.path.split(__file__)[0])
70+
71+
6772
# Needed for toolkit setuptools support
6873
if 0:
6974
try:

setup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@
7878
from distutils.core import setup
7979
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
8080
build_ft2font, build_image, build_windowing, build_transforms, \
81-
build_contour, build_nxutils, build_enthought, build_swigagg, build_gdk, \
81+
build_contour, build_nxutils, build_traits, build_swigagg, build_gdk, \
8282
build_subprocess, build_ttconv, print_line, print_status, print_message, \
8383
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, check_for_tk, \
84-
check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, check_for_cairo
84+
check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, check_for_cairo, \
85+
check_for_traits
8586
#import distutils.sysconfig
8687

8788
# jdh
@@ -99,6 +100,8 @@
99100
'matplotlib.config'
100101
]
101102

103+
py_modules = ['pylab']
104+
102105
ext_modules = []
103106

104107
# these are not optional
@@ -218,7 +221,12 @@ def add_dateutil():
218221

219222
build_swigagg(ext_modules, packages)
220223
build_transforms(ext_modules, packages)
221-
build_enthought(ext_modules, packages)
224+
225+
# for the traited config package:
226+
try: import configobj
227+
except ImportError: py_modules.append('configobj')
228+
229+
if not check_for_traits(): build_traits(ext_modules, packages)
222230

223231
if check_for_gtk() and (BUILD_GTK or BUILD_GTKAGG):
224232
if BUILD_GTK:
@@ -295,7 +303,7 @@ def add_dateutil():
295303
""",
296304
packages = packages,
297305
platforms='any',
298-
py_modules = ['pylab'],
306+
py_modules = py_modules,
299307
ext_modules = ext_modules,
300308
package_dir = {'': 'lib'},
301309
package_data = package_data,

setupext.py

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
BUILT_WINDOWING = False
8888
BUILT_CONTOUR = False
8989
BUILT_NXUTILS = False
90-
BUILT_ENTHOUGHT = False
90+
BUILT_TRAITS = False
9191
BUILT_CONTOUR = False
9292
BUILT_GDK = False
9393

@@ -324,6 +324,23 @@ def check_for_cairo():
324324
else:
325325
print_status("Cairo", cairo.version)
326326

327+
def check_for_traits():
328+
gotit = False
329+
try:
330+
from enthought import traits
331+
gotit = True
332+
try:
333+
from enthought.traits import version
334+
except:
335+
print_status("enthought.traits", "unknown and incompatible version: < 2.0")
336+
return gotit
337+
else:
338+
if version.version.endswith('mpl'): gotit = False
339+
print_status("enthought.traits", version.version)
340+
except ImportError:
341+
print_status("enthought.traits", "no")
342+
return gotit
343+
327344
def check_for_numpy():
328345
gotit = False
329346
try:
@@ -965,20 +982,41 @@ def build_transforms(ext_modules, packages):
965982
add_base_flags(module)
966983
ext_modules.append(module)
967984

968-
def build_enthought(ext_modules, packages):
969-
global BUILT_ENTHOUGHT
970-
if BUILT_ENTHOUGHT: return # only build it if you you haven't already
971-
972-
ctraits = Extension('matplotlib.enthought.traits.ctraits', ['lib/matplotlib/enthought/traits/ctraits.c'])
985+
#def build_enthought(ext_modules, packages):
986+
# global BUILT_ENTHOUGHT
987+
# if BUILT_ENTHOUGHT: return # only build it if you you haven't already
988+
#
989+
# ctraits = Extension('matplotlib.enthought.traits.ctraits', ['lib/matplotlib/enthought/traits/ctraits.c'])
990+
# ext_modules.append(ctraits)
991+
# packages.extend(['matplotlib/enthought',
992+
# 'matplotlib/enthought/traits',
993+
# 'matplotlib/enthought/traits/ui',
994+
# 'matplotlib/enthought/traits/ui/null',
995+
# 'matplotlib/enthought/resource',
996+
# 'matplotlib/enthought/util',
997+
# ])
998+
# BUILT_ENTHOUGHT = True
999+
1000+
def build_traits(ext_modules, packages):
1001+
global BUILT_TRAITS
1002+
if BUILT_TRAITS:
1003+
return # only build it if you you haven't already
1004+
1005+
ctraits = Extension('enthought.traits.ctraits',
1006+
['lib/enthought/traits/ctraits.c'])
9731007
ext_modules.append(ctraits)
974-
packages.extend(['matplotlib/enthought',
975-
'matplotlib/enthought/traits',
976-
'matplotlib/enthought/traits/ui',
977-
'matplotlib/enthought/traits/ui/null',
978-
'matplotlib/enthought/resource',
979-
'matplotlib/enthought/util',
1008+
packages.extend(['enthought',
1009+
'enthought/etsconfig',
1010+
'enthought/traits',
1011+
# 'enthought/traits/plugins',
1012+
'enthought/traits/ui',
1013+
'enthought/traits/ui/extras',
1014+
'enthought/traits/ui/null',
1015+
# 'enthought/traits/ui/tests',
1016+
'enthought/traits/ui/tk',
9801017
])
981-
BUILT_ENTHOUGHT = True
1018+
BUILT_TRAITS = True
1019+
9821020

9831021
def build_contour(ext_modules, packages):
9841022
global BUILT_CONTOUR

0 commit comments

Comments
 (0)