Skip to content

Commit b81a927

Browse files
committed
Finish updating python installs needed for panda
1 parent 48bf566 commit b81a927

File tree

9 files changed

+39
-39
lines changed

9 files changed

+39
-39
lines changed

.github/workflows/parallel_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ on:
2020
jobs:
2121

2222
test_installer: # test install_ubuntu.sh
23-
runs-on: panda-arc # Note 22.04 would work, but it requires docker > 20.10.7 which is not on our CI box (yet)
23+
runs-on: panda-arc
2424
container:
25-
image: ubuntu:20.04
25+
image: ubuntu:22.04
2626
steps:
2727
- name: Update
2828
run: apt-get -qq update -y
@@ -31,9 +31,9 @@ jobs:
3131
- name: Set up Python
3232
uses: actions/setup-python@v5
3333
with:
34-
python-version: 3.9
34+
python-version: '3.10'
3535
- name: Install Python dev headers
36-
run: apt-get -qq install -y libpython3.9-dev
36+
run: apt-get -qq install -y libpython3.10-dev
3737
- uses: actions/checkout@v4 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
3838
- name: Lint PyPANDA with flake8
3939
run: |

Dockerfile

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
ARG BASE_IMAGE="ubuntu:20.04"
22
ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu"
3-
ARG LIBOSI_VERSION="v0.1.7"
43

54
### BASE IMAGE
6-
FROM $BASE_IMAGE as base
5+
FROM $BASE_IMAGE AS base
76
ARG BASE_IMAGE
87

98
# Copy dependencies lists into container. We copy them all and then do a mv because
@@ -16,22 +15,19 @@ RUN mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_build.txt /tmp/build_dep.txt &
1615
# Base image just needs runtime dependencies
1716
RUN [ -e /tmp/base_dep.txt ] && \
1817
apt-get -qq update && \
19-
DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends curl $(cat /tmp/base_dep.txt | grep -o '^[^#]*') && \
18+
DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends curl jq $(cat /tmp/base_dep.txt | grep -o '^[^#]*') && \
2019
apt-get clean
2120

2221
### BUILD IMAGE - STAGE 2
2322
FROM base AS builder
2423
ARG BASE_IMAGE
2524
ARG TARGET_LIST
26-
ARG LIBOSI_VERSION
2725

2826
RUN [ -e /tmp/build_dep.txt ] && \
2927
apt-get -qq update && \
3028
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \
3129
apt-get clean && \
3230
python3 -m pip install --upgrade --no-cache-dir pip && \
33-
python3 -m pip install --upgrade --no-cache-dir "cffi>1.14.3" && \
34-
python3 -m pip install --upgrade --no-cache-dir "capstone" && \
3531
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
3632

3733
# Then install capstone from source
@@ -43,13 +39,19 @@ RUN cd /tmp && \
4339
ENV PATH="/root/.cargo/bin:${PATH}"
4440

