From c81d1bd35f36f5596399d88786465ecbc8c4a646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Perceval=20Wajsb=C3=BCrt?= Date: Tue, 6 Jun 2023 10:17:34 +0200 Subject: [PATCH 1/2] Add GitHub actions to publish on PyPi --- .github/workflows/release.yml | 61 ++++++++++++++++++++++++++++++++ .github/workflows/test-build.yml | 34 ++++++++++++++++++ README.markdown | 14 +++++++- pyproject.toml | 9 +++++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test-build.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..b171c7e40 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.13.0 + + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v2 + with: + path: dist/*.tar.gz + + PyPI: + name: Upload to PyPI + + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v2 + with: + name: artifact + path: dist + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 000000000..83ed9c849 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,34 @@ +# This tries to build packages, and tests the packages. +# It runs on every push to branches following the pattern v*.*.*. +# It makes sure that everything will run when the version is released. + +name: Test Build + +on: + workflow_dispatch: + push: + branches: + - v*.*.* + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.13.0 + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build sdist + run: pipx run build --sdist diff --git a/README.markdown b/README.markdown index 4ac8a97ac..a1b531f40 100644 --- a/README.markdown +++ b/README.markdown @@ -1,3 +1,7 @@ +![Tests](https://img.shields.io/github/actions/workflow/status/zrax/pycdc/linux-ci.yml?branch=master&label=tests&style=flat-square) +[![PyPI](https://img.shields.io/pypi/v/pycdc?color=blue&style=flat-square)](https://pypi.org/project/pycdc/) +[![Python](https://img.shields.io/pypi/pyversions/pycdc?color=blue&style=flat-square)](https://pypi.org/project/pycdc/) + # Decompyle++ ***A Python Byte-code Disassembler/Decompiler*** @@ -51,7 +55,15 @@ Both tools support Python marshalled code objects, as output from `marshal.dumps To use this feature, specify `-c -v ` on the command line - the version must be specified as the objects themselves do not contain version metadata. -**To use the Python bindings**, run the following Python script: +**To use the Python bindings** + +Ensure the `pycdc` Python package is installed: + +- either from source (see [above](#building-and-installing-the-python-package)) +- or from PyPi : `pip install pycdc` + +Then, use it as below: + ```python import marshal from pycdc import decompyle diff --git a/pyproject.toml b/pyproject.toml index bbaefaa3d..9b8f03f89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,15 @@ readme = "README.md" urls.homepage = "https://github.com/zrax/pycdc" dynamic = ["version"] requires-python = ">3.7.6,<3.11" +classifiers = [ + # Specify the Python versions you support here. In particular, ensure + # that you indicate whether you support Python 2, Python 3 or both. + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', +] dependencies = [] From 89d57032dfbe2c77168af7e994da841b876eee6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Perceval=20Wajsb=C3=BCrt?= Date: Wed, 7 Jun 2023 00:54:00 +0200 Subject: [PATCH 2/2] Test cibuildwheel output --- pyproject.toml | 2 ++ tests/test_bindings.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/test_bindings.py diff --git a/pyproject.toml b/pyproject.toml index 9b8f03f89..b049443cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,8 @@ build-backend = "setuptools.build_meta" [tool.cibuildwheel] +test-requires = "pytest" +test-command = "pytest {project}/tests/test_bindings.py" skip = [ "*p36-*", # Skip Python 3.6 "pp*", # Skip PyPy diff --git a/tests/test_bindings.py b/tests/test_bindings.py new file mode 100644 index 000000000..3f7bcae10 --- /dev/null +++ b/tests/test_bindings.py @@ -0,0 +1,20 @@ +import marshal + +from pycdc import decompyle + + +def func(): + a = 6 + data = foobar(a) + return data + + +body = """\ +a = 6 +data = foobar(a) +return data +""" + + +def test_marshalled_code(): + assert decompyle(marshal.dumps(func.__code__)) == body