[Bf-blender-cvs] [64c8e9a2196] master: macOS: don't require python3 to be installed to run "make update"

Brecht Van Lommel noreply at git.blender.org
Mon Sep 30 10:52:09 CEST 2019


Commit: 64c8e9a2196f657261e737ba62d1cb479e04a518
Author: Brecht Van Lommel
Date:   Mon Sep 30 10:19:55 2019 +0200
Branches: master
https://developer.blender.org/rB64c8e9a2196f657261e737ba62d1cb479e04a518

macOS: don't require python3 to be installed to run "make update"

And fall back to python3 from our libraries for other commands, once checked
out with make update.

===================================================================

M	GNUmakefile
M	build_files/utils/make_test.py
M	build_files/utils/make_update.py
M	build_files/utils/make_utils.py

===================================================================

diff --git a/GNUmakefile b/GNUmakefile
index d960a67e407..e52fd38a7e3 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -192,6 +192,16 @@ ifndef PYTHON
 	PYTHON:=python3
 endif
 
+# For macOS python3 is not installed by default, so fallback to python binary
+# in libraries, or python 2 for running make update to get it.
+ifeq ($(OS_NCASE),darwin)
+	ifeq (, $(shell command -v $(PYTHON)))
+		PYTHON:=../lib/darwin/python/bin/python3.7m
+		ifeq (, $(shell command -v $(PYTHON)))
+			PYTHON:=python
+		endif
+	endif
+endif
 
 # -----------------------------------------------------------------------------
 # additional targets for the build configuration
@@ -374,7 +384,7 @@ package_archive: .FORCE
 # Tests
 #
 test: .FORCE
-	python3 ./build_files/utils/make_test.py "$(BUILD_DIR)"
+	$(PYTHON) ./build_files/utils/make_test.py "$(BUILD_DIR)"
 
 # run pep8 check check on scripts we distribute.
 test_pep8: .FORCE
@@ -530,11 +540,11 @@ icons_geom: .FORCE
 	    "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
 
 update: .FORCE
-	python3 ./build_files/utils/make_update.py
+	$(PYTHON) ./build_files/utils/make_update.py
 
 format: .FORCE
 	PATH="../lib/${OS_NCASE}/llvm/bin/:$(PATH)" \
-		python3 source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
+		$(PYTHON) source/tools/utils_maintenance/clang_format_paths.py $(PATHS)
 
 
 # -----------------------------------------------------------------------------
diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py
index b89afc738ce..a8a6afc43cc 100755
--- a/build_files/utils/make_test.py
+++ b/build_files/utils/make_test.py
@@ -30,11 +30,11 @@ cmake_command = args.cmake_command
 config = args.config
 build_dir = args.build_directory
 
-if shutil.which(ctest_command) is None:
+if make_utils.command_missing(ctest_command):
     sys.stderr.write("ctest not found, can't run tests\n")
     sys.exit(1)
 
-if shutil.which(git_command) is None:
+if make_utils.command_missing(git_command):
     sys.stderr.write("git not found, can't run tests\n")
     sys.exit(1)
 
@@ -45,11 +45,11 @@ lib_tests_dirpath = os.path.join('..', 'lib', "tests")
 if not os.path.exists(lib_tests_dirpath):
     print("Tests files not found, downloading...")
 
-    if shutil.which(svn_command) is None:
+    if make_utils.command_missing(svn_command):
         sys.stderr.write("svn not found, can't checkout test files\n")
         sys.exit(1)
 
-    if shutil.which(cmake_command) is None:
+    if make_utils.command_missing(cmake_command):
         sys.stderr.write("cmake not found, can't checkout test files\n")
         sys.exit(1)
 
diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index 2cbbd1ffd72..3ecfa218432 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -30,7 +30,6 @@ def parse_arguments():
     parser.add_argument("--git-command", default="git")
     return parser.parse_args()
 
-
 # Setup for precompiled libraries and tests from svn.
 def svn_update(args, release_version):
     svn_non_interactive = [args.svn_command, '--non-interactive']
@@ -56,7 +55,7 @@ def svn_update(args, release_version):
         if not os.path.exists(lib_platform_dirpath):
             print_stage("Checking out Precompiled Libraries")
 
-            if shutil.which(args.svn_command) is None:
+            if make_utils.command_missing(args.svn_command):
                 sys.stderr.write("svn not found, can't checkout libraries\n")
                 sys.exit(1)
 
@@ -70,7 +69,7 @@ def svn_update(args, release_version):
         if not os.path.exists(lib_tests_dirpath):
             print_stage("Checking out Tests")
 
-            if shutil.which(args.svn_command) is None:
+            if make_utils.command_missing(args.svn_command):
                 sys.stderr.write("svn not found, can't checkout tests\n")
                 sys.exit(1)
 
@@ -91,7 +90,7 @@ def svn_update(args, release_version):
 
         if os.path.isdir(dirpath) and \
            (os.path.exists(svn_dirpath) or os.path.exists(svn_root_dirpath)):
-            if shutil.which(args.svn_command) is None:
+            if make_utils.command_missing(args.svn_command):
                 sys.stderr.write("svn not found, can't update libraries\n")
                 sys.exit(1)
 
@@ -102,7 +101,7 @@ def svn_update(args, release_version):
 
 # Update blender repository.
 def blender_update_skip(args):
-    if shutil.which(args.git_command) is None:
+    if make_utils.command_missing(args.git_command):
         sys.stderr.write("git not found, can't update code\n")
         sys.exit(1)
 
@@ -136,7 +135,7 @@ def blender_update(args):
 # Update submodules.
 def submodules_update(args, release_version):
     print_stage("Updating Submodules")
-    if shutil.which(args.git_command) is None:
+    if make_utils.command_missing(args.git_command):
         sys.stderr.write("git not found, can't update code\n")
         sys.exit(1)
 
diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py
index 0c63a18b0ba..5fedd792149 100755
--- a/build_files/utils/make_utils.py
+++ b/build_files/utils/make_utils.py
@@ -3,6 +3,7 @@
 # Utility functions for make update and make tests.
 
 import re
+import shutil
 import subprocess
 import sys
 
@@ -54,3 +55,10 @@ def svn_libraries_base_url(release_version):
     else:
         svn_branch = "trunk"
     return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"
+
+def command_missing(command):
+    # Support running with Python 2 for macOS
+    if sys.version_info >= (3, 0):
+        return shutil.which(command) is None
+    else:
+        return False



More information about the Bf-blender-cvs mailing list