4541
# install libosi
46-
RUN cd /tmp && curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_$(echo "$BASE_IMAGE" | awk -F':' '{print $2}').deb && dpkg -i /tmp/libosi_$(echo "$BASE_IMAGE" | awk -F':' '{print $2}').deb
42+
RUN cd /tmp && \
43+
BASE_IMAGE_VERSION=$(echo "$BASE_IMAGE" | awk -F':' '{print $2}') && \
44+
LIBOSI_VERSION=$(curl -s https://api.github.com/repos/panda-re/libosi/releases/latest | jq -r .tag_name) && \
45+
curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_${BASE_IMAGE_VERSION}.deb && \
46+
dpkg -i /tmp/libosi_${BASE_IMAGE_VERSION}.deb && \
47+
rm -rf /tmp/libosi_${BASE_IMAGE_VERSION}.deb
4748

4849
# Build and install panda
4950
# Copy repo root directory to /panda, note we explicitly copy in .git directory
5051
# Note .dockerignore file keeps us from copying things we don't need
5152
COPY . /panda/
5253
COPY .git /panda/
54+
RUN python3 -m pip install -r /panda/panda/python/core/requirements.txt
5355

5456
# Note we diable NUMA for docker builds because it causes make check to fail in docker
5557
RUN git -C /panda submodule update --init dtc && \
@@ -64,14 +66,13 @@ RUN git -C /panda submodule update --init dtc && \
6466
--disable-numa \
6567
--enable-llvm && \
6668
rm -rf /panda/.git
67-
6869

6970
RUN PRETEND_VERSION=$(cat /tmp/savedversion) make -C /panda/build -j "$(nproc)"
7071

7172
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
72-
FROM builder as developer
73+
FROM builder AS developer
7374
RUN cd /panda/panda/python/core && \
74-
python3 create_panda_datatypes.py && \
75+
python3 create_panda_datatypes.py --compile && \
7576
PRETEND_VERSION=$(cat /tmp/savedversion) pip install -e . && \
7677
ldconfig && \
7778
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
@@ -82,7 +83,7 @@ RUN cd /panda/panda/python/core && \
8283
WORKDIR /panda/
8384

8485
#### Install PANDA + pypanda from builder - Stage 4
85-
FROM builder as installer
86+
FROM builder AS installer
8687
RUN make -C /panda/build install && \
8788
rm -r /usr/local/lib/panda/*/cosi \
8889
/usr/local/lib/panda/*/cosi_strace \
@@ -93,20 +94,16 @@ RUN make -C /panda/build install && \
9394
# Install pypanda
9495
RUN cd /panda/panda/python/core && \
9596
python3 create_panda_datatypes.py --install && \
97+
PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel . && \
9698
PRETEND_VERSION=$(cat /tmp/savedversion) pip install .
97-
RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install --force-reinstall --no-binary :all: cffi
98-
# Build a whl too
99-
RUN cd /panda/panda/python/core && \
100-
python3 create_panda_datatypes.py --install && \
101-
PRETEND_VERSION=$(cat /tmp/savedversion) python3 -m build --wheel .
10299

103100
# BUG: PANDA sometimes fails to generate all the necessary files for PyPANDA. This is a temporary fix to detect and fail when this occurs
104101
RUN ls -alt $(pip show pandare | grep Location: | awk '{print $2}')/pandare/autogen/
105102
RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/autogen/panda_{aarch64_64,arm_32,mips64_64,mips_32,mipsel_32,ppc_32,ppc_64,x86_64_64,i386_32}.py"
106103

107104
# this layer is used to strip shared objects and change python data to be
108105
# symlinks to the installed panda data directory
109-
FROM installer as cleanup
106+
FROM installer AS cleanup
110107
RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
111108
RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \
112109
rm -rf $PKG/pc-bios && ln -s /usr/local/share/panda $PKG/pc-bios; \
@@ -121,24 +118,23 @@ RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \
121118
done
122119

123120
### Copy files for panda+pypanda from installer - Stage 5
124-
FROM base as panda
121+
FROM base AS panda
125122

126123
# Include dependency lists for packager
127124
COPY --from=base /tmp/base_dep.txt /tmp
128125
COPY --from=base /tmp/build_dep.txt /tmp
129126

130127
# Copy panda + libcapstone.so* + libosi libraries
131128
COPY --from=cleanup /usr/local /usr/local
132-
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
133-
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
129+
COPY --from=cleanup /usr/lib/libcapstone.so* /usr/lib/
130+
COPY --from=cleanup /usr/lib/libosi.so /usr/lib/libiohal.so /usr/lib/liboffset.so /usr/lib/
134131

135132
# Workaround issue #901 - ensure LD_LIBRARY_PATH contains the panda plugins directories
136133
#ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
137134
ENV LD_LIBRARY_PATH /usr/local/lib/python3.8/dist-packages/pandare/data/x86_64-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/i386-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/arm-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/ppc-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mips-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mipsel-softmmu/panda/plugins/
138135
#PANDA_PATH is used by rust plugins
139136
ENV PANDA_PATH /usr/local/lib/python3.8/dist-packages/pandare/data
140137

141-
142138
# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
143139
RUN ldconfig && \
144140
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \

panda/debian/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
panda.deb
1+
*.deb
2+
*.whl
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Jinja2==3.1.2
1+
Jinja2>=3.1.4
22
MarkupSafe==2.1.3

panda/python/core/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ data
88
a
99
__pycache__
1010
*.egg-info
11+
.eggs/

panda/python/core/create_panda_datatypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,14 @@ def copy_objs():
690690
'and prep for PyPanda wheel installation')
691691
parser.add_argument('--install', '-i', dest='install', action='store_true',
692692
help='If set, this means update pandare folder for installation')
693-
parser.add_argument('--recompile', '-r', dest='recompile', action='store_true',
694-
help='If set, recompile the headers with cffi')
693+
parser.add_argument('--compile', '-c', dest='compile', action='store_true',
694+
help='If set, compile the headers with cffi')
695695
args = parser.parse_args()
696696
"""
697697
Install as a local module (not to system) by
698698
1) Creating datatype files for local-use
699699
2) Running regular setup tools logic
700700
"""
701-
main()
701+
main(args.compile)
702702
if args.install:
703703
copy_objs()

