unicorn/bindings/python
lazymio ba92f79c9e
Merge pull request #1823 from unicorn-engine/restore-py2
[RFC] Restore py2 compatibility by using 2 files
2024-03-08 15:12:24 +08:00
..
prebuilt Allow dlls to be copied out of prebuilt directory 2016-11-17 20:59:39 -08:00
unicorn Fix ctl_remove_cache for python2 2023-08-09 14:11:21 +08:00
build_wheel.sh Use dockcross for aarch64 wheel 2022-10-01 01:31:13 +02:00
Makefile Fix gen_const 2021-10-26 13:10:59 +02:00
MANIFEST.in Basically, make python builds work as expected 2016-09-12 14:06:20 -07:00
README.md Restore Py2 compatibility 2023-06-28 16:40:43 +08:00
sample_all.sh fix file perms 2015-08-28 21:05:38 -07:00
sample_arm64.py Update sample for MRS hook 2022-02-27 15:28:32 +01:00
sample_arm64eb.py Fix Python 3 samples (#836) 2017-05-15 09:11:22 +08:00
sample_arm.py Implement coprocessor register read/write for python bindings 2022-02-11 23:03:56 +01:00
sample_armeb.py update armeb & arm64eb samples 2017-04-25 12:55:26 +08:00
sample_ctl.py Fix sample_ctl.py. 2023-05-07 09:08:20 -07:00
sample_m68k.py make cleanup 2016-11-06 16:27:24 -08:00
sample_mips.py make cleanup 2016-11-06 16:27:24 -08:00
sample_network_auditing.py Get Python samples running on Python 3 2016-07-29 00:28:43 -07:00
sample_ppc.py import Unicorn2 2021-10-03 22:14:44 +08:00
sample_riscv.py import Unicorn2 2021-10-03 22:14:44 +08:00
sample_s390x.py python: add some more comments for samples 2022-10-31 12:37:18 +08:00
sample_sparc.py make cleanup 2016-11-06 16:27:24 -08:00
sample_tricore.py TriCore Support (#1568) 2022-04-29 23:11:34 +02:00
sample_x86.py remove semicolons 2024-03-06 02:15:02 -05:00
setup.cfg Fixes to make python distribution for windows work 2016-11-05 09:18:50 -07:00
setup.py Merge pull request #1823 from unicorn-engine/restore-py2 2024-03-08 15:12:24 +08:00
shellcode.py remove semicolons 2024-03-06 02:15:02 -05:00

Python Bindings for Unicorn

Install

Install a prebuilt wheel from PyPI:

pip3 install unicorn

In case you would like to develop the bindings:

# Python3
DEBUG=1 THREADS=4 pip3 install --user -e .
# Workaround for Pylance
DEBUG=1 THREADS=4 pip3 install --user -e . --config-settings editable_mode=strict
# Python2
DEBUG=1 THREADS=4 pip install -e .

or install it by building it by yourself:

# Python3
THREADS=4 pip3 install --user .
# Python2, unfortunately `pip2` doesn't support in-tree build
THREADS=4 python3 setup.py install

Explanations for arguments:

  • THREADS=4 will use 4 threads for building.
  • DEBUG=1 will build debug version of unicorn.
  • --user will install the bindings to your user directory instead of requiring root permission.
  • -e infers the editable mode, which gives your instant feedback instead of re-compiling every time.

Note that you should setup a valid building environment according to docs/COMPILE.md but not necessarily build it because setup.py will do this for you.

Python2 compatibility

By default, Unicorn python bindings will be maintained against Python3 as it offers more powerful features which improves developing efficiency. Meanwhile, Unicorn will only keep compatible with all features Unicorn1 offers regarding Python2 because Python2 has reached end-of-life for more than 3 years as the time of writing this README. While offering all features for both Python2 & Python3 is desirable and doable, it inevitably costs too much efforts to maintain and few users really rely on this. Therefore, we assume that if users still stick to Python2, previous Unicorn1 features we offer should be enough. If you really want some new features Unicorn2 offers, please check and pull request to `unicorn/unicorn_py2``. We are happy to review and accept!