Skip to content

Commit

Permalink
Install six as a proper top-level package. Fix some other minor and r…
Browse files Browse the repository at this point in the history
…elated issues related to installing dateutil and pytz on Python 3.
  • Loading branch information
mdboom committed Aug 28, 2012
1 parent 0ee82be commit dbdc6be
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/dateutil_py2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"""
__author__ = "Gustavo Niemeyer <[email protected]>"
__license__ = "PSF License"
__version__ = "1.5"
__version__ = "1.5-mpl"
2 changes: 1 addition & 1 deletion lib/dateutil_py3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"""
__author__ = "Tomi Pieviläinen <[email protected]>"
__license__ = "Simplified BSD"
__version__ = "2.1"
__version__ = "2.1-mpl"
12 changes: 6 additions & 6 deletions lib/pytz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
VERSION = OLSON_VERSION
# Version format for a patch release - only one so far.
#VERSION = OLSON_VERSION + '.2'
__version__ = OLSON_VERSION
__version__ = OLSON_VERSION + "-mpl"

OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling

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

def timezone(zone):
r''' Return a datetime.tzinfo implementation for the given timezone
r''' Return a datetime.tzinfo implementation for the given timezone
>>> from datetime import datetime, timedelta
>>> utc = timezone('UTC')
Expand Down Expand Up @@ -252,7 +252,7 @@ def __str__(self):
def _UTC():
"""Factory function for utc unpickling.
Makes sure that unpickling a utc instance always returns the same
Makes sure that unpickling a utc instance always returns the same
module global.
These examples belong in the UTC class above, but it is obscured; or in
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def _test():
'Zulu']
all_timezones = [
tz for tz in all_timezones if resource_exists(tz)]

all_timezones_set = set(all_timezones)
common_timezones = \
['Africa/Abidjan',
Expand Down Expand Up @@ -1533,5 +1533,5 @@ def _test():
'UTC']
common_timezones = [
tz for tz in common_timezones if tz in all_timezones]

common_timezones_set = set(common_timezones)
2 changes: 1 addition & 1 deletion lib/dateutil_py3/six.py → lib/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import types

__author__ = "Benjamin Peterson <[email protected]>"
__version__ = "1.1.0"
__version__ = "1.1.0-mpl"


# True if we are running on Python 3.
Expand Down
1 change: 1 addition & 0 deletions setup.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
## Date/timezone support:
#pytz = False
#dateutil = False
#six = False

[gui_support]
# Matplotlib supports multiple GUI toolkits, including Cocoa,
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
check_for_qt, check_for_qt4, check_for_pyside, check_for_cairo, \
check_provide_pytz, check_provide_dateutil,\
check_for_dvipng, check_for_ghostscript, check_for_latex, \
check_for_pdftops, options, build_png, build_tri
check_for_pdftops, options, build_png, build_tri, check_provide_six

# jdh
packages = [
Expand Down Expand Up @@ -190,6 +190,7 @@ def chop_package(fname):

provide_dateutil = check_provide_dateutil()
provide_pytz = check_provide_pytz()
provide_six = check_provide_six()

def add_pytz():
packages.append('pytz')
Expand Down Expand Up @@ -217,17 +218,23 @@ def add_dateutil():
else:
package_dir['dateutil'] = 'lib/dateutil_py2'

def add_six():
py_modules.append('six')

if sys.platform=='win32':
# always add these to the win32 installer
add_pytz()
add_dateutil()
add_six()
else:
# only add them if we need them
if provide_pytz:
add_pytz()
print_raw("adding pytz")
if provide_dateutil:
add_dateutil()
if provide_six:
add_six()

print_raw("")
print_raw("OPTIONAL USETEX DEPENDENCIES")
Expand Down Expand Up @@ -257,7 +264,8 @@ def should_2to3(file, root):
file = os.path.abspath(file)[len(os.path.abspath(root)):]
if ('py3' in file or
file.startswith('pytz') or
file.startswith('dateutil')):
file.startswith('dateutil') or
file.startswith('six')):
return False
return True

Expand Down
35 changes: 35 additions & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'verbose': False,
'provide_pytz': 'auto',
'provide_dateutil': 'auto',
'provide_six': 'auto',
'build_agg': True,
'build_gtk': 'auto',
'build_gtkagg': 'auto',
Expand Down Expand Up @@ -143,6 +144,10 @@
"dateutil")
except: options['provide_dateutil'] = 'auto'

try: options['provide_six'] = config.getboolean("provide_packages",
"six")
except: options['provide_six'] = 'auto'

try: options['build_gtk'] = config.getboolean("gui_support", "gtk")
except: options['build_gtk'] = 'auto'

Expand Down Expand Up @@ -477,6 +482,36 @@ def check_provide_dateutil():
print_status("dateutil", "present, version unknown")
return False

def check_provide_six():
# We don't need six on Python 2.x
if sys.version_info[0] < 3:
return

if options['provide_six'] is True:
print_status("six", "matplotlib will provide")
return True
try:
import six
except ImportError:
if options['provide_six']:
print_status("six", "matplotlib will provide")
return True
else:
print_status("six", "no")
return False
else:
try:
if six.__version__.endswith('mpl'):
print_status("six", "matplotlib will provide")
return True
else:
print_status("six", six.__version__)
return False
except AttributeError:
print_status("six", "present, version unknown")
return False


def check_for_dvipng():
try:
stdin, stdout = run_child_process('dvipng -version')
Expand Down

0 comments on commit dbdc6be

Please sign in to comment.