panda/python/core/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ requires-python = ">=3.6"
3434
dependencies = [
3535
"cffi>=1.14.3",
3636
"protobuf>=4.25.1",
37-
"colorama"
37+
"colorama",
38+
"capstone==5.0.3"
3839
]
3940

4041
[tool.setuptools_scm]

panda/python/core/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cffi>=1.14.3
22
protobuf>=4.25.1
3+
capstone==5.0.3
34
colorama

panda/scripts/install_ubuntu.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lsb_release --help &>/dev/null || $SUDO apt-get update -qq && $SUDO apt-get -qq
2525
git --help &>/dev/null || $SUDO apt-get -qq update && $SUDO apt-get -qq install -y --no-install-recommends git
2626

2727
# some globals
28-
LIBOSI_VERSION="0.1.7"
28+
LIBOSI_VERSION="v0.1.9"
2929
UBUNTU_VERSION=$(lsb_release -r | awk '{print $2}')
3030
PANDA_GIT="https://github.com/panda-re/panda.git"
3131

@@ -120,17 +120,12 @@ fi
120120
# if the windows introspection library is not installed, clone and install
121121
if [[ !$(dpkg -l | grep -q libosi) ]]; then
122122
pushd /tmp
123-
curl -LJO https://github.com/panda-re/libosi/releases/download/v${LIBOSI_VERSION}/libosi_${UBUNTU_VERSION}.deb
123+
curl -LJO https://github.com/panda-re/libosi/releases/download/${LIBOSI_VERSION}/libosi_${UBUNTU_VERSION}.deb
124124
$SUDO dpkg -i /tmp/libosi_${UBUNTU_VERSION}.deb
125125
rm -rf /tmp/libosi_${UBUNTU_VERSION}.deb
126126
popd
127127
fi
128128

129-
# PyPANDA needs CFFI from pip (the version in apt is too old)
130-
# Install system-wide since PyPANDA install will also be system-wide
131-
$SUDO python3 -m pip install pip
132-
$SUDO python3 -m pip install "cffi>1.14.3"
133-
134129
progress "Trying to update DTC submodule"
135130
git submodule update --init dtc || true
136131

@@ -139,6 +134,11 @@ if [ -d "build" ]; then
139134
rm -rf "build"
140135
fi
141136

137+
# PyPANDA needs CFFI from pip (the version in apt is too old)
138+
# Install system-wide since PyPANDA install will also be system-wide
139+
python3 -m pip install --upgrade --no-cache-dir pip
140+
$SUDO python3 -m pip install -r ./panda/python/core/requirements.txt
141+
142142
progress "Building PANDA..."
143143
mkdir build
144144
pushd build
@@ -147,7 +147,7 @@ pushd build
147147
progress "PANDA is built and ready to use in panda/build/[arch]-softmmu/panda-system-[arch]."
148148

149149
cd ../panda/python/core
150-
python3 create_panda_datatypes.py --install
150+
python3 create_panda_datatypes.py --compile --install
151151
$SUDO python3 -m pip install .
152152
python3 -c "import pandare; panda = pandare.Panda(generic='i386')" # Make sure it worked
153153
progress "Pypanda successfully installed"

0 commit comments

Comments
 (0)