prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Update Windows linking code
  We should remove the environment variable based linking and document that if you want to build it dynamic vs static then you should build the OpenSSL libs in your preferred fashion. The zip files we create in our jenkins job build them statically.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/_cffi_src/build_openssl.py`
  Content:
  ```
  1 # This file is dual licensed under the terms of the Apache License, Version
  2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3 # for complete details.
  4 
  5 from __future__ import absolute_import, division, print_function
  6 
  7 import os
  8 import sys
  9 
  10 from _cffi_src.utils import build_ffi_for_binding, extra_link_args
  11 
  12 
  13 def _get_openssl_libraries(platform):
  14     # OpenSSL goes by a different library name on different operating systems.
  15     if platform != "win32":
  16         # In some circumstances, the order in which these libs are
  17         # specified on the linker command-line is significant;
  18         # libssl must come before libcrypto
  19         # (http://marc.info/?l=openssl-users&m=135361825921871)
  20         return ["ssl", "crypto"]
  21     else:
  22         link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static")
  23         return _get_openssl_windows_libraries(link_type)
  24 
  25 
  26 def _get_openssl_windows_libraries(link_type):
  27     if link_type == "dynamic":
  28         return ["libeay32", "ssleay32", "advapi32"]
  29     elif link_type == "static" or link_type == "":
  30         return ["libeay32mt", "ssleay32mt", "advapi32",
  31                 "crypt32", "gdi32", "user32", "ws2_32"]
  32     else:
  33         raise ValueError(
  34             "PYCA_WINDOWS_LINK_TYPE must be 'static' or 'dynamic'"
  35         )
  36 
  37 
  38 _OSX_PRE_INCLUDE = """
  39 #ifdef __APPLE__
  40 #include <AvailabilityMacros.h>
  41 #define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \
  42     DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
  43 #undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
  44 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
  45 #endif
  46 """
  47 
  48 _OSX_POST_INCLUDE = """
  49 #ifdef __APPLE__
  50 #undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
  51 #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \
  52     __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
  53 #endif
  54 """
  55 
  56 
  57 ffi = build_ffi_for_binding(
  58     module_name="_openssl",
  59     module_prefix="_cffi_src.openssl.",
  60     modules=[
  61         "aes",
  62         "asn1",
  63         "bignum",
  64         "bio",
  65         "cmac",
  66         "cms",
  67         "conf",
  68         "crypto",
  69         "dh",
  70         "dsa",
  71         "ec",
  72         "ecdh",
  73         "ecdsa",
  74         "engine",
  75         "err",
  76         "evp",
  77         "hmac",
  78         "nid",
  79         "objects",
  80         "opensslv",
  81         "pem",
  82         "pkcs7",
  83         "pkcs12",
  84         "rand",
  85         "rsa",
  86         "ssl",
  87         "x509",
  88         "x509name",
  89         "x509v3",
  90         "x509_vfy"
  91     ],
  92     pre_include=_OSX_PRE_INCLUDE,
  93     post_include=_OSX_POST_INCLUDE,
  94     libraries=_get_openssl_libraries(sys.platform),
  95     extra_link_args=extra_link_args(sys.platform),
  96 )
  97
  ```
  --- 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/src/_cffi_src/build_openssl.py b/src/_cffi_src/build_openssl.py
  --- a/src/_cffi_src/build_openssl.py
  +++ b/src/_cffi_src/build_openssl.py
  @@ -4,7 +4,6 @@
   
   from __future__ import absolute_import, division, print_function
   
  -import os
   import sys
   
   from _cffi_src.utils import build_ffi_for_binding, extra_link_args
  @@ -19,20 +18,8 @@
           # (http://marc.info/?l=openssl-users&m=135361825921871)
           return ["ssl", "crypto"]
       else:
  -        link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static")
  -        return _get_openssl_windows_libraries(link_type)
  -
  -
  -def _get_openssl_windows_libraries(link_type):
  -    if link_type == "dynamic":
  -        return ["libeay32", "ssleay32", "advapi32"]
  -    elif link_type == "static" or link_type == "":
  -        return ["libeay32mt", "ssleay32mt", "advapi32",
  +        return ["libeay32", "ssleay32", "advapi32",
                   "crypt32", "gdi32", "user32", "ws2_32"]
  -    else:
  -        raise ValueError(
  -            "PYCA_WINDOWS_LINK_TYPE must be 'static' or 'dynamic'"
  -        )
   
   
   _OSX_PRE_INCLUDE = """
  
verification_info: {"golden_diff": "diff --git a/src/_cffi_src/build_openssl.py b/src/_cffi_src/build_openssl.py\n--- a/src/_cffi_src/build_openssl.py\n+++ b/src/_cffi_src/build_openssl.py\n@@ -4,7 +4,6 @@\n \n from __future__ import absolute_import, division, print_function\n \n-import os\n import sys\n \n from _cffi_src.utils import build_ffi_for_binding, extra_link_args\n@@ -19,20 +18,8 @@\n         # (http://marc.info/?l=openssl-users&m=135361825921871)\n         return [\"ssl\", \"crypto\"]\n     else:\n-        link_type = os.environ.get(\"PYCA_WINDOWS_LINK_TYPE\", \"static\")\n-        return _get_openssl_windows_libraries(link_type)\n-\n-\n-def _get_openssl_windows_libraries(link_type):\n-    if link_type == \"dynamic\":\n-        return [\"libeay32\", \"ssleay32\", \"advapi32\"]\n-    elif link_type == \"static\" or link_type == \"\":\n-        return [\"libeay32mt\", \"ssleay32mt\", \"advapi32\",\n+        return [\"libeay32\", \"ssleay32\", \"advapi32\",\n                 \"crypt32\", \"gdi32\", \"user32\", \"ws2_32\"]\n-    else:\n-        raise ValueError(\n-            \"PYCA_WINDOWS_LINK_TYPE must be 'static' or 'dynamic'\"\n-        )\n \n \n _OSX_PRE_INCLUDE = \"\"\"\n", "issue": "Update Windows linking code\nWe should remove the environment variable based linking and document that if you want to build it dynamic vs static then you should build the OpenSSL libs in your preferred fashion. The zip files we create in our jenkins job build them statically.\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport os\nimport sys\n\nfrom _cffi_src.utils import build_ffi_for_binding, extra_link_args\n\n\ndef _get_openssl_libraries(platform):\n    # OpenSSL goes by a different library name on different operating systems.\n    if platform != \"win32\":\n        # In some circumstances, the order in which these libs are\n        # specified on the linker command-line is significant;\n        # libssl must come before libcrypto\n        # (http://marc.info/?l=openssl-users&m=135361825921871)\n        return [\"ssl\", \"crypto\"]\n    else:\n        link_type = os.environ.get(\"PYCA_WINDOWS_LINK_TYPE\", \"static\")\n        return _get_openssl_windows_libraries(link_type)\n\n\ndef _get_openssl_windows_libraries(link_type):\n    if link_type == \"dynamic\":\n        return [\"libeay32\", \"ssleay32\", \"advapi32\"]\n    elif link_type == \"static\" or link_type == \"\":\n        return [\"libeay32mt\", \"ssleay32mt\", \"advapi32\",\n                \"crypt32\", \"gdi32\", \"user32\", \"ws2_32\"]\n    else:\n        raise ValueError(\n            \"PYCA_WINDOWS_LINK_TYPE must be 'static' or 'dynamic'\"\n        )\n\n\n_OSX_PRE_INCLUDE = \"\"\"\n#ifdef __APPLE__\n#include <AvailabilityMacros.h>\n#define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \\\n    DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#endif\n\"\"\"\n\n_OSX_POST_INCLUDE = \"\"\"\n#ifdef __APPLE__\n#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \\\n    __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#endif\n\"\"\"\n\n\nffi = build_ffi_for_binding(\n    module_name=\"_openssl\",\n    module_prefix=\"_cffi_src.openssl.\",\n    modules=[\n        \"aes\",\n        \"asn1\",\n        \"bignum\",\n        \"bio\",\n        \"cmac\",\n        \"cms\",\n        \"conf\",\n        \"crypto\",\n        \"dh\",\n        \"dsa\",\n        \"ec\",\n        \"ecdh\",\n        \"ecdsa\",\n        \"engine\",\n        \"err\",\n        \"evp\",\n        \"hmac\",\n        \"nid\",\n        \"objects\",\n        \"opensslv\",\n        \"pem\",\n        \"pkcs7\",\n        \"pkcs12\",\n        \"rand\",\n        \"rsa\",\n        \"ssl\",\n        \"x509\",\n        \"x509name\",\n        \"x509v3\",\n        \"x509_vfy\"\n    ],\n    pre_include=_OSX_PRE_INCLUDE,\n    post_include=_OSX_POST_INCLUDE,\n    libraries=_get_openssl_libraries(sys.platform),\n    extra_link_args=extra_link_args(sys.platform),\n)\n", "path": "src/_cffi_src/build_openssl.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport sys\n\nfrom _cffi_src.utils import build_ffi_for_binding, extra_link_args\n\n\ndef _get_openssl_libraries(platform):\n    # OpenSSL goes by a different library name on different operating systems.\n    if platform != \"win32\":\n        # In some circumstances, the order in which these libs are\n        # specified on the linker command-line is significant;\n        # libssl must come before libcrypto\n        # (http://marc.info/?l=openssl-users&m=135361825921871)\n        return [\"ssl\", \"crypto\"]\n    else:\n        return [\"libeay32\", \"ssleay32\", \"advapi32\",\n                \"crypt32\", \"gdi32\", \"user32\", \"ws2_32\"]\n\n\n_OSX_PRE_INCLUDE = \"\"\"\n#ifdef __APPLE__\n#include <AvailabilityMacros.h>\n#define __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \\\n    DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#endif\n\"\"\"\n\n_OSX_POST_INCLUDE = \"\"\"\n#ifdef __APPLE__\n#undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER \\\n    __ORIG_DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER\n#endif\n\"\"\"\n\n\nffi = build_ffi_for_binding(\n    module_name=\"_openssl\",\n    module_prefix=\"_cffi_src.openssl.\",\n    modules=[\n        \"aes\",\n        \"asn1\",\n        \"bignum\",\n        \"bio\",\n        \"cmac\",\n        \"cms\",\n        \"conf\",\n        \"crypto\",\n        \"dh\",\n        \"dsa\",\n        \"ec\",\n        \"ecdh\",\n        \"ecdsa\",\n        \"engine\",\n        \"err\",\n        \"evp\",\n        \"hmac\",\n        \"nid\",\n        \"objects\",\n        \"opensslv\",\n        \"pem\",\n        \"pkcs7\",\n        \"pkcs12\",\n        \"rand\",\n        \"rsa\",\n        \"ssl\",\n        \"x509\",\n        \"x509name\",\n        \"x509v3\",\n        \"x509_vfy\"\n    ],\n    pre_include=_OSX_PRE_INCLUDE,\n    post_include=_OSX_POST_INCLUDE,\n    libraries=_get_openssl_libraries(sys.platform),\n    extra_link_args=extra_link_args(sys.platform),\n)\n", "path": "src/_cffi_src/build_openssl.py"}]}