Skip to content

Commit 47371eb

Browse files
authored
Merge pull request #1764 from bstaletic/regex-optional
Make building regex module optional
2 parents 32e42c9 + 2344ca4 commit 47371eb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

build.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ def ParseArguments():
568568
parser.add_argument( '--js-completer', action = 'store_true',
569569
help = argparse.SUPPRESS )
570570

571+
parser.add_argument( '--regex', action = argparse.BooleanOptionalAction,
572+
default = True,
573+
help = 'Choose whether to build the regex module. '
574+
'Defaults to True.' )
571575
args = parser.parse_args()
572576

573577
# coverage is not supported for c++ on MSVC
@@ -800,8 +804,8 @@ def BuildRegexModule( script_args ):
800804
exit_message = 'Failed to build regex module.',
801805
quiet = script_args.quiet,
802806
status_message = 'Building regex module' )
803-
except ImportError:
804-
pass # Swallow the error - ycmd will fall back to the standard `re`.
807+
except ( ImportError, subprocess.CalledProcessError ):
808+
print( 'Building regex module failed. Falling back to re builtin.' )
805809

806810
finally:
807811
RemoveDirectoryIfExists( build_dir )
@@ -1301,9 +1305,13 @@ def DoCmakeBuilds( args ):
13011305
BuildYcmdLib( cmake, cmake_common_args, args )
13021306
WritePythonUsedDuringBuild()
13031307

1304-
BuildRegexModule( args )
13051308
BuildWatchdogModule( args )
13061309

1310+
# NOTE: Keep BuildRegexModule() as the final step.
1311+
# If it fails, at least everything mandatory has been built.
1312+
if args.regex:
1313+
BuildRegexModule( args )
1314+
13071315

13081316
def PrintReRunMessage():
13091317
print( '',

test_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ psutil >= 5.6.6
77
coverage >= 4.2
88
requests
99
legacy-cgi ; python_version >= "3.13"
10+
# Needed for building the regex and watchdog modules.
11+
setuptools

0 commit comments

Comments
 (0)