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

Commit e42f45f

Browse files
authored
Remove most Python2 references (#742)
* Remove most Python2 references Still left some references to python2 for helper scripts since they aren't tested (afaik) in CI * Fix CI
1 parent 2ed00dc commit e42f45f

File tree

7 files changed

+7
-590
lines changed

7 files changed

+7
-590
lines changed

.github/workflows/vcpkg_ci.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ jobs:
6565
run: |
6666
# --help return non-zero and fails...
6767
mcsema-lift-${{ matrix.llvm }}.0 --version
68-
mcsema-disass-2 --help
68+
mcsema-disass --help
69+
6970
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
7071
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
7172
@@ -111,8 +112,5 @@ jobs:
111112
run: |
112113
# --help return non-zero and fails...
113114
mcsema-lift-${{ matrix.llvm }}.0 --version
114-
# TODO Might want to use virtualenv for this whole Python installation process
115-
# Will need to be updated based on the Python2 version used during installation
116-
PYTHONPATH=/usr/local/lib/python2.7/site-packages mcsema-disass-2 --help
117115
# Will need to be updated based on the Python3 version used during installation
118116
PYTHONPATH=/usr/local/lib/python3.9/site-packages mcsema-disass-3 --help

CMakeLists.txt

-31
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
4242

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

45-
find_package(Python2 QUIET)
46-
if(Python2_FOUND)
47-
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
48-
else()
49-
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
50-
endif()
51-
5245
find_package(Python3 QUIET)
5346
if(Python3_FOUND)
5447
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
@@ -195,23 +188,6 @@ set(MCSEMA_PYTHON_SOURCES
195188
tools/mcsema_disass/ida7/x86_util.py
196189
)
197190

198-
if(MCSEMA_INSTALL_PYTHON2_LIBS)
199-
add_custom_target(build_mcsema_disass_python2
200-
DEPENDS ${MCSEMA_PYTHON_SOURCES})
201-
202-
add_custom_command(
203-
TARGET build_mcsema_disass_python2 POST_BUILD
204-
COMMAND which python2 && python2 setup.py build --force
205-
COMMENT "Building McSema Python 2 mcsema-disass"
206-
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")
207-
208-
add_dependencies(${MCSEMA_LIFT}
209-
build_mcsema_disass_python2)
210-
211-
add_dependencies(build_mcsema_disass_python2
212-
protobuf_python_module_ida)
213-
endif()
214-
215191
if(MCSEMA_INSTALL_PYTHON3_LIBS)
216192
add_custom_target(build_mcsema_disass_python3
217193
DEPENDS ${MCSEMA_PYTHON_SOURCES})
@@ -299,20 +275,13 @@ endif()
299275
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
300276
if(DEFINED WIN32)
301277
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
302-
set(python_package_installer2 "${python_package_installer}.bat")
303278
set(python_package_installer3 "${python_package_installer}.bat")
304279
set(optional_interpreter "cmd.exe /C")
305280
else()
306281
set(python_package_install_path "${install_folder}")
307-
set(python_package_installer2 "${python_package_installer}_py2.sh")
308282
set(python_package_installer3 "${python_package_installer}_py3.sh")
309283
endif()
310284

311-
if(MCSEMA_INSTALL_PYTHON2_LIBS)
312-
install(CODE
313-
"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()")
314-
endif()
315-
316285
if(MCSEMA_INSTALL_PYTHON3_LIBS)
317286
install(CODE
318287
"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()")

CMakeLists_vcpkg.txt

-31
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
3737

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

40-
find_package(Python2 QUIET)
41-
if(Python2_FOUND)
42-
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
43-
else()
44-
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
45-
endif()
46-
4740
find_package(Python3 QUIET)
4841
if(Python3_FOUND)
4942
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
@@ -179,23 +172,6 @@ set(MCSEMA_PYTHON_SOURCES
179172
tools/mcsema_disass/ida7/x86_util.py
180173
)
181174

182-
if(MCSEMA_INSTALL_PYTHON2_LIBS)
183-
add_custom_target(build_mcsema_disass_python2
184-
DEPENDS ${MCSEMA_PYTHON_SOURCES})
185-
186-
add_custom_command(
187-
TARGET build_mcsema_disass_python2 POST_BUILD
188-
COMMAND which python2 && python2 setup.py build --force
189-
COMMENT "Building McSema Python 2 mcsema-disass"
190-
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")
191-
192-
add_dependencies(${MCSEMA_LIFT}
193-
build_mcsema_disass_python2)
194-
195-
add_dependencies(build_mcsema_disass_python2
196-
protobuf_python_module_ida)
197-
endif()
198-
199175
if(MCSEMA_INSTALL_PYTHON3_LIBS)
200176
add_custom_target(build_mcsema_disass_python3
201177
DEPENDS ${MCSEMA_PYTHON_SOURCES})
@@ -283,20 +259,13 @@ endif()
283259
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
284260
if(DEFINED WIN32)
285261
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
286-
set(python_package_installer2 "${python_package_installer}.bat")
287262
set(python_package_installer3 "${python_package_installer}.bat")
288263
set(optional_interpreter "cmd.exe /C")
289264
else()
290265
set(python_package_install_path "${install_folder}")
291-
set(python_package_installer2 "${python_package_installer}_py2.sh")
292266
set(python_package_installer3 "${python_package_installer}_py3.sh")
293267
endif()
294268

295-
if(MCSEMA_INSTALL_PYTHON2_LIBS)
296-
install(CODE
297-
"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()")
298-
endif()
299-
300269
if(MCSEMA_INSTALL_PYTHON3_LIBS)
301270
install(CODE
302271
"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()")

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Why would anyone translate binaries *back* to bitcode?
7272
| [CMake](https://cmake.org/) | 3.2+ |
7373
| [Remill](https://github.com/lifting-bits/remill) | Latest |
7474
| [Anvill](https://github.com/lifting-bits/anvill) | Latest |
75-
| [Python](https://www.python.org/) | 2.7, 3.8 |
75+
| [Python](https://www.python.org/) | 3.8 |
7676
| [Python Package Index](https://pypi.python.org/pypi) | Latest |
7777
| [python-protobuf](https://pypi.python.org/pypi/protobuf) | 3.2.0 |
7878
| [python-clang](https://pypi.org/project/clang/) | 3.5.0 |
@@ -133,7 +133,7 @@ sudo apt-get install \
133133
git \
134134
curl \
135135
cmake \
136-
python2.7 python-pip python-virtualenv \
136+
python3 python3-pip python3-virtualenv \
137137
wget \
138138
build-essential \
139139
gcc-multilib g++-multilib \
@@ -266,7 +266,7 @@ In order to verify that McSema works correctly as built, head on over to [the do
266266
2. Do **NOT** enable "Add to PATH"
267267

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

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

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

350350
**Install the libmagic DLL**

scripts/lift_directory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ def main():
141141
return ret
142142

143143
if __name__ == "__main__":
144-
exit(main())
144+
exit(main())

0 commit comments

Comments
 (0)