We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Fix test_sdists test farm test
`tests/letstest/scripts/test_sdists.sh` which we currently run as part of the release process is now failing. I think this should be fixed quickly so it doesn't cause us problems whenever we go to do our next release. The cause of the failure is that newer versions of `pytest` cannot be installed using old versions of `setuptools`.

To resolve this, we either need to use a newer version of `setuptools` or an older version of `pytest`. My thought is to upgrade `setuptools` because it should prevent problems with other packages in the future and our tests should arguably work with the latest version of every package installed, however, either approach should work.

If we upgrade `setuptools`, we need to decide where to do it. My thought would be to do it somewhere in `tools/_venv_common.py` or the scripts it calls so other code that uses `tools/_venv_common.py` would benefit. (It also looks like `tests/letstest/scripts/test_sdists.sh` still uses the old name `tools/_venv_common.sh` and needs to be updated.) `setuptools>=30.3` seems to be [required](https://github.com/pytest-dev/pytest/commit/d4351ac5a287eb96521f09618bbbe1c73f4e6884#diff-2eeaed663bd0d25b7e608891384b7298).

If we decided to pin back `pytest` (and maybe other packages) instead, I don't have an opinion on the approach.

@ohemorange or @sydneyli, are you interested in taking this? I initially planned on doing it myself but haven't managed to get to it yet and think it's important. It shouldn't be much work.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tools/_venv_common.py`
Content:
```
1 #!/usr/bin/env python
2 """Aids in creating a developer virtual environment for Certbot.
3 
4 When this module is run as a script, it takes the arguments that should
5 be passed to pip to install the Certbot packages as command line
6 arguments. The virtual environment will be created with the name "venv"
7 in the current working directory and will use the default version of
8 Python for the virtualenv executable in your PATH. You can change the
9 name of the virtual environment by setting the environment variable
10 VENV_NAME.
11 """
12 
13 from __future__ import print_function
14 
15 import os
16 import shutil
17 import glob
18 import time
19 import subprocess
20 import sys
21 import re
22 import shlex
23 
24 VERSION_PATTERN = re.compile(r'^(\d+)\.(\d+).*$')
25 
26 
27 class PythonExecutableNotFoundError(Exception):
28     pass
29 
30 
31 def find_python_executable(python_major):
32     # type: (int) -> str
33     """
34     Find the relevant python executable that is of the given python major version.
35     Will test, in decreasing priority order:
36     * the current Python interpreter
37     * 'pythonX' executable in PATH (with X the given major version) if available
38     * 'python' executable in PATH if available
39     * Windows Python launcher 'py' executable in PATH if available
40     Incompatible python versions for Certbot will be evicted (eg. Python < 3.5 on Windows)
41     :param int python_major: the Python major version to target (2 or 3)
42     :rtype: str
43     :return: the relevant python executable path
44     :raise RuntimeError: if no relevant python executable path could be found
45     """
46     python_executable_path = None
47 
48     # First try, current python executable
49     if _check_version('{0}.{1}.{2}'.format(
50             sys.version_info[0], sys.version_info[1], sys.version_info[2]), python_major):
51         return sys.executable
52 
53     # Second try, with python executables in path
54     versions_to_test = ['2.7', '2', ''] if python_major == 2 else ['3', '']
55     for one_version in versions_to_test:
56         try:
57             one_python = 'python{0}'.format(one_version)
58             output = subprocess.check_output([one_python, '--version'],
59                                              universal_newlines=True, stderr=subprocess.STDOUT)
60             if _check_version(output.strip().split()[1], python_major):
61                 return subprocess.check_output([one_python, '-c',
62                                                 'import sys; sys.stdout.write(sys.executable);'],
63                                                universal_newlines=True)
64         except (subprocess.CalledProcessError, OSError):
65             pass
66 
67     # Last try, with Windows Python launcher
68     try:
69         env_arg = '-{0}'.format(python_major)
70         output_version = subprocess.check_output(['py', env_arg, '--version'],
71                                                  universal_newlines=True, stderr=subprocess.STDOUT)
72         if _check_version(output_version.strip().split()[1], python_major):
73             return subprocess.check_output(['py', env_arg, '-c',
74                                             'import sys; sys.stdout.write(sys.executable);'],
75                                            universal_newlines=True)
76     except (subprocess.CalledProcessError, OSError):
77         pass
78 
79     if not python_executable_path:
80         raise RuntimeError('Error, no compatible Python {0} executable for Certbot could be found.'
81                            .format(python_major))
82 
83 
84 def _check_version(version_str, major_version):
85     search = VERSION_PATTERN.search(version_str)
86 
87     if not search:
88         return False
89 
90     version = (int(search.group(1)), int(search.group(2)))
91 
92     minimal_version_supported = (2, 7)
93     if major_version == 3 and os.name == 'nt':
94         minimal_version_supported = (3, 5)
95     elif major_version == 3:
96         minimal_version_supported = (3, 4)
97 
98     if version >= minimal_version_supported:
99         return True
100 
101     print('Incompatible python version for Certbot found: {0}'.format(version_str))
102     return False
103 
104 
105 def subprocess_with_print(cmd, env=os.environ, shell=False):
106     print('+ {0}'.format(subprocess.list2cmdline(cmd)) if isinstance(cmd, list) else cmd)
107     subprocess.check_call(cmd, env=env, shell=shell)
108 
109 
110 def get_venv_bin_path(venv_path):
111     python_linux = os.path.join(venv_path, 'bin/python')
112     if os.path.isfile(python_linux):
113         return os.path.abspath(os.path.dirname(python_linux))
114     python_windows = os.path.join(venv_path, 'Scripts\\python.exe')
115     if os.path.isfile(python_windows):
116         return os.path.abspath(os.path.dirname(python_windows))
117 
118     raise ValueError((
119         'Error, could not find python executable in venv path {0}: is it a valid venv ?'
120         .format(venv_path)))
121 
122 
123 def main(venv_name, venv_args, args):
124     """Creates a virtual environment and installs packages.
125 
126     :param str venv_name: The name or path at where the virtual
127         environment should be created.
128     :param str venv_args: Command line arguments for virtualenv
129     :param str args: Command line arguments that should be given to pip
130         to install packages
131     """
132 
133     for path in glob.glob('*.egg-info'):
134         if os.path.isdir(path):
135             shutil.rmtree(path)
136         else:
137             os.remove(path)
138 
139     env_venv_name = os.environ.get('VENV_NAME')
140     if env_venv_name:
141         print('Creating venv at {0}'
142               ' as specified in VENV_NAME'.format(env_venv_name))
143         venv_name = env_venv_name
144 
145     if os.path.isdir(venv_name):
146         os.rename(venv_name, '{0}.{1}.bak'.format(venv_name, int(time.time())))
147 
148     command = [sys.executable, '-m', 'virtualenv', '--no-site-packages', '--setuptools', venv_name]
149     command.extend(shlex.split(venv_args))
150     subprocess_with_print(command)
151 
152     # We execute the two following commands in the context of the virtual environment, to install
153     # the packages in it. To do so, we append the venv binary to the PATH that will be used for
154     # these commands. With this trick, correct python executable will be selected.
155     new_environ = os.environ.copy()
156     new_environ['PATH'] = os.pathsep.join([get_venv_bin_path(venv_name), new_environ['PATH']])
157     subprocess_with_print('python {0}'.format('./letsencrypt-auto-source/pieces/pipstrap.py'),
158                           env=new_environ, shell=True)
159     subprocess_with_print('python {0} {1}'.format('./tools/pip_install.py', ' '.join(args)),
160                           env=new_environ, shell=True)
161 
162     if os.path.isdir(os.path.join(venv_name, 'bin')):
163         # Linux/OSX specific
164         print('-------------------------------------------------------------------')
165         print('Please run the following command to activate developer environment:')
166         print('source {0}/bin/activate'.format(venv_name))
167         print('-------------------------------------------------------------------')
168     elif os.path.isdir(os.path.join(venv_name, 'Scripts')):
169         # Windows specific
170         print('---------------------------------------------------------------------------')
171         print('Please run one of the following commands to activate developer environment:')
172         print('{0}\\Scripts\\activate.bat (for Batch)'.format(venv_name))
173         print('.\\{0}\\Scripts\\Activate.ps1 (for Powershell)'.format(venv_name))
174         print('---------------------------------------------------------------------------')
175     else:
176         raise ValueError('Error, directory {0} is not a valid venv.'.format(venv_name))
177 
178 
179 if __name__ == '__main__':
180     main('venv',
181          '',
182          sys.argv[1:])
183
```
--- 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/tools/_venv_common.py b/tools/_venv_common.py
--- a/tools/_venv_common.py
+++ b/tools/_venv_common.py
@@ -149,13 +149,15 @@
     command.extend(shlex.split(venv_args))
     subprocess_with_print(command)
 
-    # We execute the two following commands in the context of the virtual environment, to install
+    # We execute the following commands in the context of the virtual environment, to install
     # the packages in it. To do so, we append the venv binary to the PATH that will be used for
     # these commands. With this trick, correct python executable will be selected.
     new_environ = os.environ.copy()
     new_environ['PATH'] = os.pathsep.join([get_venv_bin_path(venv_name), new_environ['PATH']])
     subprocess_with_print('python {0}'.format('./letsencrypt-auto-source/pieces/pipstrap.py'),
                           env=new_environ, shell=True)
+    subprocess_with_print("python -m pip install --upgrade 'setuptools>=30.3'",
+                          env=new_environ, shell=True)
     subprocess_with_print('python {0} {1}'.format('./tools/pip_install.py', ' '.join(args)),
                           env=new_environ, shell=True)

{"golden_diff": "diff --git a/tools/_venv_common.py b/tools/_venv_common.py\n--- a/tools/_venv_common.py\n+++ b/tools/_venv_common.py\n@@ -149,13 +149,15 @@\n     command.extend(shlex.split(venv_args))\n     subprocess_with_print(command)\n \n-    # We execute the two following commands in the context of the virtual environment, to install\n+    # We execute the following commands in the context of the virtual environment, to install\n     # the packages in it. To do so, we append the venv binary to the PATH that will be used for\n     # these commands. With this trick, correct python executable will be selected.\n     new_environ = os.environ.copy()\n     new_environ['PATH'] = os.pathsep.join([get_venv_bin_path(venv_name), new_environ['PATH']])\n     subprocess_with_print('python {0}'.format('./letsencrypt-auto-source/pieces/pipstrap.py'),\n                           env=new_environ, shell=True)\n+    subprocess_with_print(\"python -m pip install --upgrade 'setuptools>=30.3'\",\n+                          env=new_environ, shell=True)\n     subprocess_with_print('python {0} {1}'.format('./tools/pip_install.py', ' '.join(args)),\n                           env=new_environ, shell=True)\n", "issue": "Fix test_sdists test farm test\n`tests/letstest/scripts/test_sdists.sh` which we currently run as part of the release process is now failing. I think this should be fixed quickly so it doesn't cause us problems whenever we go to do our next release. The cause of the failure is that newer versions of `pytest` cannot be installed using old versions of `setuptools`.\r\n\r\nTo resolve this, we either need to use a newer version of `setuptools` or an older version of `pytest`. My thought is to upgrade `setuptools` because it should prevent problems with other packages in the future and our tests should arguably work with the latest version of every package installed, however, either approach should work.\r\n\r\nIf we upgrade `setuptools`, we need to decide where to do it. My thought would be to do it somewhere in `tools/_venv_common.py` or the scripts it calls so other code that uses `tools/_venv_common.py` would benefit. (It also looks like `tests/letstest/scripts/test_sdists.sh` still uses the old name `tools/_venv_common.sh` and needs to be updated.) `setuptools>=30.3` seems to be [required](https://github.com/pytest-dev/pytest/commit/d4351ac5a287eb96521f09618bbbe1c73f4e6884#diff-2eeaed663bd0d25b7e608891384b7298).\r\n\r\nIf we decided to pin back `pytest` (and maybe other packages) instead, I don't have an opinion on the approach.\r\n\r\n@ohemorange or @sydneyli, are you interested in taking this? I initially planned on doing it myself but haven't managed to get to it yet and think it's important. It shouldn't be much work.\n", "before_files": [{"content": "#!/usr/bin/env python\n\"\"\"Aids in creating a developer virtual environment for Certbot.\n\nWhen this module is run as a script, it takes the arguments that should\nbe passed to pip to install the Certbot packages as command line\narguments. The virtual environment will be created with the name \"venv\"\nin the current working directory and will use the default version of\nPython for the virtualenv executable in your PATH. You can change the\nname of the virtual environment by setting the environment variable\nVENV_NAME.\n\"\"\"\n\nfrom __future__ import print_function\n\nimport os\nimport shutil\nimport glob\nimport time\nimport subprocess\nimport sys\nimport re\nimport shlex\n\nVERSION_PATTERN = re.compile(r'^(\\d+)\\.(\\d+).*$')\n\n\nclass PythonExecutableNotFoundError(Exception):\n    pass\n\n\ndef find_python_executable(python_major):\n    # type: (int) -> str\n    \"\"\"\n    Find the relevant python executable that is of the given python major version.\n    Will test, in decreasing priority order:\n    * the current Python interpreter\n    * 'pythonX' executable in PATH (with X the given major version) if available\n    * 'python' executable in PATH if available\n    * Windows Python launcher 'py' executable in PATH if available\n    Incompatible python versions for Certbot will be evicted (eg. Python < 3.5 on Windows)\n    :param int python_major: the Python major version to target (2 or 3)\n    :rtype: str\n    :return: the relevant python executable path\n    :raise RuntimeError: if no relevant python executable path could be found\n    \"\"\"\n    python_executable_path = None\n\n    # First try, current python executable\n    if _check_version('{0}.{1}.{2}'.format(\n            sys.version_info[0], sys.version_info[1], sys.version_info[2]), python_major):\n        return sys.executable\n\n    # Second try, with python executables in path\n    versions_to_test = ['2.7', '2', ''] if python_major == 2 else ['3', '']\n    for one_version in versions_to_test:\n        try:\n            one_python = 'python{0}'.format(one_version)\n            output = subprocess.check_output([one_python, '--version'],\n                                             universal_newlines=True, stderr=subprocess.STDOUT)\n            if _check_version(output.strip().split()[1], python_major):\n                return subprocess.check_output([one_python, '-c',\n                                                'import sys; sys.stdout.write(sys.executable);'],\n                                               universal_newlines=True)\n        except (subprocess.CalledProcessError, OSError):\n            pass\n\n    # Last try, with Windows Python launcher\n    try:\n        env_arg = '-{0}'.format(python_major)\n        output_version = subprocess.check_output(['py', env_arg, '--version'],\n                                                 universal_newlines=True, stderr=subprocess.STDOUT)\n        if _check_version(output_version.strip().split()[1], python_major):\n            return subprocess.check_output(['py', env_arg, '-c',\n                                            'import sys; sys.stdout.write(sys.executable);'],\n                                           universal_newlines=True)\n    except (subprocess.CalledProcessError, OSError):\n        pass\n\n    if not python_executable_path:\n        raise RuntimeError('Error, no compatible Python {0} executable for Certbot could be found.'\n                           .format(python_major))\n\n\ndef _check_version(version_str, major_version):\n    search = VERSION_PATTERN.search(version_str)\n\n    if not search:\n        return False\n\n    version = (int(search.group(1)), int(search.group(2)))\n\n    minimal_version_supported = (2, 7)\n    if major_version == 3 and os.name == 'nt':\n        minimal_version_supported = (3, 5)\n    elif major_version == 3:\n        minimal_version_supported = (3, 4)\n\n    if version >= minimal_version_supported:\n        return True\n\n    print('Incompatible python version for Certbot found: {0}'.format(version_str))\n    return False\n\n\ndef subprocess_with_print(cmd, env=os.environ, shell=False):\n    print('+ {0}'.format(subprocess.list2cmdline(cmd)) if isinstance(cmd, list) else cmd)\n    subprocess.check_call(cmd, env=env, shell=shell)\n\n\ndef get_venv_bin_path(venv_path):\n    python_linux = os.path.join(venv_path, 'bin/python')\n    if os.path.isfile(python_linux):\n        return os.path.abspath(os.path.dirname(python_linux))\n    python_windows = os.path.join(venv_path, 'Scripts\\\\python.exe')\n    if os.path.isfile(python_windows):\n        return os.path.abspath(os.path.dirname(python_windows))\n\n    raise ValueError((\n        'Error, could not find python executable in venv path {0}: is it a valid venv ?'\n        .format(venv_path)))\n\n\ndef main(venv_name, venv_args, args):\n    \"\"\"Creates a virtual environment and installs packages.\n\n    :param str venv_name: The name or path at where the virtual\n        environment should be created.\n    :param str venv_args: Command line arguments for virtualenv\n    :param str args: Command line arguments that should be given to pip\n        to install packages\n    \"\"\"\n\n    for path in glob.glob('*.egg-info'):\n        if os.path.isdir(path):\n            shutil.rmtree(path)\n        else:\n            os.remove(path)\n\n    env_venv_name = os.environ.get('VENV_NAME')\n    if env_venv_name:\n        print('Creating venv at {0}'\n              ' as specified in VENV_NAME'.format(env_venv_name))\n        venv_name = env_venv_name\n\n    if os.path.isdir(venv_name):\n        os.rename(venv_name, '{0}.{1}.bak'.format(venv_name, int(time.time())))\n\n    command = [sys.executable, '-m', 'virtualenv', '--no-site-packages', '--setuptools', venv_name]\n    command.extend(shlex.split(venv_args))\n    subprocess_with_print(command)\n\n    # We execute the two following commands in the context of the virtual environment, to install\n    # the packages in it. To do so, we append the venv binary to the PATH that will be used for\n    # these commands. With this trick, correct python executable will be selected.\n    new_environ = os.environ.copy()\n    new_environ['PATH'] = os.pathsep.join([get_venv_bin_path(venv_name), new_environ['PATH']])\n    subprocess_with_print('python {0}'.format('./letsencrypt-auto-source/pieces/pipstrap.py'),\n                          env=new_environ, shell=True)\n    subprocess_with_print('python {0} {1}'.format('./tools/pip_install.py', ' '.join(args)),\n                          env=new_environ, shell=True)\n\n    if os.path.isdir(os.path.join(venv_name, 'bin')):\n        # Linux/OSX specific\n        print('-------------------------------------------------------------------')\n        print('Please run the following command to activate developer environment:')\n        print('source {0}/bin/activate'.format(venv_name))\n        print('-------------------------------------------------------------------')\n    elif os.path.isdir(os.path.join(venv_name, 'Scripts')):\n        # Windows specific\n        print('---------------------------------------------------------------------------')\n        print('Please run one of the following commands to activate developer environment:')\n        print('{0}\\\\Scripts\\\\activate.bat (for Batch)'.format(venv_name))\n        print('.\\\\{0}\\\\Scripts\\\\Activate.ps1 (for Powershell)'.format(venv_name))\n        print('---------------------------------------------------------------------------')\n    else:\n        raise ValueError('Error, directory {0} is not a valid venv.'.format(venv_name))\n\n\nif __name__ == '__main__':\n    main('venv',\n         '',\n         sys.argv[1:])\n", "path": "tools/_venv_common.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\"\"\"Aids in creating a developer virtual environment for Certbot.\n\nWhen this module is run as a script, it takes the arguments that should\nbe passed to pip to install the Certbot packages as command line\narguments. The virtual environment will be created with the name \"venv\"\nin the current working directory and will use the default version of\nPython for the virtualenv executable in your PATH. You can change the\nname of the virtual environment by setting the environment variable\nVENV_NAME.\n\"\"\"\n\nfrom __future__ import print_function\n\nimport os\nimport shutil\nimport glob\nimport time\nimport subprocess\nimport sys\nimport re\nimport shlex\n\nVERSION_PATTERN = re.compile(r'^(\\d+)\\.(\\d+).*$')\n\n\nclass PythonExecutableNotFoundError(Exception):\n    pass\n\n\ndef find_python_executable(python_major):\n    # type: (int) -> str\n    \"\"\"\n    Find the relevant python executable that is of the given python major version.\n    Will test, in decreasing priority order:\n    * the current Python interpreter\n    * 'pythonX' executable in PATH (with X the given major version) if available\n    * 'python' executable in PATH if available\n    * Windows Python launcher 'py' executable in PATH if available\n    Incompatible python versions for Certbot will be evicted (eg. Python < 3.5 on Windows)\n    :param int python_major: the Python major version to target (2 or 3)\n    :rtype: str\n    :return: the relevant python executable path\n    :raise RuntimeError: if no relevant python executable path could be found\n    \"\"\"\n    python_executable_path = None\n\n    # First try, current python executable\n    if _check_version('{0}.{1}.{2}'.format(\n            sys.version_info[0], sys.version_info[1], sys.version_info[2]), python_major):\n        return sys.executable\n\n    # Second try, with python executables in path\n    versions_to_test = ['2.7', '2', ''] if python_major == 2 else ['3', '']\n    for one_version in versions_to_test:\n        try:\n            one_python = 'python{0}'.format(one_version)\n            output = subprocess.check_output([one_python, '--version'],\n                                             universal_newlines=True, stderr=subprocess.STDOUT)\n            if _check_version(output.strip().split()[1], python_major):\n                return subprocess.check_output([one_python, '-c',\n                                                'import sys; sys.stdout.write(sys.executable);'],\n                                               universal_newlines=True)\n        except (subprocess.CalledProcessError, OSError):\n            pass\n\n    # Last try, with Windows Python launcher\n    try:\n        env_arg = '-{0}'.format(python_major)\n        output_version = subprocess.check_output(['py', env_arg, '--version'],\n                                                 universal_newlines=True, stderr=subprocess.STDOUT)\n        if _check_version(output_version.strip().split()[1], python_major):\n            return subprocess.check_output(['py', env_arg, '-c',\n                                            'import sys; sys.stdout.write(sys.executable);'],\n                                           universal_newlines=True)\n    except (subprocess.CalledProcessError, OSError):\n        pass\n\n    if not python_executable_path:\n        raise RuntimeError('Error, no compatible Python {0} executable for Certbot could be found.'\n                           .format(python_major))\n\n\ndef _check_version(version_str, major_version):\n    search = VERSION_PATTERN.search(version_str)\n\n    if not search:\n        return False\n\n    version = (int(search.group(1)), int(search.group(2)))\n\n    minimal_version_supported = (2, 7)\n    if major_version == 3 and os.name == 'nt':\n        minimal_version_supported = (3, 5)\n    elif major_version == 3:\n        minimal_version_supported = (3, 4)\n\n    if version >= minimal_version_supported:\n        return True\n\n    print('Incompatible python version for Certbot found: {0}'.format(version_str))\n    return False\n\n\ndef subprocess_with_print(cmd, env=os.environ, shell=False):\n    print('+ {0}'.format(subprocess.list2cmdline(cmd)) if isinstance(cmd, list) else cmd)\n    subprocess.check_call(cmd, env=env, shell=shell)\n\n\ndef get_venv_bin_path(venv_path):\n    python_linux = os.path.join(venv_path, 'bin/python')\n    if os.path.isfile(python_linux):\n        return os.path.abspath(os.path.dirname(python_linux))\n    python_windows = os.path.join(venv_path, 'Scripts\\\\python.exe')\n    if os.path.isfile(python_windows):\n        return os.path.abspath(os.path.dirname(python_windows))\n\n    raise ValueError((\n        'Error, could not find python executable in venv path {0}: is it a valid venv ?'\n        .format(venv_path)))\n\n\ndef main(venv_name, venv_args, args):\n    \"\"\"Creates a virtual environment and installs packages.\n\n    :param str venv_name: The name or path at where the virtual\n        environment should be created.\n    :param str venv_args: Command line arguments for virtualenv\n    :param str args: Command line arguments that should be given to pip\n        to install packages\n    \"\"\"\n\n    for path in glob.glob('*.egg-info'):\n        if os.path.isdir(path):\n            shutil.rmtree(path)\n        else:\n            os.remove(path)\n\n    env_venv_name = os.environ.get('VENV_NAME')\n    if env_venv_name:\n        print('Creating venv at {0}'\n              ' as specified in VENV_NAME'.format(env_venv_name))\n        venv_name = env_venv_name\n\n    if os.path.isdir(venv_name):\n        os.rename(venv_name, '{0}.{1}.bak'.format(venv_name, int(time.time())))\n\n    command = [sys.executable, '-m', 'virtualenv', '--no-site-packages', '--setuptools', venv_name]\n    command.extend(shlex.split(venv_args))\n    subprocess_with_print(command)\n\n    # We execute the following commands in the context of the virtual environment, to install\n    # the packages in it. To do so, we append the venv binary to the PATH that will be used for\n    # these commands. With this trick, correct python executable will be selected.\n    new_environ = os.environ.copy()\n    new_environ['PATH'] = os.pathsep.join([get_venv_bin_path(venv_name), new_environ['PATH']])\n    subprocess_with_print('python {0}'.format('./letsencrypt-auto-source/pieces/pipstrap.py'),\n                          env=new_environ, shell=True)\n    subprocess_with_print(\"python -m pip install --upgrade 'setuptools>=30.3'\",\n                          env=new_environ, shell=True)\n    subprocess_with_print('python {0} {1}'.format('./tools/pip_install.py', ' '.join(args)),\n                          env=new_environ, shell=True)\n\n    if os.path.isdir(os.path.join(venv_name, 'bin')):\n        # Linux/OSX specific\n        print('-------------------------------------------------------------------')\n        print('Please run the following command to activate developer environment:')\n        print('source {0}/bin/activate'.format(venv_name))\n        print('-------------------------------------------------------------------')\n    elif os.path.isdir(os.path.join(venv_name, 'Scripts')):\n        # Windows specific\n        print('---------------------------------------------------------------------------')\n        print('Please run one of the following commands to activate developer environment:')\n        print('{0}\\\\Scripts\\\\activate.bat (for Batch)'.format(venv_name))\n        print('.\\\\{0}\\\\Scripts\\\\Activate.ps1 (for Powershell)'.format(venv_name))\n        print('---------------------------------------------------------------------------')\n    else:\n        raise ValueError('Error, directory {0} is not a valid venv.'.format(venv_name))\n\n\nif __name__ == '__main__':\n    main('venv',\n         '',\n         sys.argv[1:])\n", "path": "tools/_venv_common.py"}]}