Skip to content

Commit

Permalink
setup.py: fix for Python 2.6
Browse files Browse the repository at this point in the history
With Python 2.6 on Mac OS X 10.11 I got an error:
$ ./setup.py install
running install
running build_ext
Traceback (most recent call last):
  File "./setup.py", line 195, in <module>
    setup(**kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "./setup.py", line 103, in run
    if self._called_from_setup:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 105, in __getattr__
    raise AttributeError, attr
AttributeError: _called_from_setup

Now _called_from_setup() is called only if it exists.
  • Loading branch information
LudovicRousseau committed Mar 27, 2016
1 parent 9277d45 commit fd90704
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def run(self):
if self.old_and_unmanageable or self.single_version_externally_managed:
return install_orig.install.run(self)

if not self._called_from_setup(inspect.currentframe()):
try:
have_called_from_setup = self._called_from_setup is not None
except AttributeError:
have_called_from_setup = False

if not have_called_from_setup or not self._called_from_setup(inspect.currentframe()):
# Run in backward-compatibility mode to support bdist_* commands.
install_orig.install.run(self)
else:
Expand Down

0 comments on commit fd90704

Please sign in to comment.