From 85823e8e5dba0f42297430cb4df5a586bfd08718 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 29 Dec 2022 23:32:57 +0100 Subject: [PATCH] build: Removed all usages of Python --- cmake/build_helpers.cmake | 26 ----------- cmake/modules/PostprocessBundle.cmake | 2 +- dist/AppImageBuilder.yml | 1 - dist/Arch/PKGBUILD | 2 +- dist/Brewfile | 1 - dist/DEBIAN/control.in | 2 +- dist/Dockerfile | 1 - dist/ImHex-9999.ebuild | 7 +-- dist/get_deps_archlinux.sh | 1 - dist/get_deps_debian.sh | 1 - dist/get_deps_fedora.sh | 3 +- dist/get_deps_msys2.sh | 1 - dist/msys2/PKGBUILD | 2 - dist/rpm/imhex.spec | 1 - lib/libimhex/CMakeLists.txt | 5 +-- lib/libimhex/include/hex/helpers/fs.hpp | 1 - lib/libimhex/source/helpers/fs.cpp | 3 -- .../source/content/views/view_about.cpp | 27 +++++++----- resources/lib/python/lib/imhex.py | 2 - .../lib/python/lib/imhex_python/types.py | 44 ------------------- 20 files changed, 24 insertions(+), 109 deletions(-) delete mode 100644 resources/lib/python/lib/imhex.py delete mode 100644 resources/lib/python/lib/imhex_python/types.py diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 1a71260f5..f4a1750e9 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -52,31 +52,6 @@ macro(addVersionDefines) endmacro() -macro(configurePython) - set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) - set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) - - # Enforce that we use non system Python 3 on macOS. - set(Python_FIND_FRAMEWORK NEVER) - - find_package(Python COMPONENTS Development REQUIRED) - if(Python_VERSION LESS 3) - message(STATUS ${PYTHON_VERSION_MAJOR_MINOR}) - message(FATAL_ERROR "No valid version of Python 3 was found.") - endif() - - string(REPLACE "." ";" PYTHON_VERSION_MAJOR_MINOR ${Python_VERSION}) - - list(LENGTH PYTHON_VERSION_MAJOR_MINOR PYTHON_VERSION_COMPONENT_COUNT) - - if (PYTHON_VERSION_COMPONENT_COUNT EQUAL 3) - list(REMOVE_AT PYTHON_VERSION_MAJOR_MINOR 2) - endif () - list(JOIN PYTHON_VERSION_MAJOR_MINOR "." PYTHON_VERSION_MAJOR_MINOR) - - add_compile_definitions(PYTHON_VERSION_MAJOR_MINOR="${PYTHON_VERSION_MAJOR_MINOR}") -endmacro() - # Detect current OS / System macro(detectOS) if (WIN32) @@ -223,7 +198,6 @@ macro(createPackage) # Grab all dynamically linked dependencies. INSTALL(CODE "set(CMAKE_INSTALL_BINDIR \"${CMAKE_INSTALL_BINDIR}\")") - INSTALL(CODE "get_filename_component(PY_PARENT \"${Python_LIBRARIES}\" DIRECTORY)") INSTALL(CODE "LIST(APPEND DEP_FOLDERS \${PY_PARENT})") install(CODE [[ file(GET_RUNTIME_DEPENDENCIES diff --git a/cmake/modules/PostprocessBundle.cmake b/cmake/modules/PostprocessBundle.cmake index 789ab38a4..05b83470e 100644 --- a/cmake/modules/PostprocessBundle.cmake +++ b/cmake/modules/PostprocessBundle.cmake @@ -46,7 +46,7 @@ endfunction() include(BundleUtilities) set(BU_CHMOD_BUNDLE_ITEMS ON) -fixup_bundle("${BUNDLE_PATH}" "${extra_libs}" "${extra_dirs}" IGNORE_ITEM "Python") +fixup_bundle("${BUNDLE_PATH}" "${extra_libs}" "${extra_dirs}") if (CODE_SIGN_CERTIFICATE_ID) # Hack around Apple Silicon signing bugs by copying the real app, signing it and moving it back. diff --git a/dist/AppImageBuilder.yml b/dist/AppImageBuilder.yml index eba390a99..8bca48d8d 100644 --- a/dist/AppImageBuilder.yml +++ b/dist/AppImageBuilder.yml @@ -107,7 +107,6 @@ AppDir: - /lib/x86_64-linux-gnu/libpcre2-8.so.0 - /lib/x86_64-linux-gnu/libpixman-1.so.0 - /lib/x86_64-linux-gnu/libpng16.so.16 - - /lib/x86_64-linux-gnu/libpython3.10.so.1.0 - /lib/x86_64-linux-gnu/libsasl2.so.2 - /lib/x86_64-linux-gnu/libsensors.so.5 - /lib/x86_64-linux-gnu/libstdc++.so.6 diff --git a/dist/Arch/PKGBUILD b/dist/Arch/PKGBUILD index dc7bf529d..af9192916 100644 --- a/dist/Arch/PKGBUILD +++ b/dist/Arch/PKGBUILD @@ -8,7 +8,7 @@ pkgdesc="A Hex Editor for Reverse Engineers, Programmers and people who value th arch=("x86_64") url="https://github.com/WerWolv/ImHex" license=('GPL2') -depends=(glfw mbedtls python freetype2 libglvnd dbus xdg-desktop-portal curl fmt yara nlohmann-json) +depends=(glfw mbedtls freetype2 libglvnd dbus xdg-desktop-portal curl fmt yara nlohmann-json) makedepends=(git) provides=(imhex) conflicts=(imhex) diff --git a/dist/Brewfile b/dist/Brewfile index d249056a5..659b5f57d 100644 --- a/dist/Brewfile +++ b/dist/Brewfile @@ -2,7 +2,6 @@ brew "mbedtls" brew "nlohmann-json" brew "cmake" brew "ccache" -brew "python3" brew "freetype2" brew "libmagic" brew "pkg-config" diff --git a/dist/DEBIAN/control.in b/dist/DEBIAN/control.in index 9b2fe253c..7e4487e5c 100644 --- a/dist/DEBIAN/control.in +++ b/dist/DEBIAN/control.in @@ -4,7 +4,7 @@ Section: editors Priority: optional Architecture: amd64 License: GNU GPL-2 -Depends: libglfw3, libmagic1, libmbedtls14, libpython3.10, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal +Depends: libglfw3, libmagic1, libmbedtls14, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal Maintainer: WerWolv Description: ImHex Hex Editor A Hex Editor for Reverse Engineers, Programmers and diff --git a/dist/Dockerfile b/dist/Dockerfile index a5a34ee0b..df77da582 100644 --- a/dist/Dockerfile +++ b/dist/Dockerfile @@ -13,7 +13,6 @@ RUN pacman -S --needed --noconfirm \ glfw-x11 \ file \ mbedtls \ - python3 \ freetype2 \ dbus \ xdg-desktop-portal diff --git a/dist/ImHex-9999.ebuild b/dist/ImHex-9999.ebuild index fb5d38730..ec50ce3c3 100644 --- a/dist/ImHex-9999.ebuild +++ b/dist/ImHex-9999.ebuild @@ -9,20 +9,15 @@ HOMEPAGE="https://github.com/WerWolv/ImHex" SRC_URI="" EGIT_REPO_URI="https://github.com/WerWolv/ImHex.git" -PYTHON_COMPAT=( python3_{6,7,8,9} ) - -inherit git-r3 python-single-r1 cmake +inherit git-r3 cmake LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64" IUSE="" -REQUIRED_USE="${PYTHON_REQUIRED_USE}" - DEPEND="" RDEPEND="${DEPEND} - ${PYTHON_DEPS} media-libs/glfw sys-apps/file dev-libs/mbedtls diff --git a/dist/get_deps_archlinux.sh b/dist/get_deps_archlinux.sh index 2c1267f77..6379780bc 100755 --- a/dist/get_deps_archlinux.sh +++ b/dist/get_deps_archlinux.sh @@ -7,7 +7,6 @@ pacman -S $@ --needed \ glfw \ file \ mbedtls \ - python3 \ freetype2 \ dbus \ xdg-desktop-portal \ diff --git a/dist/get_deps_debian.sh b/dist/get_deps_debian.sh index dd0a4e48d..2fc8c1f47 100755 --- a/dist/get_deps_debian.sh +++ b/dist/get_deps_debian.sh @@ -19,7 +19,6 @@ apt install -y \ libglm-dev \ libmagic-dev \ libmbedtls-dev \ - python3-dev \ libfreetype-dev \ libdbus-1-dev \ xdg-desktop-portal diff --git a/dist/get_deps_fedora.sh b/dist/get_deps_fedora.sh index 646187857..d80fb0b1f 100755 --- a/dist/get_deps_fedora.sh +++ b/dist/get_deps_fedora.sh @@ -10,5 +10,4 @@ dnf install -y \ mesa-libGL-devel \ glfw-devel \ lld \ - mbedtls-devel \ - python3-devel + mbedtls-devel \ No newline at end of file diff --git a/dist/get_deps_msys2.sh b/dist/get_deps_msys2.sh index 3eedd6aae..a1d0dd546 100755 --- a/dist/get_deps_msys2.sh +++ b/dist/get_deps_msys2.sh @@ -9,6 +9,5 @@ pacman -S --needed --noconfirm \ mingw-w64-x86_64-glfw \ mingw-w64-x86_64-file \ mingw-w64-x86_64-mbedtls \ - mingw-w64-x86_64-python \ mingw-w64-x86_64-freetype \ mingw-w64-x86_64-dlfcn diff --git a/dist/msys2/PKGBUILD b/dist/msys2/PKGBUILD index 5b86e9a50..6037693ad 100644 --- a/dist/msys2/PKGBUILD +++ b/dist/msys2/PKGBUILD @@ -7,7 +7,6 @@ pkgdesc="${_realname}: a Hex Editor for Reverse Engineers, Programmers and peopl arch=('any') url="https://github.com/WerWolv/ImHex" license=('GPLv2') -depends=("${MINGW_PACKAGE_PREFIX}-python") makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-lld" "${MINGW_PACKAGE_PREFIX}-cmake" @@ -17,7 +16,6 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-file" "${MINGW_PACKAGE_PREFIX}-mbedtls" "${MINGW_PACKAGE_PREFIX}-polly" - "${MINGW_PACKAGE_PREFIX}-python" "${MINGW_PACKAGE_PREFIX}-freetype") source=() diff --git a/dist/rpm/imhex.spec b/dist/rpm/imhex.spec index e06b492b9..e6ffc54fe 100644 --- a/dist/rpm/imhex.spec +++ b/dist/rpm/imhex.spec @@ -19,7 +19,6 @@ BuildRequires: json-devel BuildRequires: libcurl-devel BuildRequires: llvm-devel BuildRequires: mbedtls-devel -BuildRequires: python3-devel %if 0%{?fedora} >= 37 BuildRequires: yara-devel %endif diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 28dea2dd2..2490d3a75 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -90,7 +90,6 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/pattern_language ${CMAK set_target_properties(libpl PROPERTIES POSITION_INDEPENDENT_CODE ON) find_package(mbedTLS 2.26.0 REQUIRED) -configurePython() pkg_search_module(MAGIC libmagic>=5.39) if(NOT MAGIC_FOUND) @@ -162,7 +161,7 @@ add_library(libimhex SHARED ${LIBIMHEX_SOURCES}) set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON) setupCompilerWarnings(libimhex) -target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS}) +target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS}) target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS}) if (APPLE) @@ -170,4 +169,4 @@ if (APPLE) target_link_libraries(libimhex PUBLIC ${FOUNDATION}) endif () -target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${Python_LIBRARIES} libpl intervaltree) +target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} libpl intervaltree) diff --git a/lib/libimhex/include/hex/helpers/fs.hpp b/lib/libimhex/include/hex/helpers/fs.hpp index 31621e676..eb5ddafb2 100644 --- a/lib/libimhex/include/hex/helpers/fs.hpp +++ b/lib/libimhex/include/hex/helpers/fs.hpp @@ -90,7 +90,6 @@ namespace hex::fs { Patterns = 0, PatternsInclude, Magic, - Python, Plugins, Yara, Config, diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index e54348464..b05042bd9 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -238,9 +238,6 @@ namespace hex::fs { case ImHexPath::PatternsInclude: result = appendPath(getDataPaths(), "includes"); break; - case ImHexPath::Python: - result = appendPath(getDataPaths(), "python"); - break; case ImHexPath::Yara: result = appendPath(getDataPaths(), "yara"); break; diff --git a/plugins/builtin/source/content/views/view_about.cpp b/plugins/builtin/source/content/views/view_about.cpp index dd7443ffd..81c4edacb 100644 --- a/plugins/builtin/source/content/views/view_about.cpp +++ b/plugins/builtin/source/content/views/view_about.cpp @@ -130,7 +130,6 @@ namespace hex::plugin::builtin { link("GNU libmagic", "", "https://www.darwinsys.com/file/"); link("GLFW3", "", "https://github.com/glfw/glfw/"); link("LLVM", "", "https://github.com/llvm/llvm-project/"); - link("Python 3", "", "https://github.com/python/cpython/"); ImGui::PopStyleColor(); @@ -143,15 +142,23 @@ namespace hex::plugin::builtin { ImGui::TableSetupColumn("Type"); ImGui::TableSetupColumn("Paths"); - constexpr static std::array, 8> PathTypes = { - {{ "Resources", fs::ImHexPath::Resources }, - { "Config", fs::ImHexPath::Config }, - { "Magic", fs::ImHexPath::Magic }, - { "Patterns", fs::ImHexPath::Patterns }, - { "Patterns Includes", fs::ImHexPath::PatternsInclude }, - { "Plugins", fs::ImHexPath::Plugins }, - { "Python Scripts", fs::ImHexPath::Python }, - { "Yara Patterns", fs::ImHexPath::Yara }} + constexpr static std::array, u32(fs::ImHexPath::END)> PathTypes = { + { + { "Patterns", fs::ImHexPath::Patterns }, + { "Patterns Includes", fs::ImHexPath::PatternsInclude }, + { "Magic", fs::ImHexPath::Magic }, + { "Plugins", fs::ImHexPath::Plugins }, + { "Yara Patterns", fs::ImHexPath::Yara }, + { "Config", fs::ImHexPath::Config }, + { "Resources", fs::ImHexPath::Resources }, + { "Constants lists", fs::ImHexPath::Constants }, + { "Custom encodings", fs::ImHexPath::Encodings }, + { "Logs", fs::ImHexPath::Logs }, + { "Recent files", fs::ImHexPath::Recent }, + { "Scripts", fs::ImHexPath::Scripts }, + { "Themes", fs::ImHexPath::Themes }, + { "Data inspector scripts", fs::ImHexPath::Inspectors }, + } }; ImGui::TableHeadersRow(); diff --git a/resources/lib/python/lib/imhex.py b/resources/lib/python/lib/imhex.py deleted file mode 100644 index 438396caa..000000000 --- a/resources/lib/python/lib/imhex.py +++ /dev/null @@ -1,2 +0,0 @@ -from _imhex import * -import imhex_python.types as types \ No newline at end of file diff --git a/resources/lib/python/lib/imhex_python/types.py b/resources/lib/python/lib/imhex_python/types.py deleted file mode 100644 index 327976930..000000000 --- a/resources/lib/python/lib/imhex_python/types.py +++ /dev/null @@ -1,44 +0,0 @@ -class ImHexTypeMeta(type): - def __new__(cls, name, bases, dct): - return super().__new__(cls, name, bases, dct) - - def __getitem__(self, value): - return array(self, value) - -class ImHexType(metaclass=ImHexTypeMeta): - pass - -class u8(ImHexType): - pass -class u16(ImHexType): - pass -class u32(ImHexType): - pass -class u64(ImHexType): - pass -class u128(ImHexType): - pass - -class s8(ImHexType): - pass -class s16(ImHexType): - pass -class s32(ImHexType): - pass -class s64(ImHexType): - pass -class s128(ImHexType): - pass - -class float(ImHexType): - pass -class double(ImHexType): - pass - -class array(ImHexType): - def __init__(self, array_type, size): - self.array_type = array_type() - self.size = size - - array_type : type - size : int \ No newline at end of file