Issues with dateutil and pytz #983

merged 1 commit into from Aug 22, 2012


None yet
4 participants

mdboom commented Aug 22, 2012

  1. pytz is outdated. The latest version is 2012c
  2. pytz 2012c is compatible with Python 3 and should not be converted with the 2to3 tool.
  3. dateutil 1.5 is for Python 2.x only. Dateutil 2.1 is for Python 3.x only. See
  4. dateutil 2.1 should should not be converted with the 2to3 tool.

How about the following fix (works for me on win-amd64-py3.2)?

  1. update pytz to version 2012c
  2. include dateutil 2.1 under lib/dateutil2
  3. add lib/
  4. fix to use lib/dateutil2 instead of lib/dateutil on Python 3 and exclude pytz, dateutil2, and from 2to3.
diff --git a/ b/
index 6c59b4c..2fc64ff 100644
--- a/
+++ b/
@@ -106,6 +106,7 @@ package_data = {'matplotlib':['mpl-data/fonts/afm/*.afm',
+package_dir = {'': 'lib'}

 if 0:
     # TODO: exclude these when making release?
@@ -214,6 +215,8 @@ if hasdatetime: # dates require python23 datetime
         package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']
+        if sys.version_info[0] >= 3:
+            py_modules.append('six')
+            package_dir['dateutil'] = 'lib/dateutil2'

     if sys.platform=='win32':
         # always add these to the win32 installer
@@ -275,7 +278,9 @@ if sys.version_info[0] >= 3:
         def run_2to3(self, files):
             # We need to skip certain files that have already been
             # converted to Python 3.x
-            filtered = [x for x in files if 'py3' not in x]
+            filtered = [x for x in files if ('py3' not in x and
+                                             'dateutil' not in x and
+                                             'pytz' not in x and
+                                             '' not in x)]
             if sys.platform.startswith('win'):
                 # doing this in parallel on windows may crash your computer
                 [refactor(f) for f in filtered]
@@ -305,7 +310,7 @@ distrib = setup(name="matplotlib",
       py_modules = py_modules,
       ext_modules = ext_modules,
-      package_dir = {'': 'lib'},
+      package_dir = package_dir,
       package_data = package_data,
       cmdclass = {'build_py': build_py},

cgohlke commented Jul 29, 2012

Dateutil 2.1 depends on the module six.


pelson commented Aug 19, 2012

@cgohlke: What are the impacts of us not doing this for 1.2.x?


mdboom commented Aug 19, 2012

I would like to get this in for 1.2. It doesn't have to be by the freeze tomorrow, as it isn't really a "new feature" as much as updating these libraries -- and the potential breakage that entails.


cgohlke commented Aug 19, 2012

@pelson: We will have to exclude pytz and dateutil from the binary installers for Python 3 (Windows and Mac) and tell users to install them (and separately. That might be better anyway. It has always been problematic to include (outdated) pytz and dateutil packages that potentially overwrite existing packages in site-packages.


mdboom commented Aug 22, 2012

@cgohlke: Yes -- I would like to move away from including dependencies as much as possible in the future as well. But I think for this release we should continue to do so to avoid surprises, and then perhaps for the next release remove most of these things from our own distribution. pip and friends work much better now than they did when all this was originally put in place.

@mdboom mdboom Update pytz to 2012d and update dateutil to 1.5 for Python 2.x and 2.…
…1 for Python 3.x

Update so that it assume datetime is always there (as it should be on the versions of Python we support).

Update to not 2to3 pytz.

Update to install the correct version of dateutil that matches the version of Python.

mdboom commented Aug 22, 2012

I have attached a PR to make these updates and fix the 2to3 issues. Let me know how this works, and I am particularly curious to see how this addresses #745.

@mdboom mdboom added a commit that referenced this pull request Aug 22, 2012

@mdboom mdboom Merge pull request #983 from mdboom/update_pytz_and_dateutil
Issues with dateutil and pytz

@mdboom mdboom merged commit 354721b into matplotlib:master Aug 22, 2012

mdboom deleted the mdboom:update_pytz_and_dateutil branch Mar 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment