Skip to content

Commit 3936b10

Browse files
committed
firestore_snappy.patch.txt: hack test to see if the windows python error can be fixed by using a temporary directory.
A previous commit, bc4a657, patched firebase-ios-sdk with firebase/firebase-ios-sdk#9662, which modified cmake builds to create a python virtualenv for each python script. This, however, ran into a strange problem in the Windows GitHub Actions runners, where creating the virtualenv failed when it attempted to call ensurepip. The suspected root cause is a MAX_PATH length violation. To test out this hypothesis, this commit modifies the FirebaseSetupPythonInterpreter() to create the Python virtualenv in a temporary directory instead of a well-defined subdirectory of cmake's binary directory. This should have a shorter path length for the virtualenv. If this works, then possibly we will need to provide a way to override the base directory for the pyvenv's. Here is the actual failure from https://github.com/firebase/firebase-cpp-sdk/runs/6083486670 ``` -- Found PythonInterp: C:/ProgramData/chocolatey/bin/python2.7.exe (found suitable version "2.7.9", minimum required is "2.7") -- Found Python3: C:/hostedtoolcache/windows/Python/3.10.4/x64/python3.exe (found version "3.10.4") found components: Interpreter -- FirebaseSetupPythonInterpreter(FirestoreProtos): Creating Python virtualenv in D:/a/firebase-cpp-sdk/firebase-cpp-sdk/ta/admob/it/bin/external/src/firestore-build/Firestore/Protos/pyvenv/FirestoreProtos using C:/hostedtoolcache/windows/Python/3.10.4/x64/python3.exe Error: Command '['D:\\a\\firebase-cpp-sdk\\firebase-cpp-sdk\\ta\\admob\\it\\bin\\external\\src\\firestore-build\\Firestore\\Protos\\pyvenv\\FirestoreProtos\\Scripts\\python3.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3221225781. CMake Error at bin/external/src/firestore/cmake/python_setup.cmake:133 (message): Failed to create a Python virtualenv in D:/a/firebase-cpp-sdk/firebase-cpp-sdk/ta/admob/it/bin/external/src/firestore-build/Firestore/Protos/pyvenv/FirestoreProtos using C:/hostedtoolcache/windows/Python/3.10.4/x64/python3.exe Call Stack (most recent call first): bin/external/src/firestore/Firestore/Protos/CMakeLists.txt:16 (FirebaseSetupPythonInterpreter) ```
1 parent 9efdb4a commit 3936b10

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

cmake/external/firestore_snappy.patch.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,39 @@ index 000000000..bdb7b9f6a
887887
+
888888
+ set("${ARG_OUTVAR}" "${PYTHON_EXECUTABLE}" PARENT_SCOPE)
889889
+endfunction(FirebaseSetupPythonInterpreter)
890+
diff --git a/cmake/python_setup.cmake b/cmake/python_setup.cmake
891+
index bdb7b9f6a..152744fab 100644
892+
--- a/cmake/python_setup.cmake
893+
+++ b/cmake/python_setup.cmake
894+
@@ -91,12 +91,30 @@ function(FirebaseSetupPythonInterpreter)
895+
"The Python interpreter on the host system to use"
896+
)
897+
898+
+ # Create a temporary directory into which to install the virtualenv
899+
+ execute_process(
900+
+ COMMAND
901+
+ "${FIREBASE_PYTHON_HOST_EXECUTABLE}"
902+
+ -c
903+
+ "import tempfile; print(tempfile.mkdtemp('FirebaseSetupPythonInterpreter', 'pyvenv'))"
904+
+ RESULT_VARIABLE
905+
+ FIREBASE_PYVENV_MKDTEMP_RESULT
906+
+ OUTPUT_VARIABLE
907+
+ FIREBASE_PYVENV_MKDTEMP_OUTPUT
908+
+ OUTPUT_STRIP_TRAILING_WHITESPACE
909+
+ )
910+
+ if(NOT FIREBASE_PYVENV_MKDTEMP_RESULT EQUAL 0)
911+
+ message(FATAL_ERROR
912+
+ "Failed to create a temporary directory for the Python virtualenv "
913+
+ "using ${FIREBASE_PYTHON_HOST_EXECUTABLE}")
914+
+ endif()
915+
+
916+
# Check if the virtualenv is already up-to-date by examining the contents of
917+
# its stamp files. The stamp files store the path of the host Python
918+
# interpreter and the dependencies that were installed by pip. If both of
919+
# these files exist and contain the same Python interpreter and dependencies
920+
# then just re-use the virtualenv; otherwise, re-create it.
921+
- set(PYVENV_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pyvenv/${ARG_KEY}")
922+
+ set(PYVENV_DIRECTORY "${FIREBASE_PYVENV_MKDTEMP_OUTPUT}/${ARG_KEY}")
923+
set(STAMP_FILE1 "${PYVENV_DIRECTORY}/cmake_firebase_python_stamp1.txt")
924+
set(STAMP_FILE2 "${PYVENV_DIRECTORY}/cmake_firebase_python_stamp2.txt")
925+

0 commit comments

Comments
 (0)