Repository: Pyomo/pyomo

Issue:
Problems with setup.py when failures arise
I'm seeing the following error on Linux using Python 3.7.  FWIW, the underlying error is that the PyUtilib master branch hasn't been installed, which is now required to install the Pyomo master branch:

> Traceback (most recent call last):
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/distutils/core.py", line 148, in setup
>     dist.run_commands()
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/distutils/dist.py", line 966, in run_commands
>     self.run_command(cmd)
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/distutils/dist.py", line 985, in run_command
>     cmd_obj.run()
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/setuptools/command/develop.py", line 38, in run
>     self.install_for_development()
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/setuptools/command/develop.py", line 154, in install_for_development
>     self.process_distribution(None, self.dist, not self.no_deps)
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 752, in process_distribution
>     [requirement], self.local_index, self.easy_install
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/pkg_resources/__init__.py", line 780, in resolve
>     replace_conflicting=replace_conflicting
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1063, in best_match
>     return self.obtain(req, installer)
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1075, in obtain
>     return installer(requirement)
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
>     raise DistutilsError(msg)
> distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('PyUtilib>=5.6.6.dev0')
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "setup.py", line 191, in <module>
>     run_setup()
>   File "setup.py", line 187, in run_setup
>     """
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/site-packages/setuptools/__init__.py", line 143, in setup
>     return distutils.core.setup(**attrs)
>   File "/home/wehart/anaconda3/envs/simple/lib/python3.7/distutils/core.py", line 163, in setup
>     raise SystemExit("error: " + str(msg))
> SystemExit: error: Could not find suitable distribution for Requirement.parse('PyUtilib>=5.6.6.dev0')
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "setup.py", line 197, in <module>
>     if 'Microsoft Visual C++' not in e_info.message:
> AttributeError: 'SystemExit' object has no attribute 'message'



Discussion:
@whart222 what command did you use to install? `python setup.py develop`? Did you install a development version of PyUtilib before installing Pyomo?

I tried to recreate this error in Python 2.7 on Linux and found that I could get a similar error if I tried to install Pyomo using `develop` without first installing PyUtilib using `develop`. I could not reproduce the secondary `AttributeError` exception.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -194,7 +194,7 @@ def run_setup():
     # environment is missing / has an incorrect Microsoft compiler.
     # Since Cython is not strictly required, we will disable Cython and
     # try re-running setup(), but only for this very specific situation.
-    if 'Microsoft Visual C++' not in e_info.message:
+    if 'Microsoft Visual C++' not in str(e_info):
         raise
     elif using_cython == CYTHON_REQUIRED:
         print("""


Test patch: