We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[package] libx264/20190605: build fail compiler.version setting required for vcvars not defined

### Package and Environment Details
  * Package Name/Version: **libx264/20190605**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Mingw GCC 8.1**
  * Docker image: **conanio/gcc8.1**
  * Conan version: **conan 1.21.0**
  * Python version: **Python 3.7.5**


### Conan profile
```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=14
compiler.exception=seh
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.version=8.1
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_CMAKE_GENERATOR=MinGW Makefiles
```

```
[requires]
libx264/20190605
```


### Steps to reproduce
Change `libx264/20190605@bincrafters/stable` to `libx264/20190605` build fail.
Failed in

```
ConanException: compiler.version setting required for vcvars not defined
```
Because of new `conanfile.py` without first determining whether it is `_is_msvc`.
In no `Visual Studio` environment, `tools.vcvars` due to the error.


### Fixed method
in line 94, change to:
```
    def build(self):
        if self._is_msvc:
            with tools.vcvars(self.settings):
                autotools = self._configure_autotools()
                autotools.make()
        else:
            autotools = self._configure_autotools()
            autotools.make()

    def package(self):
        if self._is_msvc:
            with tools.vcvars(self.settings):
                autotools = self._configure_autotools()
                autotools.install()
        else:
            autotools = self._configure_autotools()
            autotools.install()
        self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses')
        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
```


### Logs
<details><summary>Click to expand log</summary>

```
libx264/20190605: Applying build-requirement: nasm/2.14
libx264/20190605: Applying build-requirement: msys2/20190524
libx264/20190605: WARN: Build folder is dirty, removing it: C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
libx264/20190605: Copying sources to build folder
libx264/20190605: Building your package in C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
libx264/20190605: Generator txt created conanbuildinfo.txt
libx264/20190605: Calling build()
libx264/20190605: 
libx264/20190605: ERROR: Package '1a9b746db3232276ada4cf64b16512ba901fcf09' build failed
libx264/20190605: WARN: Build folder C:\Users\Home\.conan\data\libx264\20190605\_\_\build\1a9b746db3232276ada4cf64b16512ba901fcf09
ERROR: libx264/20190605: Error in build() method, line 95
	with tools.vcvars(self.settings):
	ConanException: compiler.version setting required for vcvars not defined

```

</details>


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `recipes/libx264/all/conanfile.py`
Content:
```
1 from conans import ConanFile, tools, AutoToolsBuildEnvironment
2 import os
3 
4 
5 class LibX264Conan(ConanFile):
6     name = "libx264"
7     url = "https://github.com/conan-io/conan-center-index"
8     homepage = "https://www.videolan.org/developers/x264.html"
9     description = "x264 is a free software library and application for encoding video streams into the " \
10                   "H.264/MPEG-4 AVC compression format"
11     topics = ("conan", "libx264", "video", "encoding")
12     license = "GPL-2.0"
13     settings = "os", "arch", "compiler", "build_type"
14     options = {"shared": [True, False], "fPIC": [True, False], "bit_depth": [8, 10, "all"]}
15     default_options = {'shared': False, 'fPIC': True, 'bit_depth': 'all'}
16     build_requires = "nasm/2.13.02"
17     _override_env = {}
18     _autotools = None
19 
20     @property
21     def _is_mingw(self):
22         return self.settings.os == "Windows" and self.settings.compiler == 'gcc'
23 
24     @property
25     def _is_msvc(self):
26         return self.settings.compiler == 'Visual Studio'
27 
28     @property
29     def _source_subfolder(self):
30         return "source_subfolder"
31 
32     def build_requirements(self):
33         if "CONAN_BASH_PATH" not in os.environ and tools.os_info.is_windows:
34             self.build_requires("msys2/20190524")
35 
36     def config_options(self):
37         if self.settings.os == 'Windows':
38             del self.options.fPIC
39 
40     def configure(self):
41         del self.settings.compiler.libcxx
42         del self.settings.compiler.cppstd
43 
44     def source(self):
45         tools.get(**self.conan_data["sources"][self.version])
46         extracted_dir = 'x264-snapshot-%s-2245' % self.version
47         os.rename(extracted_dir, self._source_subfolder)
48 
49     @property
50     def env(self):
51         ret = super(LibX264Conan, self).env
52         ret.update(self._override_env)
53         return ret
54 
55     def _configure_autotools(self):
56         if not self._autotools:
57             prefix = tools.unix_path(self.package_folder)
58             args = ['--disable-cli', '--prefix={}'.format(prefix)]
59             if self.options.shared:
60                 args.append('--enable-shared')
61             else:
62                 args.append('--enable-static')
63             if self.settings.os != 'Windows' and self.options.fPIC:
64                 args.append('--enable-pic')
65             if self.settings.build_type == 'Debug':
66                 args.append('--enable-debug')
67             args.append('--bit-depth=%s' % str(self.options.bit_depth))
68 
69             if tools.cross_building(self.settings):
70                 if self.settings.os == "Android":
71                     # the as of ndk does not work well for building libx264
72                     self._override_env["AS"] = os.environ["CC"]
73                     ndk_root = tools.unix_path(os.environ["NDK_ROOT"])
74                     arch = {'armv7': 'arm',
75                             'armv8': 'aarch64',
76                             'x86': 'i686',
77                             'x86_64': 'x86_64'}.get(str(self.settings.arch))
78                     abi = 'androideabi' if self.settings.arch == 'armv7' else 'android'
79                     cross_prefix = "%s/bin/%s-linux-%s-" % (ndk_root, arch, abi)
80                     args.append('--cross-prefix=%s' % cross_prefix)
81 
82             if self._is_msvc:
83                 self._override_env['CC'] = 'cl'
84             self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
85             if self._is_msvc:
86                 self._autotools.flags.append('-%s' % str(self.settings.compiler.runtime))
87                 # cannot open program database ... if multiple CL.EXE write to the same .PDB file, please use /FS
88                 self._autotools.flags.append('-FS')
89             self._autotools.configure(args=args, build=False, vars=self._override_env, configure_dir=self._source_subfolder)
90         return self._autotools
91 
92     def build(self):
93         with tools.vcvars(self.settings):
94             autotools = self._configure_autotools()
95             autotools.make()
96 
97     def package(self):
98         with tools.vcvars(self.settings):
99             autotools = self._configure_autotools()
100             autotools.install()
101         self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses')
102         tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
103 
104     def package_info(self):
105         if self._is_msvc:
106             self.cpp_info.libs = ['libx264.dll.lib' if self.options.shared else 'libx264']
107             if self.options.shared:
108                 self.cpp_info.defines.append("X264_API_IMPORTS")
109         elif self._is_mingw:
110             self.cpp_info.libs = ['x264.dll' if self.options.shared else 'x264']
111         else:
112             self.cpp_info.libs = ['x264']
113         if self.settings.os == "Linux":
114             self.cpp_info.system_libs.extend(['dl', 'pthread', 'm'])
115         elif self.settings.os == "Android":
116             self.cpp_info.system_libs.extend(['dl', 'm'])
117         self.cpp_info.names['pkg_config'] = 'x264'
118
```
--- 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()

```

diff --git a/recipes/libx264/all/conanfile.py b/recipes/libx264/all/conanfile.py
--- a/recipes/libx264/all/conanfile.py
+++ b/recipes/libx264/all/conanfile.py
@@ -90,12 +90,12 @@
         return self._autotools
 
     def build(self):
-        with tools.vcvars(self.settings):
+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
             autotools = self._configure_autotools()
             autotools.make()
 
     def package(self):
-        with tools.vcvars(self.settings):
+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
             autotools = self._configure_autotools()
             autotools.install()
         self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses')

{"golden_diff": "diff --git a/recipes/libx264/all/conanfile.py b/recipes/libx264/all/conanfile.py\n--- a/recipes/libx264/all/conanfile.py\n+++ b/recipes/libx264/all/conanfile.py\n@@ -90,12 +90,12 @@\n         return self._autotools\n \n     def build(self):\n-        with tools.vcvars(self.settings):\n+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():\n             autotools = self._configure_autotools()\n             autotools.make()\n \n     def package(self):\n-        with tools.vcvars(self.settings):\n+        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():\n             autotools = self._configure_autotools()\n             autotools.install()\n         self.copy(pattern=\"COPYING\", src=self._source_subfolder, dst='licenses')\n", "issue": "[package] libx264/20190605: build fail compiler.version setting required for vcvars not defined\n\r\n### Package and Environment Details\r\n  * Package Name/Version: **libx264/20190605**\r\n  * Operating System+version: **Windows 10**\r\n  * Compiler+version: **Mingw GCC 8.1**\r\n  * Docker image: **conanio/gcc8.1**\r\n  * Conan version: **conan 1.21.0**\r\n  * Python version: **Python 3.7.5**\r\n\r\n\r\n### Conan profile\r\n```\r\nConfiguration:\r\n[settings]\r\narch=x86_64\r\narch_build=x86_64\r\nbuild_type=Debug\r\ncompiler=gcc\r\ncompiler.cppstd=14\r\ncompiler.exception=seh\r\ncompiler.libcxx=libstdc++11\r\ncompiler.threads=posix\r\ncompiler.version=8.1\r\nos=Windows\r\nos_build=Windows\r\n[options]\r\n[build_requires]\r\n[env]\r\nCONAN_CMAKE_GENERATOR=MinGW Makefiles\r\n```\r\n\r\n```\r\n[requires]\r\nlibx264/20190605\r\n```\r\n\r\n\r\n### Steps to reproduce\r\nChange `libx264/20190605@bincrafters/stable` to `libx264/20190605` build fail.\r\nFailed in\r\n\r\n```\r\nConanException: compiler.version setting required for vcvars not defined\r\n```\r\nBecause of new `conanfile.py` without first determining whether it is `_is_msvc`.\r\nIn no `Visual Studio` environment, `tools.vcvars` due to the error.\r\n\r\n\r\n### Fixed method\r\nin line 94, change to:\r\n```\r\n    def build(self):\r\n        if self._is_msvc:\r\n            with tools.vcvars(self.settings):\r\n                autotools = self._configure_autotools()\r\n                autotools.make()\r\n        else:\r\n            autotools = self._configure_autotools()\r\n            autotools.make()\r\n\r\n    def package(self):\r\n        if self._is_msvc:\r\n            with tools.vcvars(self.settings):\r\n                autotools = self._configure_autotools()\r\n                autotools.install()\r\n        else:\r\n            autotools = self._configure_autotools()\r\n            autotools.install()\r\n        self.copy(pattern=\"COPYING\", src=self._source_subfolder, dst='licenses')\r\n        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))\r\n```\r\n\r\n\r\n### Logs\r\n<details><summary>Click to expand log</summary>\r\n\r\n```\r\nlibx264/20190605: Applying build-requirement: nasm/2.14\r\nlibx264/20190605: Applying build-requirement: msys2/20190524\r\nlibx264/20190605: WARN: Build folder is dirty, removing it: C:\\Users\\Home\\.conan\\data\\libx264\\20190605\\_\\_\\build\\1a9b746db3232276ada4cf64b16512ba901fcf09\r\nlibx264/20190605: Copying sources to build folder\r\nlibx264/20190605: Building your package in C:\\Users\\Home\\.conan\\data\\libx264\\20190605\\_\\_\\build\\1a9b746db3232276ada4cf64b16512ba901fcf09\r\nlibx264/20190605: Generator txt created conanbuildinfo.txt\r\nlibx264/20190605: Calling build()\r\nlibx264/20190605: \r\nlibx264/20190605: ERROR: Package '1a9b746db3232276ada4cf64b16512ba901fcf09' build failed\r\nlibx264/20190605: WARN: Build folder C:\\Users\\Home\\.conan\\data\\libx264\\20190605\\_\\_\\build\\1a9b746db3232276ada4cf64b16512ba901fcf09\r\nERROR: libx264/20190605: Error in build() method, line 95\r\n\twith tools.vcvars(self.settings):\r\n\tConanException: compiler.version setting required for vcvars not defined\r\n\r\n```\r\n\r\n</details>\r\n\n", "before_files": [{"content": "from conans import ConanFile, tools, AutoToolsBuildEnvironment\nimport os\n\n\nclass LibX264Conan(ConanFile):\n    name = \"libx264\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://www.videolan.org/developers/x264.html\"\n    description = \"x264 is a free software library and application for encoding video streams into the \" \\\n                  \"H.264/MPEG-4 AVC compression format\"\n    topics = (\"conan\", \"libx264\", \"video\", \"encoding\")\n    license = \"GPL-2.0\"\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\"shared\": [True, False], \"fPIC\": [True, False], \"bit_depth\": [8, 10, \"all\"]}\n    default_options = {'shared': False, 'fPIC': True, 'bit_depth': 'all'}\n    build_requires = \"nasm/2.13.02\"\n    _override_env = {}\n    _autotools = None\n\n    @property\n    def _is_mingw(self):\n        return self.settings.os == \"Windows\" and self.settings.compiler == 'gcc'\n\n    @property\n    def _is_msvc(self):\n        return self.settings.compiler == 'Visual Studio'\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    def build_requirements(self):\n        if \"CONAN_BASH_PATH\" not in os.environ and tools.os_info.is_windows:\n            self.build_requires(\"msys2/20190524\")\n\n    def config_options(self):\n        if self.settings.os == 'Windows':\n            del self.options.fPIC\n\n    def configure(self):\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version])\n        extracted_dir = 'x264-snapshot-%s-2245' % self.version\n        os.rename(extracted_dir, self._source_subfolder)\n\n    @property\n    def env(self):\n        ret = super(LibX264Conan, self).env\n        ret.update(self._override_env)\n        return ret\n\n    def _configure_autotools(self):\n        if not self._autotools:\n            prefix = tools.unix_path(self.package_folder)\n            args = ['--disable-cli', '--prefix={}'.format(prefix)]\n            if self.options.shared:\n                args.append('--enable-shared')\n            else:\n                args.append('--enable-static')\n            if self.settings.os != 'Windows' and self.options.fPIC:\n                args.append('--enable-pic')\n            if self.settings.build_type == 'Debug':\n                args.append('--enable-debug')\n            args.append('--bit-depth=%s' % str(self.options.bit_depth))\n\n            if tools.cross_building(self.settings):\n                if self.settings.os == \"Android\":\n                    # the as of ndk does not work well for building libx264\n                    self._override_env[\"AS\"] = os.environ[\"CC\"]\n                    ndk_root = tools.unix_path(os.environ[\"NDK_ROOT\"])\n                    arch = {'armv7': 'arm',\n                            'armv8': 'aarch64',\n                            'x86': 'i686',\n                            'x86_64': 'x86_64'}.get(str(self.settings.arch))\n                    abi = 'androideabi' if self.settings.arch == 'armv7' else 'android'\n                    cross_prefix = \"%s/bin/%s-linux-%s-\" % (ndk_root, arch, abi)\n                    args.append('--cross-prefix=%s' % cross_prefix)\n\n            if self._is_msvc:\n                self._override_env['CC'] = 'cl'\n            self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)\n            if self._is_msvc:\n                self._autotools.flags.append('-%s' % str(self.settings.compiler.runtime))\n                # cannot open program database ... if multiple CL.EXE write to the same .PDB file, please use /FS\n                self._autotools.flags.append('-FS')\n            self._autotools.configure(args=args, build=False, vars=self._override_env, configure_dir=self._source_subfolder)\n        return self._autotools\n\n    def build(self):\n        with tools.vcvars(self.settings):\n            autotools = self._configure_autotools()\n            autotools.make()\n\n    def package(self):\n        with tools.vcvars(self.settings):\n            autotools = self._configure_autotools()\n            autotools.install()\n        self.copy(pattern=\"COPYING\", src=self._source_subfolder, dst='licenses')\n        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))\n\n    def package_info(self):\n        if self._is_msvc:\n            self.cpp_info.libs = ['libx264.dll.lib' if self.options.shared else 'libx264']\n            if self.options.shared:\n                self.cpp_info.defines.append(\"X264_API_IMPORTS\")\n        elif self._is_mingw:\n            self.cpp_info.libs = ['x264.dll' if self.options.shared else 'x264']\n        else:\n            self.cpp_info.libs = ['x264']\n        if self.settings.os == \"Linux\":\n            self.cpp_info.system_libs.extend(['dl', 'pthread', 'm'])\n        elif self.settings.os == \"Android\":\n            self.cpp_info.system_libs.extend(['dl', 'm'])\n        self.cpp_info.names['pkg_config'] = 'x264'\n", "path": "recipes/libx264/all/conanfile.py"}], "after_files": [{"content": "from conans import ConanFile, tools, AutoToolsBuildEnvironment\nimport os\n\n\nclass LibX264Conan(ConanFile):\n    name = \"libx264\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://www.videolan.org/developers/x264.html\"\n    description = \"x264 is a free software library and application for encoding video streams into the \" \\\n                  \"H.264/MPEG-4 AVC compression format\"\n    topics = (\"conan\", \"libx264\", \"video\", \"encoding\")\n    license = \"GPL-2.0\"\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\"shared\": [True, False], \"fPIC\": [True, False], \"bit_depth\": [8, 10, \"all\"]}\n    default_options = {'shared': False, 'fPIC': True, 'bit_depth': 'all'}\n    build_requires = \"nasm/2.13.02\"\n    _override_env = {}\n    _autotools = None\n\n    @property\n    def _is_mingw(self):\n        return self.settings.os == \"Windows\" and self.settings.compiler == 'gcc'\n\n    @property\n    def _is_msvc(self):\n        return self.settings.compiler == 'Visual Studio'\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    def build_requirements(self):\n        if \"CONAN_BASH_PATH\" not in os.environ and tools.os_info.is_windows:\n            self.build_requires(\"msys2/20190524\")\n\n    def config_options(self):\n        if self.settings.os == 'Windows':\n            del self.options.fPIC\n\n    def configure(self):\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version])\n        extracted_dir = 'x264-snapshot-%s-2245' % self.version\n        os.rename(extracted_dir, self._source_subfolder)\n\n    @property\n    def env(self):\n        ret = super(LibX264Conan, self).env\n        ret.update(self._override_env)\n        return ret\n\n    def _configure_autotools(self):\n        if not self._autotools:\n            prefix = tools.unix_path(self.package_folder)\n            args = ['--disable-cli', '--prefix={}'.format(prefix)]\n            if self.options.shared:\n                args.append('--enable-shared')\n            else:\n                args.append('--enable-static')\n            if self.settings.os != 'Windows' and self.options.fPIC:\n                args.append('--enable-pic')\n            if self.settings.build_type == 'Debug':\n                args.append('--enable-debug')\n            args.append('--bit-depth=%s' % str(self.options.bit_depth))\n\n            if tools.cross_building(self.settings):\n                if self.settings.os == \"Android\":\n                    # the as of ndk does not work well for building libx264\n                    self._override_env[\"AS\"] = os.environ[\"CC\"]\n                    ndk_root = tools.unix_path(os.environ[\"NDK_ROOT\"])\n                    arch = {'armv7': 'arm',\n                            'armv8': 'aarch64',\n                            'x86': 'i686',\n                            'x86_64': 'x86_64'}.get(str(self.settings.arch))\n                    abi = 'androideabi' if self.settings.arch == 'armv7' else 'android'\n                    cross_prefix = \"%s/bin/%s-linux-%s-\" % (ndk_root, arch, abi)\n                    args.append('--cross-prefix=%s' % cross_prefix)\n\n            if self._is_msvc:\n                self._override_env['CC'] = 'cl'\n            self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)\n            if self._is_msvc:\n                self._autotools.flags.append('-%s' % str(self.settings.compiler.runtime))\n                # cannot open program database ... if multiple CL.EXE write to the same .PDB file, please use /FS\n                self._autotools.flags.append('-FS')\n            self._autotools.configure(args=args, build=False, vars=self._override_env, configure_dir=self._source_subfolder)\n        return self._autotools\n\n    def build(self):\n        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():\n            autotools = self._configure_autotools()\n            autotools.make()\n\n    def package(self):\n        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():\n            autotools = self._configure_autotools()\n            autotools.install()\n        self.copy(pattern=\"COPYING\", src=self._source_subfolder, dst='licenses')\n        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))\n\n    def package_info(self):\n        if self._is_msvc:\n            self.cpp_info.libs = ['libx264.dll.lib' if self.options.shared else 'libx264']\n            if self.options.shared:\n                self.cpp_info.defines.append(\"X264_API_IMPORTS\")\n        elif self._is_mingw:\n            self.cpp_info.libs = ['x264.dll' if self.options.shared else 'x264']\n        else:\n            self.cpp_info.libs = ['x264']\n        if self.settings.os == \"Linux\":\n            self.cpp_info.system_libs.extend(['dl', 'pthread', 'm'])\n        elif self.settings.os == \"Android\":\n            self.cpp_info.system_libs.extend(['dl', 'm'])\n        self.cpp_info.names['pkg_config'] = 'x264'\n", "path": "recipes/libx264/all/conanfile.py"}]}