Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Remove most Python2 references (#742)
Browse files Browse the repository at this point in the history
* Remove most Python2 references

Still left some references to python2 for helper scripts since they
aren't tested (afaik) in CI

* Fix CI
  • Loading branch information
ekilmer committed Mar 5, 2021
1 parent 2ed00dc commit e42f45f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 590 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/vcpkg_ci.yml
Expand Up @@ -65,7 +65,8 @@ jobs:
run: |
# --help return non-zero and fails...
mcsema-lift-${{ matrix.llvm }}.0 --version
mcsema-disass-2 --help
mcsema-disass --help
mcsema-lift-${{ matrix.llvm }}.0 --arch amd64 --os linux --cfg ./tests/test_suite_generator/generated/prebuilt_cfg/amd64/linux/cfg/hello_world --output hello_world.bc
mcsema-lift-${{ matrix.llvm }}.0 --arch x86 --os linux --cfg ./tests/test_suite_generator/generated/prebuilt_cfg/x86/linux/cfg/hello_world --output hello_world.bc
Expand Down Expand Up @@ -111,8 +112,5 @@ jobs:
run: |
# --help return non-zero and fails...
mcsema-lift-${{ matrix.llvm }}.0 --version
# TODO Might want to use virtualenv for this whole Python installation process
# Will need to be updated based on the Python2 version used during installation
PYTHONPATH=/usr/local/lib/python2.7/site-packages mcsema-disass-2 --help
# Will need to be updated based on the Python3 version used during installation
PYTHONPATH=/usr/local/lib/python3.9/site-packages mcsema-disass-3 --help
31 changes: 0 additions & 31 deletions CMakeLists.txt
Expand Up @@ -42,13 +42,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")

option(MCSEMA_ENABLE_RUNTIME "Should runtimes for re-compilation of bitcode be produced?" ON)

find_package(Python2 QUIET)
if(Python2_FOUND)
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
else()
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
endif()

find_package(Python3 QUIET)
if(Python3_FOUND)
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
Expand Down Expand Up @@ -195,23 +188,6 @@ set(MCSEMA_PYTHON_SOURCES
tools/mcsema_disass/ida7/x86_util.py
)

if(MCSEMA_INSTALL_PYTHON2_LIBS)
add_custom_target(build_mcsema_disass_python2
DEPENDS ${MCSEMA_PYTHON_SOURCES})

add_custom_command(
TARGET build_mcsema_disass_python2 POST_BUILD
COMMAND which python2 && python2 setup.py build --force
COMMENT "Building McSema Python 2 mcsema-disass"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")

add_dependencies(${MCSEMA_LIFT}
build_mcsema_disass_python2)

add_dependencies(build_mcsema_disass_python2
protobuf_python_module_ida)
endif()

if(MCSEMA_INSTALL_PYTHON3_LIBS)
add_custom_target(build_mcsema_disass_python3
DEPENDS ${MCSEMA_PYTHON_SOURCES})
Expand Down Expand Up @@ -299,20 +275,13 @@ endif()
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
if(DEFINED WIN32)
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}.bat")
set(python_package_installer3 "${python_package_installer}.bat")
set(optional_interpreter "cmd.exe /C")
else()
set(python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}_py2.sh")
set(python_package_installer3 "${python_package_installer}_py3.sh")
endif()

if(MCSEMA_INSTALL_PYTHON2_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer2}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code2)\n if(NOT exit_code2 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 2 package\")\n endif()")
endif()

if(MCSEMA_INSTALL_PYTHON3_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer3}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code3)\n if(NOT exit_code3 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 3 package\")\n endif()")
Expand Down
31 changes: 0 additions & 31 deletions CMakeLists_vcpkg.txt
Expand Up @@ -37,13 +37,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")

option(MCSEMA_ENABLE_RUNTIME "Should runtimes for re-compilation of bitcode be produced?" ON)

