summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Bailey <derekbailey@google.com>2022-01-28 15:00:57 -0800
committerGitHub <noreply@github.com>2022-01-28 15:00:57 -0800
commitdbbaeac85c95eda8cbed3955d969196d131372f7 (patch)
tree8220b28a8371d754af6f48adceedec180da839fd
parent028f0fde6286b5fc7b1adddf76ba111b0a0fcfb7 (diff)
downloadflatbuffers-dbbaeac85c95eda8cbed3955d969196d131372f7.tar.gz
flatbuffers-dbbaeac85c95eda8cbed3955d969196d131372f7.tar.bz2
flatbuffers-dbbaeac85c95eda8cbed3955d969196d131372f7.zip
Use `${PYTHON_EXECUTABLE}` instead of `py` in cmake (#7042)
* Emit include for bfbs-gen-embed * Use python3 explicitly * bump min python version to 3.6 * Sort find_package for python * try casting Path to string * cast WindowsPath to string to please CI * stringify the wrong thing * another stringify path
-rw-r--r--CMakeLists.txt8
-rwxr-xr-xscripts/generate_code.py10
2 files changed, 9 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a7ceaaa..b4a489f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -526,16 +526,16 @@ function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
register_generated_output(${GEN_BFBS_HEADER})
endfunction()
-# Look if we have python 3 installed so that we can run the generate code python
-# script after flatc is built.
-find_package(PythonInterp 3)
+# Look if we have python 3.5 installed so that we can run the generate code
+# python script after flatc is built.
+find_package(PythonInterp 3.5)
if(PYTHONINTERP_FOUND AND
# Skip doing this if the MSVC version is below VS 12.
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
(NOT MSVC OR MSVC_VERSION GREATER 1800))
if(MSVC)
- set(GENERATION_SCRIPT py scripts/generate_code.py)
+ set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
else()
set(GENERATION_SCRIPT scripts/generate_code.py)
endif()
diff --git a/scripts/generate_code.py b/scripts/generate_code.py
index 39b82856..7902f0ed 100755
--- a/scripts/generate_code.py
+++ b/scripts/generate_code.py
@@ -74,7 +74,7 @@ def flatc(
cmd += [schema] if isinstance(schema, str) else schema
if data:
cmd += [data] if isinstance(data, str) else data
- result = subprocess.run(cmd, cwd=cwd, check=True)
+ result = subprocess.run(cmd, cwd=str(cwd), check=True)
# Glob a pattern relative to file path
@@ -360,7 +360,7 @@ assert (
new_monster_file.exists()
), "filename suffix option did not produce a file"
assert filecmp.cmp(
- orig_monster_file, new_monster_file
+ str(orig_monster_file), str(new_monster_file)
), "filename suffix option did not produce identical results"
new_monster_file.unlink()
@@ -409,6 +409,6 @@ new_reflection_file = Path(reflection_path, temp_dir, "reflection_generated.h")
original_reflection_file = Path(
root_path, "include/flatbuffers/reflection_generated.h"
)
-if not filecmp.cmp(new_reflection_file, original_reflection_file):
- shutil.move(new_reflection_file, original_reflection_file)
-shutil.rmtree(Path(reflection_path, temp_dir))
+if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)):
+ shutil.move(str(new_reflection_file), str(original_reflection_file))
+shutil.rmtree(str(Path(reflection_path, temp_dir)))