Skip to content

Commit

Permalink
Fixed SyntaxError when installing via Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond authored and rbtcollins committed Mar 18, 2013
1 parent e7ac371 commit 56c49a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -21,6 +21,9 @@ Improvements
create a synthetic test recording any such exception.
(Robert Collins, #1130429)

* Fixed SyntaxError raised in ``_compat2x.py`` when installing via Python 3.
(Will Bond, #941958)

* New class ``StreamResult`` which defines the API for the new result type.
(Robert Collins)

Expand Down
10 changes: 10 additions & 0 deletions setup.py
Expand Up @@ -2,15 +2,25 @@
"""Distutils installer for testtools."""

from setuptools import setup
from distutils.command.build_py import build_py
import email
import os
import sys

import testtools
cmd_class = {}
if getattr(testtools, 'TestCommand', None) is not None:
cmd_class['test'] = testtools.TestCommand


class testtools_build_py(build_py):
def build_module(self, module, module_file, package):
if sys.version_info >= (3,) and module == '_compat2x':
return
return build_py.build_module(self, module, module_file, package)
cmd_class['build_py'] = testtools_build_py


def get_version_from_pkg_info():
"""Get the version from PKG-INFO file if we can."""
pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
Expand Down
2 changes: 1 addition & 1 deletion testtools/compat.py
Expand Up @@ -35,7 +35,7 @@

try:
from testtools import _compat2x as _compat
except SyntaxError:
except (SyntaxError, ImportError):
from testtools import _compat3x as _compat

reraise = _compat.reraise
Expand Down

0 comments on commit 56c49a5

Please sign in to comment.