Skip to content

Commit

Permalink
[WIP] Python 3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Oct 22, 2023
1 parent e5ef1da commit bfa3d55
Show file tree
Hide file tree
Showing 24 changed files with 82 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-${ARCH}.sh
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-sdk-${ARCH}.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
-v $GITHUB_WORKSPACE:/work \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-sdk-aarch64
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
Expand All @@ -49,7 +49,7 @@ jobs:
needs: linux-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: ['3.12']
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.sh
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-py-aarch64
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/linux-x86-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ jobs:
shell: bash
run: |
mkdir -p $RUNNER_TEMP/lief-install
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_sdk.sh
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 \
bash /src/scripts/docker/linux-sdk-x64
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -77,13 +78,14 @@ jobs:
-e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
liefproject/manylinux_2_28_x86_64 \
bash /src/scripts/docker/test-linux-x64
pywheels:
runs-on: ubuntu-latest
needs: linux-sdk
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.12']
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -121,7 +123,8 @@ jobs:
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux.sh
liefproject/manylinux_2_28_x86_64 \
bash /src/scripts/docker/linux-py-x64
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
needs: osx-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
arch: ['x64', 'arm64']
fail-fast: false
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
-v $GITHUB_WORKSPACE:/src \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/test-linux-x64
windows:
runs-on: windows-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sanitize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
-e BUILD_DIR=/tmp/build_gcc \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/gcc.sh
liefproject/sanity:latest bash /src/scripts/docker/test-gcc
clang:
runs-on: ubuntu-latest
steps:
Expand All @@ -29,7 +29,7 @@ jobs:
-e BUILD_DIR=/tmp/build_clang \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/clang.sh
liefproject/sanity:latest bash /src/scripts/docker/test-clang
asan:
runs-on: ubuntu-latest
steps:
Expand All @@ -41,4 +41,4 @@ jobs:
run: |
docker run --rm \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/asan_check.sh
liefproject/sanity:latest bash /src/scripts/docker/test-asan
2 changes: 1 addition & 1 deletion .github/workflows/windows-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
needs: build-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12-dev']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
arch: ['x86', 'x64']
fail-fast: false
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "**"

env:
python-version: '3.9'
python-version: '3.12'

jobs:
quick-test:
Expand Down
7 changes: 4 additions & 3 deletions api/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ def __init__(self, *args, **kwargs):
def run(self):
for ext in self.extensions:
self.build_extension(ext)
self.copy_extensions_to_source()

if self.inplace:
self.copy_extensions_to_source()

def _fix_platform(self):
if sys.platform == "darwin":
Expand Down Expand Up @@ -498,9 +500,8 @@ class egg_info(_egg_info):
long_description=long_description.read_text(),
long_description_content_type="text/x-rst; charset=UTF-8",
distclass=LiefDistribution,
scripts=['examples/elf_reader.py', 'examples/pe_reader.py', 'examples/macho_reader.py'],
packages=["lief"],
package_data={"lief": ["py.typed", "*.pyi", "*.so", "*.pyd"]},
package_data={"lief": ["py.typed", "*.pyi", "*.pyd"]},
ext_modules=[Module("lief._lief")],
cmdclass=cmdclass,
version=version
Expand Down
24 changes: 12 additions & 12 deletions scripts/docker/android-arm.sh → scripts/docker/android-sdk-arm
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ git config --global --add safe.directory /work
mkdir -p build/$ARCH_DIR/static-release && mkdir -p build/$ARCH_DIR/shared-release
pushd build/$ARCH_DIR/shared-release

cmake ../../.. -GNinja \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
cmake ../../.. -GNinja \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++" \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_BUILD_TYPE=Release

ninja

popd
pushd build/$ARCH_DIR/static-release

cmake ../../.. -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
cmake ../../.. -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
-DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++" \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DCMAKE_BUILD_TYPE=Release

ninja
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ git config --global --add safe.directory /work
mkdir -p build/$ARCH_DIR/static-release && mkdir -p build/$ARCH_DIR/shared-release
pushd build/$ARCH_DIR/shared-release

cmake ../../.. -GNinja \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
cmake ../../.. -GNinja \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++" \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_BUILD_TYPE=Release

ninja

