diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a7ceaaad..b4a489f2c 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 39b82856d..7902f0edf 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)))