From b0ab7fd6d74851fe1b6f62e558583d14bed10802 Mon Sep 17 00:00:00 2001 From: Antelox Date: Mon, 3 Mar 2025 14:45:26 +0100 Subject: [PATCH 1/2] Python bindings: Port pkg_resources to importlib_resources for python < 3.9 Co-authored-by: Arusekk --- .github/workflows/build-wheels-publish.yml | 6 ++---- bindings/python/pyproject.toml | 3 +++ bindings/python/unicorn/unicorn_py3/unicorn.py | 12 +++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-wheels-publish.yml b/.github/workflows/build-wheels-publish.yml index 56708b12b7..c68bad7479 100644 --- a/.github/workflows/build-wheels-publish.yml +++ b/.github/workflows/build-wheels-publish.yml @@ -296,11 +296,9 @@ jobs: - name: Build SDist run: | - cd bindings/python python3 -m pip install -U pip build - python3 -m build --sdist - python3 -m pip install dist/*.tar.gz - cd ~ + python3 -m build --sdist bindings/python + python3 -m pip install bindings/python/dist/*.tar.gz python3 -c 'import unicorn; print(f"Unicorn version installed from sdist: {unicorn.__version__}")' - uses: actions/upload-artifact@v4 diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index f9562d00a4..e897e2898a 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -6,6 +6,9 @@ build-backend = "setuptools.build_meta" name = "unicorn" dynamic = ["version"] requires-python = ">= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*, != 3.5.*, != 3.6.*" +dependencies = [ + "importlib_resources; python_version < '3.9'" +] authors = [ { name = "Nguyen Anh Quynh", email = "quynh@gmail.com" }, ] diff --git a/bindings/python/unicorn/unicorn_py3/unicorn.py b/bindings/python/unicorn/unicorn_py3/unicorn.py index 8684a391e3..0a6b31504a 100644 --- a/bindings/python/unicorn/unicorn_py3/unicorn.py +++ b/bindings/python/unicorn/unicorn_py3/unicorn.py @@ -109,19 +109,17 @@ def _load_lib(path: Path, lib_name: str): # Loading attempts, in order # - user-provided environment variable - # - pkg_resources can get us the path to the local libraries + # - importlib.resources/importlib_resources can get us the path to the local libraries # - we can get the path to the local libraries by parsing our filename # - global load # - python's lib directory - if sys.version_info.minor >= 12: - from importlib import resources - - canonicals = resources.files('unicorn') / 'lib' + if sys.version_info >= (3, 9): + import importlib.resources as resources else: - import pkg_resources + import importlib_resources as resources - canonicals = pkg_resources.resource_filename('unicorn', 'lib') + canonicals = resources.files('unicorn') / 'lib' lib_locations = [ os.getenv('LIBUNICORN_PATH'), From 69045f32db57358cfdbcb819b3222786cefcf6e1 Mon Sep 17 00:00:00 2001 From: Antelox Date: Mon, 3 Mar 2025 16:05:57 +0100 Subject: [PATCH 2/2] GitHub Workflow: Bump uraimo/run-on-arch-action to v3 --- .github/workflows/Nuget-publishing.yml | 2 +- .github/workflows/build-uc2.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Nuget-publishing.yml b/.github/workflows/Nuget-publishing.yml index 505f416d26..820a7a0563 100644 --- a/.github/workflows/Nuget-publishing.yml +++ b/.github/workflows/Nuget-publishing.yml @@ -288,7 +288,7 @@ jobs: - name: '🚧 Linux ppc64le build' if: contains(matrix.config.arch, 'ppc64le') - uses: uraimo/run-on-arch-action@v2 + uses: uraimo/run-on-arch-action@v3 with: arch: ${{ matrix.config.arch }} distro: ${{ matrix.config.distro }} diff --git a/.github/workflows/build-uc2.yml b/.github/workflows/build-uc2.yml index fc6e678f5b..01bd14c68b 100644 --- a/.github/workflows/build-uc2.yml +++ b/.github/workflows/build-uc2.yml @@ -494,7 +494,7 @@ jobs: - name: '🚧 Linux ppc64le build' if: contains(matrix.config.arch, 'ppc64le') - uses: uraimo/run-on-arch-action@v2 + uses: uraimo/run-on-arch-action@v3 with: arch: ${{ matrix.config.arch }} distro: ${{ matrix.config.distro }}