prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [GHA] Better handling of environment variables and change detection
  This should help reduce the number of times that Android AVD tests have to be run, along with consolidating some of the environment variable logic.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `setup.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 from __future__ import print_function
  3 
  4 import glob
  5 import os
  6 import platform
  7 import subprocess
  8 import sys
  9 import traceback
  10 from distutils.command.install import INSTALL_SCHEMES
  11 from distutils.sysconfig import get_python_inc
  12 from distutils.util import convert_path
  13 
  14 from setuptools import find_packages
  15 from setuptools import setup
  16 
  17 # Get all template files
  18 templates = []
  19 for dirpath, dirnames, filenames in os.walk(convert_path('pwnlib/shellcraft/templates'), followlinks=True):
  20     for f in filenames:
  21         templates.append(os.path.relpath(os.path.join(dirpath, f), 'pwnlib'))
  22 
  23 # This makes pwntools-LICENSE.txt appear with the package folders
  24 for scheme in INSTALL_SCHEMES.values():
  25     scheme['data'] = scheme['purelib']
  26 
  27 console_scripts = ['pwn=pwnlib.commandline.main:main']
  28 
  29 # Find all of the ancillary console scripts
  30 # We have a magic flag --include-all-scripts
  31 flag = '--only-use-pwn-command'
  32 if flag in sys.argv:
  33     sys.argv.remove(flag)
  34 else:
  35     flag = False
  36 
  37 for filename in glob.glob('pwnlib/commandline/*'):
  38     filename = os.path.basename(filename)
  39     filename, ext = os.path.splitext(filename)
  40 
  41     if ext != '.py' or '__init__' in filename:
  42         continue
  43 
  44     script = '%s=pwnlib.commandline.common:main' % filename
  45     if not flag:
  46         console_scripts.append(script)
  47 
  48 install_requires     = ['paramiko>=1.15.2',
  49                         'mako>=1.0.0',
  50                         'pyelftools>=0.2.4',
  51                         'capstone>=3.0.5rc2', # See Gallopsled/pwntools#971, Gallopsled/pwntools#1160
  52                         'ropgadget>=5.3',
  53                         'pyserial>=2.7',
  54                         'requests>=2.0',
  55                         'pip>=6.0.8',
  56                         'pygments>=2.0',
  57                         'pysocks',
  58                         'python-dateutil',
  59                         'packaging',
  60                         'psutil>=3.3.0',
  61                         'intervaltree>=3.0',
  62                         'sortedcontainers',
  63                         # see unicorn-engine/unicorn#1100 and #1170
  64                         'unicorn>=1.0.2rc1',
  65                         'six>=1.12.0',
  66                         'rpyc',
  67                         'colored_traceback',
  68 ]
  69 
  70 if platform.python_version_tuple()[0] == '2':
  71     install_requires += ['pathlib2']
  72 
  73 # Check that the user has installed the Python development headers
  74 PythonH = os.path.join(get_python_inc(), 'Python.h')
  75 if not os.path.exists(PythonH):
  76     print("You must install the Python development headers!", file=sys.stderr)
  77     print("$ apt-get install python-dev", file=sys.stderr)
  78     sys.exit(-1)
  79 
  80 # Convert README.md to reStructuredText for PyPI
  81 long_description = ''
  82 try:
  83     long_description = subprocess.check_output(['pandoc', 'README.md', '--to=rst'], universal_newlines=True)
  84 except Exception as e:
  85     print("Failed to convert README.md through pandoc, proceeding anyway", file=sys.stderr)
  86     traceback.print_exc()
  87 
  88 setup(
  89     name                 = 'pwntools',
  90     python_requires      = '>=2.7',
  91     packages             = find_packages(),
  92     version              = '4.11.0dev',
  93     data_files           = [('pwntools-doc',
  94                              glob.glob('*.md') + glob.glob('*.txt')),
  95                             ],
  96     package_data         = {
  97         'pwnlib': [
  98             'data/crcsums.txt',
  99             'data/useragents/useragents.txt',
  100             'data/binutils/*',
  101             'data/includes/*.h',
  102             'data/includes/*/*.h',
  103             'data/templates/*.mako',
  104         ] + templates,
  105     },
  106     entry_points = {'console_scripts': console_scripts},
  107     scripts              = glob.glob("bin/*"),
  108     description          = "Pwntools CTF framework and exploit development library.",
  109     long_description     = long_description,
  110     author               = "Gallopsled et al.",
  111     author_email         = "pwntools-users@googlegroups.com",
  112     url                  = 'https://pwntools.com',
  113     download_url         = "https://github.com/Gallopsled/pwntools/releases",
  114     install_requires     = install_requires,
  115     license              = "Mostly MIT, some GPL/BSD, see LICENSE-pwntools.txt",
  116     keywords             = 'pwntools exploit ctf capture the flag binary wargame overflow stack heap defcon',
  117     classifiers          = [
  118         'Development Status :: 5 - Production/Stable',
  119         'Environment :: Console',
  120         'Intended Audience :: Developers',
  121         'Intended Audience :: Science/Research',
  122         'Intended Audience :: System Administrators',
  123         'License :: OSI Approved :: MIT License',
  124         'Natural Language :: English',
  125         'Operating System :: POSIX :: Linux',
  126         'Programming Language :: Python :: 2.7',
  127         'Programming Language :: Python :: 3',
  128         'Topic :: Security',
  129         'Topic :: Software Development :: Assemblers',
  130         'Topic :: Software Development :: Debuggers',
  131         'Topic :: Software Development :: Disassemblers',
  132         'Topic :: Software Development :: Embedded Systems',
  133         'Topic :: Software Development :: Libraries :: Python Modules',
  134         'Topic :: System :: System Shells',
  135         'Topic :: Utilities',
  136     ]
  137 )
  138
  ```
  --- 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/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -11,7 +11,6 @@
   from distutils.sysconfig import get_python_inc
   from distutils.util import convert_path
   
  -from setuptools import find_packages
   from setuptools import setup
   
   # Get all template files
  @@ -45,30 +44,12 @@
       if not flag:
           console_scripts.append(script)
   
  -install_requires     = ['paramiko>=1.15.2',
  -                        'mako>=1.0.0',
  -                        'pyelftools>=0.2.4',
  -                        'capstone>=3.0.5rc2', # See Gallopsled/pwntools#971, Gallopsled/pwntools#1160
  -                        'ropgadget>=5.3',
  -                        'pyserial>=2.7',
  -                        'requests>=2.0',
  -                        'pip>=6.0.8',
  -                        'pygments>=2.0',
  -                        'pysocks',
  -                        'python-dateutil',
  -                        'packaging',
  -                        'psutil>=3.3.0',
  -                        'intervaltree>=3.0',
  -                        'sortedcontainers',
  -                        # see unicorn-engine/unicorn#1100 and #1170
  -                        'unicorn>=1.0.2rc1',
  -                        'six>=1.12.0',
  -                        'rpyc',
  -                        'colored_traceback',
  -]
  -
  -if platform.python_version_tuple()[0] == '2':
  -    install_requires += ['pathlib2']
  +compat = {}
  +if sys.version_info < (3, 4):
  +    import toml
  +    project = toml.load('pyproject.toml')['project']
  +    compat['install_requires'] = project['dependencies']
  +    compat['name'] = project['name']
   
   # Check that the user has installed the Python development headers
   PythonH = os.path.join(get_python_inc(), 'Python.h')
  @@ -77,18 +58,7 @@
       print("$ apt-get install python-dev", file=sys.stderr)
       sys.exit(-1)
   
  -# Convert README.md to reStructuredText for PyPI
  -long_description = ''
  -try:
  -    long_description = subprocess.check_output(['pandoc', 'README.md', '--to=rst'], universal_newlines=True)
  -except Exception as e:
  -    print("Failed to convert README.md through pandoc, proceeding anyway", file=sys.stderr)
  -    traceback.print_exc()
  -
   setup(
  -    name                 = 'pwntools',
  -    python_requires      = '>=2.7',
  -    packages             = find_packages(),
       version              = '4.11.0dev',
       data_files           = [('pwntools-doc',
                                glob.glob('*.md') + glob.glob('*.txt')),
  @@ -105,33 +75,5 @@
       },
       entry_points = {'console_scripts': console_scripts},
       scripts              = glob.glob("bin/*"),
  -    description          = "Pwntools CTF framework and exploit development library.",
  -    long_description     = long_description,
  -    author               = "Gallopsled et al.",
  -    author_email         = "pwntools-users@googlegroups.com",
  -    url                  = 'https://pwntools.com',
  -    download_url         = "https://github.com/Gallopsled/pwntools/releases",
  -    install_requires     = install_requires,
  -    license              = "Mostly MIT, some GPL/BSD, see LICENSE-pwntools.txt",
  -    keywords             = 'pwntools exploit ctf capture the flag binary wargame overflow stack heap defcon',
  -    classifiers          = [
  -        'Development Status :: 5 - Production/Stable',
  -        'Environment :: Console',
  -        'Intended Audience :: Developers',
  -        'Intended Audience :: Science/Research',
  -        'Intended Audience :: System Administrators',
  -        'License :: OSI Approved :: MIT License',
  -        'Natural Language :: English',
  -        'Operating System :: POSIX :: Linux',
  -        'Programming Language :: Python :: 2.7',
  -        'Programming Language :: Python :: 3',
  -        'Topic :: Security',
  -        'Topic :: Software Development :: Assemblers',
  -        'Topic :: Software Development :: Debuggers',
  -        'Topic :: Software Development :: Disassemblers',
  -        'Topic :: Software Development :: Embedded Systems',
  -        'Topic :: Software Development :: Libraries :: Python Modules',
  -        'Topic :: System :: System Shells',
  -        'Topic :: Utilities',
  -    ]
  +    **compat
   )
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -11,7 +11,6 @@\n from distutils.sysconfig import get_python_inc\n from distutils.util import convert_path\n \n-from setuptools import find_packages\n from setuptools import setup\n \n # Get all template files\n@@ -45,30 +44,12 @@\n     if not flag:\n         console_scripts.append(script)\n \n-install_requires     = ['paramiko>=1.15.2',\n-                        'mako>=1.0.0',\n-                        'pyelftools>=0.2.4',\n-                        'capstone>=3.0.5rc2', # See Gallopsled/pwntools#971, Gallopsled/pwntools#1160\n-                        'ropgadget>=5.3',\n-                        'pyserial>=2.7',\n-                        'requests>=2.0',\n-                        'pip>=6.0.8',\n-                        'pygments>=2.0',\n-                        'pysocks',\n-                        'python-dateutil',\n-                        'packaging',\n-                        'psutil>=3.3.0',\n-                        'intervaltree>=3.0',\n-                        'sortedcontainers',\n-                        # see unicorn-engine/unicorn#1100 and #1170\n-                        'unicorn>=1.0.2rc1',\n-                        'six>=1.12.0',\n-                        'rpyc',\n-                        'colored_traceback',\n-]\n-\n-if platform.python_version_tuple()[0] == '2':\n-    install_requires += ['pathlib2']\n+compat = {}\n+if sys.version_info < (3, 4):\n+    import toml\n+    project = toml.load('pyproject.toml')['project']\n+    compat['install_requires'] = project['dependencies']\n+    compat['name'] = project['name']\n \n # Check that the user has installed the Python development headers\n PythonH = os.path.join(get_python_inc(), 'Python.h')\n@@ -77,18 +58,7 @@\n     print(\"$ apt-get install python-dev\", file=sys.stderr)\n     sys.exit(-1)\n \n-# Convert README.md to reStructuredText for PyPI\n-long_description = ''\n-try:\n-    long_description = subprocess.check_output(['pandoc', 'README.md', '--to=rst'], universal_newlines=True)\n-except Exception as e:\n-    print(\"Failed to convert README.md through pandoc, proceeding anyway\", file=sys.stderr)\n-    traceback.print_exc()\n-\n setup(\n-    name                 = 'pwntools',\n-    python_requires      = '>=2.7',\n-    packages             = find_packages(),\n     version              = '4.11.0dev',\n     data_files           = [('pwntools-doc',\n                              glob.glob('*.md') + glob.glob('*.txt')),\n@@ -105,33 +75,5 @@\n     },\n     entry_points = {'console_scripts': console_scripts},\n     scripts              = glob.glob(\"bin/*\"),\n-    description          = \"Pwntools CTF framework and exploit development library.\",\n-    long_description     = long_description,\n-    author               = \"Gallopsled et al.\",\n-    author_email         = \"pwntools-users@googlegroups.com\",\n-    url                  = 'https://pwntools.com',\n-    download_url         = \"https://github.com/Gallopsled/pwntools/releases\",\n-    install_requires     = install_requires,\n-    license              = \"Mostly MIT, some GPL/BSD, see LICENSE-pwntools.txt\",\n-    keywords             = 'pwntools exploit ctf capture the flag binary wargame overflow stack heap defcon',\n-    classifiers          = [\n-        'Development Status :: 5 - Production/Stable',\n-        'Environment :: Console',\n-        'Intended Audience :: Developers',\n-        'Intended Audience :: Science/Research',\n-        'Intended Audience :: System Administrators',\n-        'License :: OSI Approved :: MIT License',\n-        'Natural Language :: English',\n-        'Operating System :: POSIX :: Linux',\n-        'Programming Language :: Python :: 2.7',\n-        'Programming Language :: Python :: 3',\n-        'Topic :: Security',\n-        'Topic :: Software Development :: Assemblers',\n-        'Topic :: Software Development :: Debuggers',\n-        'Topic :: Software Development :: Disassemblers',\n-        'Topic :: Software Development :: Embedded Systems',\n-        'Topic :: Software Development :: Libraries :: Python Modules',\n-        'Topic :: System :: System Shells',\n-        'Topic :: Utilities',\n-    ]\n+    **compat\n )\n", "issue": "[GHA] Better handling of environment variables and change detection\nThis should help reduce the number of times that Android AVD tests have to be run, along with consolidating some of the environment variable logic.\n", "before_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function\n\nimport glob\nimport os\nimport platform\nimport subprocess\nimport sys\nimport traceback\nfrom distutils.command.install import INSTALL_SCHEMES\nfrom distutils.sysconfig import get_python_inc\nfrom distutils.util import convert_path\n\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n# Get all template files\ntemplates = []\nfor dirpath, dirnames, filenames in os.walk(convert_path('pwnlib/shellcraft/templates'), followlinks=True):\n    for f in filenames:\n        templates.append(os.path.relpath(os.path.join(dirpath, f), 'pwnlib'))\n\n# This makes pwntools-LICENSE.txt appear with the package folders\nfor scheme in INSTALL_SCHEMES.values():\n    scheme['data'] = scheme['purelib']\n\nconsole_scripts = ['pwn=pwnlib.commandline.main:main']\n\n# Find all of the ancillary console scripts\n# We have a magic flag --include-all-scripts\nflag = '--only-use-pwn-command'\nif flag in sys.argv:\n    sys.argv.remove(flag)\nelse:\n    flag = False\n\nfor filename in glob.glob('pwnlib/commandline/*'):\n    filename = os.path.basename(filename)\n    filename, ext = os.path.splitext(filename)\n\n    if ext != '.py' or '__init__' in filename:\n        continue\n\n    script = '%s=pwnlib.commandline.common:main' % filename\n    if not flag:\n        console_scripts.append(script)\n\ninstall_requires     = ['paramiko>=1.15.2',\n                        'mako>=1.0.0',\n                        'pyelftools>=0.2.4',\n                        'capstone>=3.0.5rc2', # See Gallopsled/pwntools#971, Gallopsled/pwntools#1160\n                        'ropgadget>=5.3',\n                        'pyserial>=2.7',\n                        'requests>=2.0',\n                        'pip>=6.0.8',\n                        'pygments>=2.0',\n                        'pysocks',\n                        'python-dateutil',\n                        'packaging',\n                        'psutil>=3.3.0',\n                        'intervaltree>=3.0',\n                        'sortedcontainers',\n                        # see unicorn-engine/unicorn#1100 and #1170\n                        'unicorn>=1.0.2rc1',\n                        'six>=1.12.0',\n                        'rpyc',\n                        'colored_traceback',\n]\n\nif platform.python_version_tuple()[0] == '2':\n    install_requires += ['pathlib2']\n\n# Check that the user has installed the Python development headers\nPythonH = os.path.join(get_python_inc(), 'Python.h')\nif not os.path.exists(PythonH):\n    print(\"You must install the Python development headers!\", file=sys.stderr)\n    print(\"$ apt-get install python-dev\", file=sys.stderr)\n    sys.exit(-1)\n\n# Convert README.md to reStructuredText for PyPI\nlong_description = ''\ntry:\n    long_description = subprocess.check_output(['pandoc', 'README.md', '--to=rst'], universal_newlines=True)\nexcept Exception as e:\n    print(\"Failed to convert README.md through pandoc, proceeding anyway\", file=sys.stderr)\n    traceback.print_exc()\n\nsetup(\n    name                 = 'pwntools',\n    python_requires      = '>=2.7',\n    packages             = find_packages(),\n    version              = '4.11.0dev',\n    data_files           = [('pwntools-doc',\n                             glob.glob('*.md') + glob.glob('*.txt')),\n                            ],\n    package_data         = {\n        'pwnlib': [\n            'data/crcsums.txt',\n            'data/useragents/useragents.txt',\n            'data/binutils/*',\n            'data/includes/*.h',\n            'data/includes/*/*.h',\n            'data/templates/*.mako',\n        ] + templates,\n    },\n    entry_points = {'console_scripts': console_scripts},\n    scripts              = glob.glob(\"bin/*\"),\n    description          = \"Pwntools CTF framework and exploit development library.\",\n    long_description     = long_description,\n    author               = \"Gallopsled et al.\",\n    author_email         = \"pwntools-users@googlegroups.com\",\n    url                  = 'https://pwntools.com',\n    download_url         = \"https://github.com/Gallopsled/pwntools/releases\",\n    install_requires     = install_requires,\n    license              = \"Mostly MIT, some GPL/BSD, see LICENSE-pwntools.txt\",\n    keywords             = 'pwntools exploit ctf capture the flag binary wargame overflow stack heap defcon',\n    classifiers          = [\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Intended Audience :: Developers',\n        'Intended Audience :: Science/Research',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: MIT License',\n        'Natural Language :: English',\n        'Operating System :: POSIX :: Linux',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Topic :: Security',\n        'Topic :: Software Development :: Assemblers',\n        'Topic :: Software Development :: Debuggers',\n        'Topic :: Software Development :: Disassemblers',\n        'Topic :: Software Development :: Embedded Systems',\n        'Topic :: Software Development :: Libraries :: Python Modules',\n        'Topic :: System :: System Shells',\n        'Topic :: Utilities',\n    ]\n)\n", "path": "setup.py"}], "after_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function\n\nimport glob\nimport os\nimport platform\nimport subprocess\nimport sys\nimport traceback\nfrom distutils.command.install import INSTALL_SCHEMES\nfrom distutils.sysconfig import get_python_inc\nfrom distutils.util import convert_path\n\nfrom setuptools import setup\n\n# Get all template files\ntemplates = []\nfor dirpath, dirnames, filenames in os.walk(convert_path('pwnlib/shellcraft/templates'), followlinks=True):\n    for f in filenames:\n        templates.append(os.path.relpath(os.path.join(dirpath, f), 'pwnlib'))\n\n# This makes pwntools-LICENSE.txt appear with the package folders\nfor scheme in INSTALL_SCHEMES.values():\n    scheme['data'] = scheme['purelib']\n\nconsole_scripts = ['pwn=pwnlib.commandline.main:main']\n\n# Find all of the ancillary console scripts\n# We have a magic flag --include-all-scripts\nflag = '--only-use-pwn-command'\nif flag in sys.argv:\n    sys.argv.remove(flag)\nelse:\n    flag = False\n\nfor filename in glob.glob('pwnlib/commandline/*'):\n    filename = os.path.basename(filename)\n    filename, ext = os.path.splitext(filename)\n\n    if ext != '.py' or '__init__' in filename:\n        continue\n\n    script = '%s=pwnlib.commandline.common:main' % filename\n    if not flag:\n        console_scripts.append(script)\n\ncompat = {}\nif sys.version_info < (3, 4):\n    import toml\n    project = toml.load('pyproject.toml')['project']\n    compat['install_requires'] = project['dependencies']\n    compat['name'] = project['name']\n\n# Check that the user has installed the Python development headers\nPythonH = os.path.join(get_python_inc(), 'Python.h')\nif not os.path.exists(PythonH):\n    print(\"You must install the Python development headers!\", file=sys.stderr)\n    print(\"$ apt-get install python-dev\", file=sys.stderr)\n    sys.exit(-1)\n\nsetup(\n    version              = '4.11.0dev',\n    data_files           = [('pwntools-doc',\n                             glob.glob('*.md') + glob.glob('*.txt')),\n                            ],\n    package_data         = {\n        'pwnlib': [\n            'data/crcsums.txt',\n            'data/useragents/useragents.txt',\n            'data/binutils/*',\n            'data/includes/*.h',\n            'data/includes/*/*.h',\n            'data/templates/*.mako',\n        ] + templates,\n    },\n    entry_points = {'console_scripts': console_scripts},\n    scripts              = glob.glob(\"bin/*\"),\n    **compat\n)\n", "path": "setup.py"}]}