prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Deprecate the pyomo install-extras subcommand
  The conda pyomo.extras package supports this functionality more robustly.  We should not duplicate this logic in separate places.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pyomo/scripting/plugins/extras.py`
  Content:
  ```
  1 #  ___________________________________________________________________________
  2 #
  3 #  Pyomo: Python Optimization Modeling Objects
  4 #  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
  5 #  Under the terms of Contract DE-NA0003525 with National Technology and 
  6 #  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain 
  7 #  rights in this software.
  8 #  This software is distributed under the 3-clause BSD License.
  9 #  ___________________________________________________________________________
  10 
  11 import six
  12 from pyomo.scripting.pyomo_parser import add_subparser, CustomHelpFormatter
  13 
  14 def get_packages():
  15     packages = [
  16         'sympy', 
  17         'xlrd', 
  18         'openpyxl', 
  19         #('suds-jurko', 'suds'),
  20         ('PyYAML', 'yaml'),
  21         'pypyodbc', 
  22         'pymysql', 
  23         #'openopt', 
  24         #'FuncDesigner', 
  25         #'DerApproximator', 
  26         ('ipython[notebook]', 'IPython'),
  27         ('pyro4', 'Pyro4'),
  28     ]
  29     if six.PY2:
  30         packages.append(('pyro','Pyro'))
  31     return packages
  32 
  33 def install_extras(args=[], quiet=False):
  34     #
  35     # Verify that pip is installed
  36     #
  37     try:
  38         import pip
  39         pip_version = pip.__version__.split('.')
  40         for i,s in enumerate(pip_version):
  41             try:
  42                 pip_version[i] = int(s)
  43             except:
  44                 pass
  45         pip_version = tuple(pip_version)
  46     except ImportError:
  47         print("You must have 'pip' installed to run this script.")
  48         raise SystemExit
  49 
  50     cmd = ['--disable-pip-version-check', 'install','--upgrade']
  51     # Disable the PIP download cache
  52     if pip_version[0] >= 6:
  53         cmd.append('--no-cache-dir')
  54     else:
  55         cmd.append('--download-cache')
  56         cmd.append('')
  57 
  58     if not quiet:
  59         print(' ')
  60         print('-'*60)
  61         print("Installation Output Logs")
  62         print("  (A summary will be printed below)")
  63         print('-'*60)
  64         print(' ')
  65 
  66     results = {}
  67     for package in get_packages():
  68         if type(package) is tuple:
  69             package, pkg_import = package
  70         else:
  71             pkg_import = package
  72         try:
  73             # Allow the user to provide extra options
  74             pip.main(cmd + args + [package])
  75             __import__(pkg_import)
  76             results[package] = True
  77         except:
  78             results[package] = False
  79         try:
  80             pip.logger.consumers = []
  81         except AttributeError:
  82             # old pip versions (prior to 6.0~104^2)
  83             pip.log.consumers = []
  84 
  85     if not quiet:
  86         print(' ')
  87         print(' ')
  88     print('-'*60)
  89     print("Installation Summary")
  90     print('-'*60)
  91     print(' ')
  92     for package, result in sorted(six.iteritems(results)):
  93         if result:
  94             print("YES %s" % package)
  95         else:
  96             print("NO  %s" % package)
  97 
  98 
  99 def pyomo_subcommand(options):
  100     return install_extras(options.args, quiet=options.quiet)
  101 
  102 
  103 _parser = add_subparser(
  104     'install-extras',
  105     func=pyomo_subcommand,
  106     help='Install "extra" packages that Pyomo can leverage.',
  107     description="""
  108 This pyomo subcommand uses PIP to install optional third-party Python
  109 packages that Pyomo could leverage from PyPI.  The installation of some
  110 packages may fail, but this subcommand ignore these failures and
  111 provides a summary describing which packages were installed.
  112 """,
  113     epilog="""
  114 Since pip options begin with a dash, the --pip-args option can only be
  115 used with the equals syntax.  --pip-args may appear multiple times on
  116 the command line.  For example:\n\n
  117     pyomo install-extras --pip-args="--upgrade"
  118 """,
  119     formatter_class=CustomHelpFormatter,
  120 )
  121 
  122 _parser.add_argument(
  123     '-q', '--quiet',
  124     action='store_true',
  125     dest='quiet',
  126     default=False,
  127     help="Suppress some terminal output",
  128 )
  129 _parser.add_argument(
  130     "--pip-args",
  131     dest="args",
  132     action="append",
  133     help=("Arguments that are passed to the 'pip' command when "
  134           "installing packages"),
  135 )
  136 
  137
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pyomo/scripting/plugins/extras.py b/pyomo/scripting/plugins/extras.py
  --- a/pyomo/scripting/plugins/extras.py
  +++ b/pyomo/scripting/plugins/extras.py
  @@ -11,6 +11,8 @@
   import six
   from pyomo.scripting.pyomo_parser import add_subparser, CustomHelpFormatter
   
  +from pyomo.common.deprecation import deprecated
  +
   def get_packages():
       packages = [
           'sympy', 
  @@ -30,6 +32,11 @@
           packages.append(('pyro','Pyro'))
       return packages
   
  +@deprecated(
  +        "Use of the pyomo install-extras is deprecated."
  +        "The current recommended course of action is to manually install "
  +        "optional dependencies as needed.",
  +        version='TBD')
   def install_extras(args=[], quiet=False):
       #
       # Verify that pip is installed
  
verification_info: {"golden_diff": "diff --git a/pyomo/scripting/plugins/extras.py b/pyomo/scripting/plugins/extras.py\n--- a/pyomo/scripting/plugins/extras.py\n+++ b/pyomo/scripting/plugins/extras.py\n@@ -11,6 +11,8 @@\n import six\n from pyomo.scripting.pyomo_parser import add_subparser, CustomHelpFormatter\n \n+from pyomo.common.deprecation import deprecated\n+\n def get_packages():\n     packages = [\n         'sympy', \n@@ -30,6 +32,11 @@\n         packages.append(('pyro','Pyro'))\n     return packages\n \n+@deprecated(\n+        \"Use of the pyomo install-extras is deprecated.\"\n+        \"The current recommended course of action is to manually install \"\n+        \"optional dependencies as needed.\",\n+        version='TBD')\n def install_extras(args=[], quiet=False):\n     #\n     # Verify that pip is installed\n", "issue": "Deprecate the pyomo install-extras subcommand\nThe conda pyomo.extras package supports this functionality more robustly.  We should not duplicate this logic in separate places.\n", "before_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and \n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain \n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\nimport six\nfrom pyomo.scripting.pyomo_parser import add_subparser, CustomHelpFormatter\n\ndef get_packages():\n    packages = [\n        'sympy', \n        'xlrd', \n        'openpyxl', \n        #('suds-jurko', 'suds'),\n        ('PyYAML', 'yaml'),\n        'pypyodbc', \n        'pymysql', \n        #'openopt', \n        #'FuncDesigner', \n        #'DerApproximator', \n        ('ipython[notebook]', 'IPython'),\n        ('pyro4', 'Pyro4'),\n    ]\n    if six.PY2:\n        packages.append(('pyro','Pyro'))\n    return packages\n\ndef install_extras(args=[], quiet=False):\n    #\n    # Verify that pip is installed\n    #\n    try:\n        import pip\n        pip_version = pip.__version__.split('.')\n        for i,s in enumerate(pip_version):\n            try:\n                pip_version[i] = int(s)\n            except:\n                pass\n        pip_version = tuple(pip_version)\n    except ImportError:\n        print(\"You must have 'pip' installed to run this script.\")\n        raise SystemExit\n\n    cmd = ['--disable-pip-version-check', 'install','--upgrade']\n    # Disable the PIP download cache\n    if pip_version[0] >= 6:\n        cmd.append('--no-cache-dir')\n    else:\n        cmd.append('--download-cache')\n        cmd.append('')\n\n    if not quiet:\n        print(' ')\n        print('-'*60)\n        print(\"Installation Output Logs\")\n        print(\"  (A summary will be printed below)\")\n        print('-'*60)\n        print(' ')\n\n    results = {}\n    for package in get_packages():\n        if type(package) is tuple:\n            package, pkg_import = package\n        else:\n            pkg_import = package\n        try:\n            # Allow the user to provide extra options\n            pip.main(cmd + args + [package])\n            __import__(pkg_import)\n            results[package] = True\n        except:\n            results[package] = False\n        try:\n            pip.logger.consumers = []\n        except AttributeError:\n            # old pip versions (prior to 6.0~104^2)\n            pip.log.consumers = []\n\n    if not quiet:\n        print(' ')\n        print(' ')\n    print('-'*60)\n    print(\"Installation Summary\")\n    print('-'*60)\n    print(' ')\n    for package, result in sorted(six.iteritems(results)):\n        if result:\n            print(\"YES %s\" % package)\n        else:\n            print(\"NO  %s\" % package)\n\n\ndef pyomo_subcommand(options):\n    return install_extras(options.args, quiet=options.quiet)\n\n\n_parser = add_subparser(\n    'install-extras',\n    func=pyomo_subcommand,\n    help='Install \"extra\" packages that Pyomo can leverage.',\n    description=\"\"\"\nThis pyomo subcommand uses PIP to install optional third-party Python\npackages that Pyomo could leverage from PyPI.  The installation of some\npackages may fail, but this subcommand ignore these failures and\nprovides a summary describing which packages were installed.\n\"\"\",\n    epilog=\"\"\"\nSince pip options begin with a dash, the --pip-args option can only be\nused with the equals syntax.  --pip-args may appear multiple times on\nthe command line.  For example:\\n\\n\n    pyomo install-extras --pip-args=\"--upgrade\"\n\"\"\",\n    formatter_class=CustomHelpFormatter,\n)\n\n_parser.add_argument(\n    '-q', '--quiet',\n    action='store_true',\n    dest='quiet',\n    default=False,\n    help=\"Suppress some terminal output\",\n)\n_parser.add_argument(\n    \"--pip-args\",\n    dest=\"args\",\n    action=\"append\",\n    help=(\"Arguments that are passed to the 'pip' command when \"\n          \"installing packages\"),\n)\n\n", "path": "pyomo/scripting/plugins/extras.py"}], "after_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and \n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain \n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\nimport six\nfrom pyomo.scripting.pyomo_parser import add_subparser, CustomHelpFormatter\n\nfrom pyomo.common.deprecation import deprecated\n\ndef get_packages():\n    packages = [\n        'sympy', \n        'xlrd', \n        'openpyxl', \n        #('suds-jurko', 'suds'),\n        ('PyYAML', 'yaml'),\n        'pypyodbc', \n        'pymysql', \n        #'openopt', \n        #'FuncDesigner', \n        #'DerApproximator', \n        ('ipython[notebook]', 'IPython'),\n        ('pyro4', 'Pyro4'),\n    ]\n    if six.PY2:\n        packages.append(('pyro','Pyro'))\n    return packages\n\n@deprecated(\n        \"Use of the pyomo install-extras is deprecated.\"\n        \"The current recommended course of action is to manually install \"\n        \"optional dependencies as needed.\",\n        version='TBD')\ndef install_extras(args=[], quiet=False):\n    #\n    # Verify that pip is installed\n    #\n    try:\n        import pip\n        pip_version = pip.__version__.split('.')\n        for i,s in enumerate(pip_version):\n            try:\n                pip_version[i] = int(s)\n            except:\n                pass\n        pip_version = tuple(pip_version)\n    except ImportError:\n        print(\"You must have 'pip' installed to run this script.\")\n        raise SystemExit\n\n    cmd = ['--disable-pip-version-check', 'install','--upgrade']\n    # Disable the PIP download cache\n    if pip_version[0] >= 6:\n        cmd.append('--no-cache-dir')\n    else:\n        cmd.append('--download-cache')\n        cmd.append('')\n\n    if not quiet:\n        print(' ')\n        print('-'*60)\n        print(\"Installation Output Logs\")\n        print(\"  (A summary will be printed below)\")\n        print('-'*60)\n        print(' ')\n\n    results = {}\n    for package in get_packages():\n        if type(package) is tuple:\n            package, pkg_import = package\n        else:\n            pkg_import = package\n        try:\n            # Allow the user to provide extra options\n            pip.main(cmd + args + [package])\n            __import__(pkg_import)\n            results[package] = True\n        except:\n            results[package] = False\n        try:\n            pip.logger.consumers = []\n        except AttributeError:\n            # old pip versions (prior to 6.0~104^2)\n            pip.log.consumers = []\n\n    if not quiet:\n        print(' ')\n        print(' ')\n    print('-'*60)\n    print(\"Installation Summary\")\n    print('-'*60)\n    print(' ')\n    for package, result in sorted(six.iteritems(results)):\n        if result:\n            print(\"YES %s\" % package)\n        else:\n            print(\"NO  %s\" % package)\n\n\ndef pyomo_subcommand(options):\n    return install_extras(options.args, quiet=options.quiet)\n\n\n_parser = add_subparser(\n    'install-extras',\n    func=pyomo_subcommand,\n    help='Install \"extra\" packages that Pyomo can leverage.',\n    description=\"\"\"\nThis pyomo subcommand uses PIP to install optional third-party Python\npackages that Pyomo could leverage from PyPI.  The installation of some\npackages may fail, but this subcommand ignore these failures and\nprovides a summary describing which packages were installed.\n\"\"\",\n    epilog=\"\"\"\nSince pip options begin with a dash, the --pip-args option can only be\nused with the equals syntax.  --pip-args may appear multiple times on\nthe command line.  For example:\\n\\n\n    pyomo install-extras --pip-args=\"--upgrade\"\n\"\"\",\n    formatter_class=CustomHelpFormatter,\n)\n\n_parser.add_argument(\n    '-q', '--quiet',\n    action='store_true',\n    dest='quiet',\n    default=False,\n    help=\"Suppress some terminal output\",\n)\n_parser.add_argument(\n    \"--pip-args\",\n    dest=\"args\",\n    action=\"append\",\n    help=(\"Arguments that are passed to the 'pip' command when \"\n          \"installing packages\"),\n)\n\n", "path": "pyomo/scripting/plugins/extras.py"}]}