MINGW-packages/mingw-w64-gnuradio/0001-cmake-Install-python-wrapper-exe-for-scripts-on-Wind.patch
Chris Gorman dac5778500 update gnuradio version, remove old patches, and move to tarball build
- renamed patch 0005 to 0001
- removed patches 0002, 0003 and 0006 as they are nolonger needed with the new version
- use gpg keys to validate package sources
- add dependency on angleproject as gnuradio-companion --qt depends on libEGL and
  angleproject provides this library.
2024-07-24 19:34:11 -04:00

63 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ryan Volz <rvolz@mit.edu>
Date: Tue, 21 Apr 2020 17:46:01 -0400
Subject: [PATCH] cmake: Install python wrapper exe for scripts on Windows.
---
cmake/Modules/GrPython.cmake | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake
index 8f113273b..72cde3a49 100644
--- a/cmake/Modules/GrPython.cmake
+++ b/cmake/Modules/GrPython.cmake
@@ -358,12 +358,44 @@ function(GR_PYTHON_INSTALL)
get_filename_component(pyfile_name ${pyfile} NAME)
get_filename_component(pyfile ${pyfile} ABSOLUTE)
string(REPLACE "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" pyexefile
- "${pyfile}.exe")
+ "${pyfile}.py")
list(APPEND python_install_gen_targets ${pyexefile})
get_filename_component(pyexefile_path ${pyexefile} PATH)
file(MAKE_DIRECTORY ${pyexefile_path})
+ if(WIN32)
+ # check the python file to see if we should wrap it
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ "import sys; from pip._vendor.distlib.scripts import FIRST_LINE_RE; f = open('${pyfile}', 'rb'); first_line = f.readline(); f.close(); match = FIRST_LINE_RE.match(first_line.replace(b'\\r\\n', b'\\n')); sys.exit(0 if match else 1)"
+ RESULT_VARIABLE pyfile_dont_wrap
+ OUTPUT_QUIET
+ )
+ if(NOT pyfile_dont_wrap)
+ # pyfile_dont_wrap is a 0 if we should wrap, 1 if we shouldn't
+ # generate script wrapper exe and install
+ get_filename_component(pyfile_dir ${pyfile} DIRECTORY)
+ string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pywrapperfile_dir ${pyfile_dir})
+ string(REGEX REPLACE "\.py$" "" pywrapperfile_name "${pyfile_name}")
+ set(pywrapperfile_name "${pywrapperfile_name}.exe")
+ set(pywrapperfile "${pywrapperfile_dir}/${pywrapperfile_name}")
+ list(APPEND python_install_gen_targets ${pywrapperfile})
+
+ add_custom_command(
+ OUTPUT ${pywrapperfile} DEPENDS ${pyfile}
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ "from pip._vendor.distlib.scripts import ScriptMaker; maker = ScriptMaker('${pyfile_dir}', '${pywrapperfile_dir}', add_launchers=True); maker.executable = '/usr/bin/env python'; maker.make('${pyfile_name}')"
+ COMMENT "Wrapping ${pyfile_name}"
+ VERBATIM
+ )
+
+ install(PROGRAMS ${pywrapperfile}
+ DESTINATION ${GR_PYTHON_INSTALL_DESTINATION}
+ )
+ endif()
+ endif()
+
add_custom_command(
OUTPUT ${pyexefile}
DEPENDS ${pyfile}
--
2.40.0