Skip to content

Commit dbdc6be

Browse files
committed
Install six as a proper top-level package. Fix some other minor and related issues related to installing dateutil and pytz on Python 3.
1 parent 0ee82be commit dbdc6be

File tree

7 files changed

+55
-11
lines changed

7 files changed

+55
-11
lines changed

lib/dateutil_py2/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"""
77
__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"
88
__license__ = "PSF License"
9-
__version__ = "1.5"
9+
__version__ = "1.5-mpl"

lib/dateutil_py3/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"""
88
__author__ = "Tomi Pieviläinen <tomi.pievilainen@iki.fi>"
99
__license__ = "Simplified BSD"
10-
__version__ = "2.1"
10+
__version__ = "2.1-mpl"

lib/pytz/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
VERSION = OLSON_VERSION
1414
# Version format for a patch release - only one so far.
1515
#VERSION = OLSON_VERSION + '.2'
16-
__version__ = OLSON_VERSION
16+
__version__ = OLSON_VERSION + "-mpl"
1717

1818
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
1919

@@ -115,7 +115,7 @@ def resource_exists(name):
115115
# module, as well as the Zope3 i18n package. Perhaps we should just provide
116116
# the POT file and translations, and leave it up to callers to make use
117117
# of them.
118-
#
118+
#
119119
# t = gettext.translation(
120120
# 'pytz', os.path.join(os.path.dirname(__file__), 'locales'),
121121
# fallback=True
@@ -128,7 +128,7 @@ def resource_exists(name):
128128
_tzinfo_cache = {}
129129

130130
def timezone(zone):
131-
r''' Return a datetime.tzinfo implementation for the given timezone
131+
r''' Return a datetime.tzinfo implementation for the given timezone
132132
133133
>>> from datetime import datetime, timedelta
134134
>>> utc = timezone('UTC')
@@ -252,7 +252,7 @@ def __str__(self):
252252
def _UTC():
253253
"""Factory function for utc unpickling.
254254
255-
Makes sure that unpickling a utc instance always returns the same
255+
Makes sure that unpickling a utc instance always returns the same
256256
module global.
257257
258258
These examples belong in the UTC class above, but it is obscured; or in
@@ -1098,7 +1098,7 @@ def _test():
10981098
'Zulu']
10991099
all_timezones = [
11001100
tz for tz in all_timezones if resource_exists(tz)]
1101-
1101+
11021102
all_timezones_set = set(all_timezones)
11031103
common_timezones = \
11041104
['Africa/Abidjan',
@@ -1533,5 +1533,5 @@ def _test():
15331533
'UTC']
15341534
common_timezones = [
15351535
tz for tz in common_timezones if tz in all_timezones]
1536-
1536+
15371537
common_timezones_set = set(common_timezones)

lib/dateutil_py3/six.py renamed to lib/six.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import types
66

77
__author__ = "Benjamin Peterson <benjamin@python.org>"
8-
__version__ = "1.1.0"
8+
__version__ = "1.1.0-mpl"
99

1010

1111
# True if we are running on Python 3.

setup.cfg.template

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
## Date/timezone support:
2929
#pytz = False
3030
#dateutil = False
31+
#six = False
3132

3233
[gui_support]
3334
# Matplotlib supports multiple GUI toolkits, including Cocoa,

setup.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
check_for_qt, check_for_qt4, check_for_pyside, check_for_cairo, \
4949
check_provide_pytz, check_provide_dateutil,\
5050
check_for_dvipng, check_for_ghostscript, check_for_latex, \
51-
check_for_pdftops, options, build_png, build_tri
51+
check_for_pdftops, options, build_png, build_tri, check_provide_six
5252

5353
# jdh
5454
packages = [
@@ -190,6 +190,7 @@ def chop_package(fname):
190190

191191
provide_dateutil = check_provide_dateutil()
192192
provide_pytz = check_provide_pytz()
193+
provide_six = check_provide_six()
193194

194195
def add_pytz():
195196
packages.append('pytz')
@@ -217,17 +218,23 @@ def add_dateutil():
217218
else:
218219
package_dir['dateutil'] = 'lib/dateutil_py2'
219220

221+
def add_six():
222+
py_modules.append('six')
223+
220224
if sys.platform=='win32':
221225
# always add these to the win32 installer
222226
add_pytz()
223227
add_dateutil()
228+
add_six()
224229
else:
225230
# only add them if we need them
226231
if provide_pytz:
227232
add_pytz()
228233
print_raw("adding pytz")
229234
if provide_dateutil:
230235
add_dateutil()
236+
if provide_six:
237+
add_six()
231238

232239
print_raw("")
233240
print_raw("OPTIONAL USETEX DEPENDENCIES")
@@ -257,7 +264,8 @@ def should_2to3(file, root):
257264
file = os.path.abspath(file)[len(os.path.abspath(root)):]
258265
if ('py3' in file or
259266
file.startswith('pytz') or
260-
file.startswith('dateutil')):
267+
file.startswith('dateutil') or
268+
file.startswith('six')):
261269
return False
262270
return True
263271

setupext.py

+35
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
'verbose': False,
108108
'provide_pytz': 'auto',
109109
'provide_dateutil': 'auto',
110+
'provide_six': 'auto',
110111
'build_agg': True,
111112
'build_gtk': 'auto',
112113
'build_gtkagg': 'auto',
@@ -143,6 +144,10 @@
143144
"dateutil")
144145
except: options['provide_dateutil'] = 'auto'
145146

147+
try: options['provide_six'] = config.getboolean("provide_packages",
148+
"six")
149+
except: options['provide_six'] = 'auto'
150+
146151
try: options['build_gtk'] = config.getboolean("gui_support", "gtk")
147152
except: options['build_gtk'] = 'auto'
148153

@@ -477,6 +482,36 @@ def check_provide_dateutil():
477482
print_status("dateutil", "present, version unknown")
478483
return False
479484

485+
def check_provide_six():
486+
# We don't need six on Python 2.x
487+
if sys.version_info[0] < 3:
488+
return
489+
490+
if options['provide_six'] is True:
491+
print_status("six", "matplotlib will provide")
492+
return True
493+
try:
494+
import six
495+
except ImportError:
496+
if options['provide_six']:
497+
print_status("six", "matplotlib will provide")
498+
return True
499+
else:
500+
print_status("six", "no")
501+
return False
502+
else:
503+
try:
504+
if six.__version__.endswith('mpl'):
505+
print_status("six", "matplotlib will provide")
506+
return True
507+
else:
508+
print_status("six", six.__version__)
509+
return False
510+
except AttributeError:
511+
print_status("six", "present, version unknown")
512+
return False
513+
514+
480515
def check_for_dvipng():
481516
try:
482517
stdin, stdout = run_child_process('dvipng -version')

0 commit comments

Comments
 (0)