From e9ea687bb9e4848a6205cf7e0b07f73f349f7c36 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 8 Jan 2016 04:08:06 +0000 Subject: [PATCH 1/2] Disable the Python bindings by default which partially fixes issue #404. To enable the Python bindings use the newly added ``--python`` option. --- scripts/mk_util.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 6a070fe93..ca1b34c17 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -79,7 +79,7 @@ TRACE = False DOTNET_ENABLED=False JAVA_ENABLED=False ML_ENABLED=False -PYTHON_INSTALL_ENABLED=True +PYTHON_INSTALL_ENABLED=False STATIC_LIB=False VER_MAJOR=None VER_MINOR=None @@ -612,6 +612,7 @@ def display_help(exit_code): print(" --dotnet generate .NET bindings.") print(" --java generate Java bindings.") print(" --ml generate OCaml bindings.") + print(" --python generate Python bindings.") print(" --staticlib build Z3 static library.") if not IS_WINDOWS: print(" -g, --gmp use GMP.") @@ -642,14 +643,14 @@ def display_help(exit_code): # Parse configuration option for mk_make script def parse_options(): global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE, VS_PAR, VS_PAR_NUM - global DOTNET_ENABLED, JAVA_ENABLED, ML_ENABLED, STATIC_LIB, PREFIX, GMP, FOCI2, FOCI2LIB, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH + global DOTNET_ENABLED, JAVA_ENABLED, ML_ENABLED, STATIC_LIB, PREFIX, GMP, FOCI2, FOCI2LIB, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH, PYTHON_INSTALL_ENABLED global LINUX_X64, SLOW_OPTIMIZE, USE_OMP try: options, remainder = getopt.gnu_getopt(sys.argv[1:], 'b:df:sxhmcvtnp:gj', ['build=', 'debug', 'silent', 'x64', 'help', 'makefiles', 'showcpp', 'vsproj', 'trace', 'dotnet', 'staticlib', 'prefix=', 'gmp', 'foci2=', 'java', 'parallel=', 'gprof', - 'githash=', 'x86', 'ml', 'optimize', 'noomp', 'pypkgdir=']) + 'githash=', 'x86', 'ml', 'optimize', 'noomp', 'pypkgdir=', 'python']) except: print("ERROR: Invalid command line option") display_help(1) @@ -708,6 +709,8 @@ def parse_options(): ML_ENABLED = True elif opt in ('', '--noomp'): USE_OMP = False + elif opt in ('--python'): + PYTHON_INSTALL_ENABLED = True else: print("ERROR: Invalid command line option '%s'" % opt) display_help(1) @@ -1339,6 +1342,9 @@ class PythonInstallComponent(Component): self.in_prefix_install = True self.libz3Component = libz3Component + if not PYTHON_INSTALL_ENABLED: + return + if IS_WINDOWS: # Installing under Windows doesn't make sense as the install prefix is used # but that doesn't make sense under Windows @@ -1365,7 +1371,7 @@ class PythonInstallComponent(Component): assert not os.path.isabs(self.pythonPkgDir) def final_info(self): - if not PYTHON_PACKAGE_DIR.startswith(PREFIX): + if not PYTHON_PACKAGE_DIR.startswith(PREFIX) and PYTHON_INSTALL_ENABLED: print("Warning: The detected Python package directory (%s) is not " "in the installation prefix (%s). This can lead to a broken " "Python API installation. Use --pypkgdir= to change the " From 49a2ed01c8271660f4a323a2aec82a0f82958e9c Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 8 Jan 2016 04:43:09 +0000 Subject: [PATCH 2/2] Improve error message emitting during configure when the Python bindings are enabled and the set python package directory does not live under the install prefix. This is the other part required to fix issue #404. --- scripts/mk_util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index ca1b34c17..ed5df106b 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1363,7 +1363,15 @@ class PythonInstallComponent(Component): else: # Use path inside the prefix (should be the normal case on Linux) # CMW: Also normal on *BSD? - assert PYTHON_PACKAGE_DIR.startswith(PREFIX) + if not PYTHON_PACKAGE_DIR.startswith(PREFIX): + raise MKException(('The python package directory ({}) must live ' + + 'under the install prefix ({}) to install the python bindings.' + + 'Use --pypkgdir and --prefix to set the python package directory ' + + 'and install prefix respectively. Note that the python package ' + + 'directory does not need to exist and will be created if ' + + 'necessary during install.').format( + PYTHON_PACKAGE_DIR, + PREFIX)) self.pythonPkgDir = strip_path_prefix(PYTHON_PACKAGE_DIR, PREFIX) self.in_prefix_install = True