popd
pushd build/$ARCH_DIR/static-release

cmake ../../.. -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
cmake ../../.. -GNinja \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
-DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++" \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DLIEF_PYTHON_API=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DCMAKE_BUILD_TYPE=Release

ninja
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions scripts/docker/linux-py-aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/bash
set -ex

export CXXFLAGS='-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc'
export CFLAGS='-ffunction-sections -fdata-sections -static-libgcc'
export LDFLAGS='-Wl,--gc-sections'
export LIEF_BUILD_DIR=/tmp/lief-build
export _PYTHON_HOST_PLATFORM="manylinux2014-aarch64"
export SETUPTOOLS_EXT_SUFFIX=$($PYTHON_BINARY -c "import sysconfig;print(sysconfig.get_config_var('EXT_SUFFIX').replace('x86_64', 'aarch64'))")

git config --global --add safe.directory /work

$PYTHON_BINARY -m pip install tomli pip wheel

pushd /work/api/python
export PYLIEF_CONF=/work/scripts/docker/config/pylinux-aarch64.toml
$PYTHON_BINARY -m pip -vvv wheel --no-build-isolation --wheel-dir=/work/dist .
popd
10 changes: 4 additions & 6 deletions scripts/docker/run_linux.sh → scripts/docker/linux-py-x64
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ set -ex
export CXXFLAGS='-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc'
export CFLAGS='-ffunction-sections -fdata-sections -static-libgcc'
export LDFLAGS='-Wl,--gc-sections -Wl,--strip-all'

export LIEF_BUILD_DIR="/tmp/lief-build"
export PYLIEF_CONF=/src/scripts/docker/config/pylinux-x64.toml
export LIEF_BUILD_DIR=/tmp/lief-build

$PYTHON_BINARY -m pip install tomli pip wheel

pushd /src/api/python
export PYLIEF_CONF=/src/scripts/docker/pylinux-x64.toml \

$PYTHON_BINARY -m pip -vvv wheel --no-build-isolation --wheel-dir=/src/wheel_stage .
$PYTHON_BINARY -m pip -vvv install --user .
popd

find /src/wheel_stage -iname "*-cp${PYTHON_VERSION}-*" -exec auditwheel repair -w /src/dist {} \;

chown -R 1000:1000 /src/dist /src/wheel_stage
find /src/wheel_stage -iname "*-cp${PYTHON_VERSION}-*" \
-exec auditwheel repair -w /src/dist {} \;
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
#!/usr/bin/bash
set -ex

# Script to be run with liefproject/manylinux2014-aarch64:
# ==============================================================================================
# docker run \
# -e CCACHE_DIR=/ccache \
# -v $LIEF_SRC:/work \
# -v $HOME/.ccache:/ccache \
# --rm liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
# ==============================================================================================
#

CXXFLAGS='-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc -static-libstdc++'
CFLAGS='-ffunction-sections -fdata-sections -static-libgcc'
export LDFLAGS='-Wl,--gc-sections -Wl,--exclude-libs,ALL'

ARCH_DIR="linux-aarch64"
git config --global --add safe.directory /work

mkdir -p build/$ARCH_DIR/static-release && mkdir -p build/$ARCH_DIR/shared-release
mkdir -p build/$ARCH_DIR/static-release
mkdir -p build/$ARCH_DIR/shared-release

cmake -S /work -B /work/build/$ARCH_DIR/shared-release -GNinja \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
Expand Down Expand Up @@ -46,5 +37,3 @@ popd

/bin/mv build/$ARCH_DIR/*.tar.gz build/
ls -alh build

chown -R 1000:1000 build/
File renamed without changes.
33 changes: 0 additions & 33 deletions scripts/docker/manylinux2014-aarch64.sh

This file was deleted.

32 changes: 0 additions & 32 deletions scripts/docker/run_archlinux.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/docker/gcc.sh → scripts/docker/test-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
set -ex
cmake -B ${BUILD_DIR} -S ${SRC_DIR} -GNinja \
-DLIEF_USE_CCACHE=off \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DCMAKE_C_COMPILER=/usr/bin/gcc
ninja -C ${BUILD_DIR} LIB_LIEF

0 comments on commit bfa3d55

Please sign in to comment.