2019-03-14 14:07:19 -04:00
|
|
|
#!/usr/bin/env python3
|
2018-11-07 20:16:16 -05:00
|
|
|
# Developer virtualenv setup for Certbot client
|
2019-04-05 18:01:09 -04:00
|
|
|
import sys
|
|
|
|
|
|
2018-11-07 20:16:16 -05:00
|
|
|
import _venv_common
|
|
|
|
|
|
2019-04-05 18:01:09 -04:00
|
|
|
|
|
|
|
|
def create_venv(venv_path):
|
|
|
|
|
"""Create a Python 3 virtual environment at venv_path.
|
|
|
|
|
|
|
|
|
|
:param str venv_path: path where the venv should be created
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
python3 = _venv_common.find_python_executable(3)
|
|
|
|
|
command = [python3, '-m', 'venv', venv_path]
|
|
|
|
|
_venv_common.subprocess_with_print(command)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(pip_args=None):
|
|
|
|
|
venv_path = _venv_common.prepare_venv_path('venv3')
|
|
|
|
|
create_venv(venv_path)
|
2019-07-02 16:45:57 -04:00
|
|
|
|
|
|
|
|
if not pip_args:
|
2019-11-12 17:33:38 -05:00
|
|
|
pip_args = _venv_common.REQUIREMENTS + ['-e certbot[dev3]']
|
2019-07-02 16:45:57 -04:00
|
|
|
|
2019-04-05 18:01:09 -04:00
|
|
|
_venv_common.install_packages(venv_path, pip_args)
|
2018-11-07 20:16:16 -05:00
|
|
|
|
Update tools/venv3.py to support py launcher on Windows (#6493)
Following some inconsistencies occurred during by developments, and in the light of #6508, it decided to wrote a PR that will take fully advantage of the conversion from bash to python to the development setup tools.
This PR adresses several issues when trying to use the development setup tools (`tools/venv.py` and `tools/venv3.py`:
* on Windows, `python` executable is not always in PATH (default behavior)
* even if the option is checked, the `python` executable is not associated to the usually symlink `python3` on Windows
* on Windows again, really powerful introspection of the available Python environments can be done with `py`, the Windows Python launcher
* in general for all systems, `tools/venv.py` and `tools/venv3.py` ensures that the respective Python major version will be used to setup the virtual environment if available.
* finally, the best and first candidate to test should be the Python executable used to launch the `tools/venv*.py` script. It was not relevant before because it was shell scripts, but do it is.
The logic is shared in `_venv_common.py`, and will be called appropriately for both scripts. In priority decreasing order, python executable will be search and tested:
* from the current Python executable, as exposed by `sys.executable`
* from any python or pythonX (X as a python version like 2, 3 or 2.7 or 3.4) executable available in PATH
* from the Windows Python launched `py` if available
Individual changes were:
* Update tools/venv3.py to support py launcher on Windows
* Fix typo in help message
* More explicit calls with space protection
* Complete refactoring to take advantage of the python runtime, and control of the compatible version to use.
2018-11-15 18:17:36 -05:00
|
|
|
|
2018-11-07 20:16:16 -05:00
|
|
|
if __name__ == '__main__':
|
2019-04-05 18:01:09 -04:00
|
|
|
main(sys.argv[1:])
|