Skip to content

Commit

Permalink
Merge pull request #1823 from unicorn-engine/restore-py2
Browse files Browse the repository at this point in the history
[RFC] Restore py2 compatibility by using 2 files
  • Loading branch information
wtdcode authored Mar 8, 2024
2 parents d1da4de + 3c89d0c commit ba92f79
Show file tree
Hide file tree
Showing 7 changed files with 2,114 additions and 1,113 deletions.
41 changes: 0 additions & 41 deletions bindings/python/README.TXT

This file was deleted.

42 changes: 42 additions & 0 deletions bindings/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Python Bindings for Unicorn

## Install

Install a prebuilt wheel from PyPI:

```bash
pip3 install unicorn
```

In case you would like to develop the bindings:

```bash
# 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:

```bash
# 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!
2 changes: 1 addition & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def build_libraries():
os.mkdir(BUILD_DIR)
conf = 'Debug' if os.getenv('DEBUG', '') else 'Release'

cmake_args = ["cmake", '-B', BUILD_DIR, "-DCMAKE_BUILD_TYPE=" + conf]
cmake_args = ["cmake", '-B', BUILD_DIR, '-S', UC_DIR, "-DCMAKE_BUILD_TYPE=" + conf]
if os.getenv("TRACE", ""):
cmake_args += ["-DUNICORN_TRACER=on"]
subprocess.check_call(cmake_args)
Expand Down
Loading

0 comments on commit ba92f79

Please sign in to comment.