find_package(Python2 QUIET)
if(Python2_FOUND)
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
else()
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
endif()

find_package(Python3 QUIET)
if(Python3_FOUND)
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
Expand Down Expand Up @@ -179,23 +172,6 @@ set(MCSEMA_PYTHON_SOURCES
tools/mcsema_disass/ida7/x86_util.py
)

if(MCSEMA_INSTALL_PYTHON2_LIBS)
add_custom_target(build_mcsema_disass_python2
DEPENDS ${MCSEMA_PYTHON_SOURCES})

add_custom_command(
TARGET build_mcsema_disass_python2 POST_BUILD
COMMAND which python2 && python2 setup.py build --force
COMMENT "Building McSema Python 2 mcsema-disass"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")

add_dependencies(${MCSEMA_LIFT}
build_mcsema_disass_python2)

add_dependencies(build_mcsema_disass_python2
protobuf_python_module_ida)
endif()

if(MCSEMA_INSTALL_PYTHON3_LIBS)
add_custom_target(build_mcsema_disass_python3
DEPENDS ${MCSEMA_PYTHON_SOURCES})
Expand Down Expand Up @@ -283,20 +259,13 @@ endif()
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
if(DEFINED WIN32)
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}.bat")
set(python_package_installer3 "${python_package_installer}.bat")
set(optional_interpreter "cmd.exe /C")
else()
set(python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}_py2.sh")
set(python_package_installer3 "${python_package_installer}_py3.sh")
endif()

if(MCSEMA_INSTALL_PYTHON2_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer2}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code2)\n if(NOT exit_code2 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 2 package\")\n endif()")
endif()

if(MCSEMA_INSTALL_PYTHON3_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer3}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code3)\n if(NOT exit_code3 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 3 package\")\n endif()")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -72,7 +72,7 @@ Why would anyone translate binaries *back* to bitcode?
| [CMake](https://cmake.org/) | 3.2+ |
| [Remill](https://github.com/lifting-bits/remill) | Latest |
| [Anvill](https://github.com/lifting-bits/anvill) | Latest |
| [Python](https://www.python.org/) | 2.7, 3.8 |
| [Python](https://www.python.org/) | 3.8 |
| [Python Package Index](https://pypi.python.org/pypi) | Latest |
| [python-protobuf](https://pypi.python.org/pypi/protobuf) | 3.2.0 |
| [python-clang](https://pypi.org/project/clang/) | 3.5.0 |
Expand Down Expand Up @@ -133,7 +133,7 @@ sudo apt-get install \
git \
curl \
cmake \
python2.7 python-pip python-virtualenv \
python3 python3-pip python3-virtualenv \
wget \
build-essential \
gcc-multilib g++-multilib \
Expand Down Expand Up @@ -266,7 +266,7 @@ In order to verify that McSema works correctly as built, head on over to [the do
2. Do **NOT** enable "Add to PATH"

**Python**
1. Get the latest Python 2.7 (X64) installer from the official download page: https://www.python.org/downloads/windows/
1. Get the latest Python 3 (X64) installer from the official download page: https://www.python.org/downloads/windows/
2. Enable "Add to PATH"

**CMake**
Expand Down Expand Up @@ -344,7 +344,7 @@ You should now have the following directories: C:\mcsema, C:\remill.
Make extra sure it only contains ASCII characters with no newlines! The following command should work fine under cmd:

```
echo|set /p="C:\mcsema\Lib\site-packages" > "C:\Python27\Lib\site-packages\mcsema.pth"
echo|set /p="C:\mcsema\Lib\site-packages" > "C:\Python3<version>\Lib\site-packages\mcsema.pth"
```

**Install the libmagic DLL**
Expand Down
2 changes: 1 addition & 1 deletion scripts/lift_directory.py
Expand Up @@ -141,4 +141,4 @@ def main():
return ret

if __name__ == "__main__":
exit(main())
exit(main())

0 comments on commit e42f45f

Please sign in to comment.