mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	setup_venv: Uninstall typing on Python >3.4.
Otherwise this causes an error ``` AttributeError: type object 'Callable' has no attribute '_abc_registry' ``` on 3.7. While the error is specific to 3.7, it is safer to uninstall typing for all the versions that don't require a pip-provided typing library.
This commit is contained in:
		@@ -39,7 +39,7 @@ git remote add -f upstream https://github.com/zulip/zulip.git
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
# On CentOS/RHEL, you must first install epel-release, and then python34
 | 
					# On CentOS/RHEL, you must first install epel-release, and then python36
 | 
				
			||||||
# On Fedora, you must first install python3
 | 
					# On Fedora, you must first install python3
 | 
				
			||||||
# From a clone of zulip.git
 | 
					# From a clone of zulip.git
 | 
				
			||||||
./tools/provision
 | 
					./tools/provision
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
from scripts.lib.zulip_tools import run, ENDC, WARNING, parse_lsb_release
 | 
					from scripts.lib.zulip_tools import run, ENDC, WARNING, parse_lsb_release
 | 
				
			||||||
from scripts.lib.hash_reqs import expand_reqs
 | 
					from scripts.lib.hash_reqs import expand_reqs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,9 +64,8 @@ COMMON_YUM_VENV_DEPENDENCIES = [
 | 
				
			|||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
REDHAT_VENV_DEPENDENCIES = COMMON_YUM_VENV_DEPENDENCIES + [
 | 
					REDHAT_VENV_DEPENDENCIES = COMMON_YUM_VENV_DEPENDENCIES + [
 | 
				
			||||||
    "python34-devel",
 | 
					    "python36-devel",
 | 
				
			||||||
    "python34-pip",
 | 
					    "python36-six",
 | 
				
			||||||
    "python34-six",
 | 
					 | 
				
			||||||
    "python-virtualenv",
 | 
					    "python-virtualenv",
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -352,4 +352,15 @@ def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
 | 
				
			|||||||
        # Might be a failure due to network connection issues. Retrying...
 | 
					        # Might be a failure due to network connection issues. Retrying...
 | 
				
			||||||
        print(WARNING + "`pip install` failed; retrying..." + ENDC)
 | 
					        print(WARNING + "`pip install` failed; retrying..." + ENDC)
 | 
				
			||||||
        install_venv_deps(requirements_file)
 | 
					        install_venv_deps(requirements_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # The typing module has been included in stdlib since 3.5.
 | 
				
			||||||
 | 
					    # Installing a pypi version of it has been harmless until a bug
 | 
				
			||||||
 | 
					    # "AttributeError: type object 'Callable' has no attribute
 | 
				
			||||||
 | 
					    # '_abc_registry'" happens in 3.7. And so just to be safe, it is
 | 
				
			||||||
 | 
					    # disabled from now on for all >= 3.5 versions.
 | 
				
			||||||
 | 
					    # Remove this once 3.4 is no longer supported.
 | 
				
			||||||
 | 
					    at_least_35 = (sys.version_info.major == 3) and (sys.version_info.minor >= 5)
 | 
				
			||||||
 | 
					    if at_least_35 and ('python2.7' not in virtualenv_args):
 | 
				
			||||||
 | 
					        run(["pip", "uninstall", "-y", "typing"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    run(["sudo", "chmod", "-R", "a+rX", venv_path])
 | 
					    run(["sudo", "chmod", "-R", "a+rX", venv_path])
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -290,6 +290,10 @@ def install_yum_deps(deps_to_install, retry=False):
 | 
				
			|||||||
                print("Unrecognized output. `subscription-manager` might not be available")
 | 
					                print("Unrecognized output. `subscription-manager` might not be available")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    run(["sudo", "yum", "install", "-y"] + yum_extra_flags + deps_to_install)
 | 
					    run(["sudo", "yum", "install", "-y"] + yum_extra_flags + deps_to_install)
 | 
				
			||||||
 | 
					    if vendor in ["CentOS", "RedHat"]:
 | 
				
			||||||
 | 
					        # This is how a pip3 is installed to /usr/bin in CentOS/RHEL
 | 
				
			||||||
 | 
					        # for python35 and later.
 | 
				
			||||||
 | 
					        run(["sudo", "python36", "-m", "ensurepip"])
 | 
				
			||||||
    postgres_dir = 'pgsql-%s' % (POSTGRES_VERSION,)
 | 
					    postgres_dir = 'pgsql-%s' % (POSTGRES_VERSION,)
 | 
				
			||||||
    for cmd in ['pg_config', 'pg_isready', 'psql']:
 | 
					    for cmd in ['pg_config', 'pg_isready', 'psql']:
 | 
				
			||||||
        # Our tooling expects these postgres scripts to be at
 | 
					        # Our tooling expects these postgres scripts to be at
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user