Skip to content

Commit

Permalink
Python 3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Oct 28, 2023
1 parent 00a0015 commit 29f7e9d
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 244 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}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down
53 changes: 32 additions & 21 deletions .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ 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:/work \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
docker run --name lief-sdk -u 1001:1001 --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/manylinux2014-aarch64 \
bash /src/scripts/docker/linux-sdk-aarch64
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
Expand All @@ -49,7 +54,7 @@ jobs:
needs: linux-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']
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -76,18 +81,23 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.sh
PYTHON_BINARY="/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}"
docker run -u 1001:1001 --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=$PYTHON_BINARY \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 \
bash /src/scripts/docker/linux-py-aarch64
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -124,6 +134,7 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy \
python3 /src/.github/deploy.py /runner_tmp/artifacts
78 changes: 47 additions & 31 deletions .github/workflows/linux-x86-64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ 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
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
docker run --name lief-sdk -u 1001:1001 --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 @@ -67,23 +71,28 @@ jobs:
shell: bash
env:
PYTHON_VERSION: 38
PYTHON_BINARY: "/opt/python/cp38-cp38/bin/python3.8"
run: |
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION \
-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
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
docker run --rm -u 1001:1001 \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=$PYTHON_BINARY \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
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.8, 3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -111,17 +120,23 @@ jobs:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-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
PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
docker run --rm -u 1001:1001 \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=$PYTHON_BINARY \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux_2_28_x86_64 \
bash /src/scripts/docker/linux-py-x64
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -158,7 +173,8 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy \
python3 /src/.github/deploy.py /runner_tmp/artifacts
documentation:
needs: [deploy]
runs-on: ubuntu-latest
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
10 changes: 5 additions & 5 deletions .github/workflows/windows-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
build-sdk:
runs-on: windows-2019
runs-on: windows-2022
strategy:
matrix:
arch: ['x64', 'x86']
Expand All @@ -36,7 +36,7 @@ jobs:
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
Expand Down 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 All @@ -172,7 +172,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
- "**"

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

jobs:
quick-test:
runs-on: windows-2019
runs-on: windows-2022
strategy:
matrix:
arch: [x64, x86]
Expand All @@ -37,7 +37,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
Expand Down
9 changes: 5 additions & 4 deletions api/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_lief_logging_opt(self):
def get_python_opt(self):
config = ["-DLIEF_PYTHON_API=on"]
interpreter = Path(sys.executable)
base = sysconfig.get_config_var("base")
base = sysconfig.get_config_var("installed_base")
if base is not None:
config += [f"-DPython_ROOT_DIR={base}"]

Expand Down 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 @@ -491,9 +493,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
Loading

0 comments on commit 29f7e9d

Please sign in to comment.