Skip to content

Commit

Permalink
Attempt at Python packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Aug 12, 2023
1 parent 621572f commit f28ae88
Show file tree
Hide file tree
Showing 598 changed files with 255,446 additions and 141 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python/Ghidra/** linguist-generated
197 changes: 106 additions & 91 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,126 @@
# This file is autogenerated by maturin v1.0.1
# To update, run
#
# maturin generate-ci github
#
name: CI

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:

permissions:
contents: read
on: [push, pull_request]

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
# linux:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [x86_64, aarch64]
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: 'true'

# - uses: actions/setup-python@v4
# with:
# python-version: '3.10'

# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@stable
# with:
# targets: aarch64-linux-gnu, x86-64-linux-gnu

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64]
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
# - name: Install Rust aarch64-apple-darwin target
# if: matrix.platform.os == 'macos-latest'
# run: rustup target add aarch64-apple-darwin

# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist

# windows:
# runs-on: windows-latest
# strategy:
# matrix:
# target: [x64]
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: 'true'

# - uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# architecture: ${{ matrix.target }}

# - name: Build wheels
# uses: PyO3/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# args: --release --out dist --find-interpreter
# sccache: 'true'

# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist

macos:
# Skip building pull requests from the same repository
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4

- name: Python environment
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
targets: aarch64-apple-darwin, x86_64-apple-darwin

- name: Build
shell: bash
env:
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
MACOSX_DEPLOYMENT_TARGET: '10.9'
ARCHFLAGS: -arch x86_64 -arch arm64
PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
run: |
pip install -r requirements.txt
python setup.py bdist_wheel --py-limited-api=cp37
pip install --force-reinstall dist/*_universal2.whl
- name: Test
run: |
# Import the package we just built
python -c "import icicle"
# Run example code
python tests/example.py
# Run exception tests
python tests/invalid.py
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *

# release:
# name: Release
# runs-on: ubuntu-latest
# if: "startsWith(github.ref, 'refs/tags/')"
# needs: [linux, windows, macos]
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: wheels
# - name: Publish to PyPI
# uses: PyO3/maturin-action@v1
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# with:
# command: upload
# args: --skip-existing *
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ debug/
venv*/
.env/
dist/
.DS_Store
build/
.DS_Store
__pycache__/
*.egg-info/
*.so
*.dll
*.dylib
33 changes: 21 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ icicle-vm = { path = "icicle-emu/icicle-vm" }
pcode = { path = "icicle-emu/sleigh/pcode" }
sleigh-runtime = { path = "icicle-emu/sleigh/sleigh-runtime" }
indexmap = "1.9.3"
pyo3 = { version = "0.18.3", features = ["extension-module", "indexmap"] }
pyo3 = { version = "0.19.2", features = ["extension-module", "indexmap", "abi3-py37"] }
target-lexicon = "0.12.7"
tracing = "*"
tracing-subscriber = "0.3.17"

[build-dependencies]
pyo3-build-config = "0.18.3"
pyo3-build-config = "0.19.2"
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
11 changes: 11 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include Cargo.lock
include Cargo.toml
include README.md
include build.rs
include requirements.txt
recursive-include src *
recursive-include icicle-emu *
recursive-include python *.py
recursive-include python *.pyi
recursive-include python py.typed
recursive-include python/icicle/Ghidra *
Loading

0 comments on commit f28ae88

Please sign in to comment.