mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	To replace DISTRIB_FAMILY, there’s now an os_families function using the standard ID and ID_LIKE information in /etc/os-release. Fixes #13070; fixes #13071. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| 
 | |
| import os
 | |
| import argparse
 | |
| import sys
 | |
| 
 | |
| ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 | |
| if ZULIP_PATH not in sys.path:
 | |
|     sys.path.append(ZULIP_PATH)
 | |
| 
 | |
| from scripts.lib.zulip_tools import os_families, overwrite_symlink, run, parse_os_release
 | |
| from scripts.lib.setup_venv import (
 | |
|     setup_virtualenv, VENV_DEPENDENCIES, REDHAT_VENV_DEPENDENCIES,
 | |
|     FEDORA_VENV_DEPENDENCIES
 | |
| )
 | |
| 
 | |
| parser = argparse.ArgumentParser(description="Create a production virtualenv with caching")
 | |
| parser.add_argument("deploy_path")
 | |
| args = parser.parse_args()
 | |
| 
 | |
| # install dependencies for setting up the virtualenv
 | |
| distro_info = parse_os_release()
 | |
| if "debian" in os_families():
 | |
|     run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)
 | |
| elif "fedora" in os_families():
 | |
|     if "rhel" in os_families():
 | |
|         _VENV_DEPS = REDHAT_VENV_DEPENDENCIES
 | |
|     else:
 | |
|         _VENV_DEPS = FEDORA_VENV_DEPENDENCIES
 | |
|     run(["yum", "-y", "install"] + _VENV_DEPS)
 | |
| else:
 | |
|     print("Unsupported platform: {}".format(distro_info['ID']))
 | |
|     sys.exit(1)
 | |
| 
 | |
| python_version = sys.version_info[0]
 | |
| 
 | |
| # Set the current working directory to the Zulip checkout, so the api/
 | |
| # relative path in requirements/common.in works.
 | |
| os.chdir(ZULIP_PATH)
 | |
| 
 | |
| venv_name = "zulip-py3-venv"
 | |
| cached_venv_path = setup_virtualenv(
 | |
|     os.path.join(args.deploy_path, venv_name),
 | |
|     os.path.join(ZULIP_PATH, "requirements", "prod.txt"),
 | |
|     virtualenv_args=['-p', 'python{}'.format(python_version)])
 | |
| 
 | |
| current_venv_path = os.path.join(args.deploy_path, 'zulip-current-venv')
 | |
| overwrite_symlink(venv_name, current_venv_path)
 |