Skip to content

Commit ba92f79

Browse files
authored
Merge pull request #1823 from unicorn-engine/restore-py2
[RFC] Restore py2 compatibility by using 2 files
2 parents d1da4de + 3c89d0c commit ba92f79

File tree

7 files changed

+2114
-1113
lines changed

7 files changed

+2114
-1113
lines changed

bindings/python/README.TXT

-41
This file was deleted.

bindings/python/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Python Bindings for Unicorn
2+
3+
## Install
4+
5+
Install a prebuilt wheel from PyPI:
6+
7+
```bash
8+
pip3 install unicorn
9+
```
10+
11+
In case you would like to develop the bindings:
12+
13+
```bash
14+
# Python3
15+
DEBUG=1 THREADS=4 pip3 install --user -e .
16+
# Workaround for Pylance
17+
DEBUG=1 THREADS=4 pip3 install --user -e . --config-settings editable_mode=strict
18+
# Python2
19+
DEBUG=1 THREADS=4 pip install -e .
20+
```
21+
22+
or install it by building it by yourself:
23+
24+
```bash
25+
# Python3
26+
THREADS=4 pip3 install --user .
27+
# Python2, unfortunately `pip2` doesn't support in-tree build
28+
THREADS=4 python3 setup.py install
29+
```
30+
31+
Explanations for arguments:
32+
33+
- `THREADS=4` will use 4 threads for building.
34+
- `DEBUG=1` will build debug version of unicorn.
35+
- `--user` will install the bindings to your user directory instead of requiring root permission.
36+
- `-e` infers the editable mode, which gives your instant feedback instead of re-compiling every time.
37+
38+
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.
39+
40+
## Python2 compatibility
41+
42+
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!

bindings/python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def build_libraries():
136136
os.mkdir(BUILD_DIR)
137137
conf = 'Debug' if os.getenv('DEBUG', '') else 'Release'
138138

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

0 commit comments

Comments
 (0)